From aaea7ab4e9d4a949c4a675ed13f0bf64a7ddd8ab Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 18 Feb 2020 19:41:29 +0000 Subject: [PATCH] Allow a socket created/connected in one thread to be used in another. See #1233 --- nse_nsock.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nse_nsock.cc b/nse_nsock.cc index 7808585ff..75ddeb638 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -366,6 +366,16 @@ static void callback (nsock_pool nsp, nsock_event nse, void *ud) nu->action = "ERROR"; return; } + switch (nse_type(nse)) { + case NSE_TYPE_CONNECT: + case NSE_TYPE_CONNECT_SSL: + /* After a connect or reconnect event, allow the socket to be reused by a + * different thread. */ + nu->thread = NULL; + break; + default: + break; + } assert(lua_status(L) == LUA_YIELD); trace(nse_iod(nse), nu->action, nu->direction); status(L, nse_status(nse));