[NSE] Upon connection failure, a socket will now unlock its "socket lock"

allowing other pending socket connections to succeed sooner. This change
only slightly speeds up the process as these sockets will be collected
eventually, causing the slots to be unlocked.
This commit is contained in:
batrick 2009-05-17 20:05:39 +00:00
parent 3b36da46b2
commit 94ff7eb079

View file

@ -469,12 +469,14 @@ static int l_nsock_connect(lua_State *L) {
error_id = getaddrinfo(addr, NULL, NULL, &dest);
if (error_id) {
socket_unlock(L, 1);
error = gai_strerror(error_id);
lua_pushboolean(L, false);
lua_pushstring(L, error);
return 2;
}
if (dest == NULL) {
socket_unlock(L, 1);
lua_pushboolean(L, false);
lua_pushstring(L, "getaddrinfo returned success but no addresses");
return 2;
@ -509,6 +511,7 @@ static int l_nsock_connect(lua_State *L) {
udata->ssl_session);
break;
#else
socket_unlock(L, 1);
lua_pushboolean(L, false);
lua_pushstring(L, "Sorry, you don't have OpenSSL\n");
return 2;
@ -523,6 +526,7 @@ static int l_nsock_connect(lua_State *L) {
return lua_yield(L, 0);
error:
socket_unlock(L, 1);
freeaddrinfo(dest);
luaL_argerror(L, 4, "invalid connection method");
return 0;