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

Reporter Zash
Owner MattJ
Stars (0)
  • Priority-Medium
  • Status-Fixed
  • Milestone-0.11
  • Type-Defect
  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

    • owner MattJ
    • tags Milestone-0.11 Status-Fixed

New comment

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