#666 Race condition in net.http.request with server_select

Reporter Zash
Owner MattJ
Created
Updated
Stars (0)
Tags
  • Priority-Medium
  • Status-Fixed
  • Type-Defect
  • Milestone-0.11
  1. Zash on

    What steps will reproduce the problem? 1. Use server_select 2. Call net.http.request("https://localhost/", ...) 3. Be unlucky What is the expected output? Successful https request. What do you see instead? Traceback, partly obscured by the TLS handshake coroutine: net/http.lua:35: attempt to index local 'req' (a nil value) -- in listener.onconnect() stack traceback: [C]: in function 'handshake' net/server_select.lua:653: in function 'starttls' If both the underlying LuaSocket connect call and the TLS handshake completes straight away then server_select will call the onconnect listener callback before the server.addclient() call in net.http.request() returns the connection handle. The HTTP request object is associated with the connection after addclient returns, so in this case onconnect is called before this happens, which leads to the traceback.

  2. Zash on

    Presumed to be fixed in https://hg.prosody.im/trunk/rev/2bd2e94a0496

    Changes
    • tags Milestone-0.11 Status-Fixed
    • owner MattJ

New comment

Not published. Used for spam prevention and optional update notifications.