libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 47e648bd2667c2d2ef742154d2399b3a520a4cdf
parent b65a22107e0da3b698383720437feb0b7eeaa60e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Sun,  4 Jun 2017 13:21:39 +0300

internal_add_connection(): minor refactoring for additional error check and minor optimization

Diffstat:
Msrc/microhttpd/daemon.c | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -2357,22 +2357,24 @@ internal_add_connection (struct MHD_Daemon *daemon, struct MHD_Connection *connection; unsigned int i; int eno; - struct MHD_Daemon *worker; - if (NULL != daemon->worker_pool) + /* Direct add to master daemon could happen only with "external" add mode. */ + EXTRA_CHECK ((NULL == daemon->worker_pool) || (external_add)); + if ((external_add) && (NULL != daemon->worker_pool)) { /* have a pool, try to find a pool with capacity; we use the socket as the initial offset into the pool for load balancing */ for (i = 0; i < daemon->worker_pool_size; ++i) { - worker = &daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size]; + struct MHD_Daemon * const worker = + &daemon->worker_pool[(i + client_socket) % daemon->worker_pool_size]; if (worker->connections < worker->connection_limit) return internal_add_connection (worker, client_socket, addr, addrlen, - external_add, + true, non_blck); } /* all pools are at their connection limit, must refuse */