From 543af4c57df6293be7796e1d2ed9168efef782b9 Mon Sep 17 00:00:00 2001 From: batrick Date: Tue, 14 Jul 2009 05:19:47 +0000 Subject: [PATCH] Increased the default parallelism for NSE to 40. This patch is the result of testing to determine an ideal default value. A post on nmap-dev will soon follow further describing the results and motivation. --- nse_nsock.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nse_nsock.cc b/nse_nsock.cc index eae996ad8..b91c428aa 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -259,7 +259,7 @@ static void set_thread (lua_State *L, int index, struct l_nsock_udata *n) * CONNECT_WAITING is a weak keyed table of pairs. * The table contains threads waiting to make a socket connection. */ -#define MAX_PARALLELISM 10 +#define MAX_PARALLELISM 40 #define THREAD_SOCKETS 1 /* */ #define CONNECT_WAITING 2 /* Threads waiting to lock */ @@ -273,6 +273,7 @@ static void set_thread (lua_State *L, int index, struct l_nsock_udata *n) */ static int socket_lock(lua_State * L) { + int p = o.max_parallelism == 0 ? MAX_PARALLELISM : o.max_parallelism; lua_settop(L, 1); lua_rawgeti(L, LUA_ENVIRONINDEX, THREAD_SOCKETS); nse_base(L); @@ -284,7 +285,7 @@ static int socket_lock(lua_State * L) lua_pushvalue(L, 1); lua_pushboolean(L, true); lua_rawset(L, -3); - } else if (table_length(L, 2) <= MAX(MAX_PARALLELISM, o.max_parallelism)) + } else if (table_length(L, 2) <= p) { /* There is room for this thread to open sockets */ nse_base(L);