commit 95d084fa6ad9dbd7d40d03d1310af1229553c71f parent d0acbabefab836b815a0d1eed24f73605e9f6381 Author: Evgeny Grin (Karlson2k) <k2k@narod.ru> Date: Sat, 8 Aug 2015 12:29:20 +0000 Small refactoring in MHD_handle_connection() for optimization Diffstat:
| M | src/microhttpd/daemon.c | | | 20 | ++++++++++---------- |
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -811,16 +811,6 @@ MHD_handle_connection (void *data) (MHD_CONNECTION_CLOSED != con->state) ) { tvp = NULL; - if (timeout > 0) - { - now = MHD_monotonic_time(); - if (now - con->last_activity > timeout) - tv.tv_sec = 0; - else - tv.tv_sec = timeout - (now - con->last_activity); - tv.tv_usec = 0; - tvp = &tv; - } #if HTTPS_SUPPORT if (MHD_YES == con->tls_read_ready) { @@ -830,6 +820,16 @@ MHD_handle_connection (void *data) tvp = &tv; } #endif + if (NULL == tvp && timeout > 0) + { + now = MHD_monotonic_time(); + if (now - con->last_activity > timeout) + tv.tv_sec = 0; + else + tv.tv_sec = timeout - (now - con->last_activity); + tv.tv_usec = 0; + tvp = &tv; + } if (0 == (con->daemon->options & MHD_USE_POLL)) { /* use select */