diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 2cfef944..7adf57f7 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -1136,21 +1136,25 @@ internal_add_connection (struct MHD_Daemon *daemon, | |||
1136 | int res_thread_create; | 1136 | int res_thread_create; |
1137 | unsigned int i; | 1137 | unsigned int i; |
1138 | int eno; | 1138 | int eno; |
1139 | struct MHD_Daemon *worker; | ||
1139 | #if OSX | 1140 | #if OSX |
1140 | static int on = 1; | 1141 | static int on = 1; |
1141 | #endif | 1142 | #endif |
1143 | |||
1142 | if (NULL != daemon->worker_pool) | 1144 | if (NULL != daemon->worker_pool) |
1143 | { | 1145 | { |
1144 | /* have a pool, try to find a pool with capacity; we use the | 1146 | /* have a pool, try to find a pool with capacity; we use the |
1145 | socket as the initial offset into the pool for load | 1147 | socket as the initial offset into the pool for load |
1146 | balancing */ | 1148 | balancing */ |
1147 | for (i=0;i<daemon->worker_pool_size;i++) | 1149 | for (i=0;i<daemon->worker_pool_size;i++) |
1148 | if (daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size].connections < | 1150 | { |
1149 | daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size].connection_limit) | 1151 | worker = &daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size]; |
1150 | return internal_add_connection (&daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size], | 1152 | if (worker->connections < worker->connection_limit) |
1151 | client_socket, | 1153 | return internal_add_connection (worker, |
1152 | addr, addrlen, | 1154 | client_socket, |
1153 | external_add); | 1155 | addr, addrlen, |
1156 | external_add); | ||
1157 | } | ||
1154 | /* all pools are at their connection limit, must refuse */ | 1158 | /* all pools are at their connection limit, must refuse */ |
1155 | if (0 != MHD_socket_close_ (client_socket)) | 1159 | if (0 != MHD_socket_close_ (client_socket)) |
1156 | MHD_PANIC ("close failed\n"); | 1160 | MHD_PANIC ("close failed\n"); |