diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-08 12:29:20 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2015-08-08 12:29:20 +0000 |
commit | 95d084fa6ad9dbd7d40d03d1310af1229553c71f (patch) | |
tree | 71447308b85f974cef3e581d45505661a8a3e36f /src/microhttpd/daemon.c | |
parent | d0acbabefab836b815a0d1eed24f73605e9f6381 (diff) | |
download | libmicrohttpd-95d084fa6ad9dbd7d40d03d1310af1229553c71f.tar.gz libmicrohttpd-95d084fa6ad9dbd7d40d03d1310af1229553c71f.zip |
Small refactoring in MHD_handle_connection() for optimization
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 6d70bed5..b6e3f352 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -811,16 +811,6 @@ MHD_handle_connection (void *data) | |||
811 | (MHD_CONNECTION_CLOSED != con->state) ) | 811 | (MHD_CONNECTION_CLOSED != con->state) ) |
812 | { | 812 | { |
813 | tvp = NULL; | 813 | tvp = NULL; |
814 | if (timeout > 0) | ||
815 | { | ||
816 | now = MHD_monotonic_time(); | ||
817 | if (now - con->last_activity > timeout) | ||
818 | tv.tv_sec = 0; | ||
819 | else | ||
820 | tv.tv_sec = timeout - (now - con->last_activity); | ||
821 | tv.tv_usec = 0; | ||
822 | tvp = &tv; | ||
823 | } | ||
824 | #if HTTPS_SUPPORT | 814 | #if HTTPS_SUPPORT |
825 | if (MHD_YES == con->tls_read_ready) | 815 | if (MHD_YES == con->tls_read_ready) |
826 | { | 816 | { |
@@ -830,6 +820,16 @@ MHD_handle_connection (void *data) | |||
830 | tvp = &tv; | 820 | tvp = &tv; |
831 | } | 821 | } |
832 | #endif | 822 | #endif |
823 | if (NULL == tvp && timeout > 0) | ||
824 | { | ||
825 | now = MHD_monotonic_time(); | ||
826 | if (now - con->last_activity > timeout) | ||
827 | tv.tv_sec = 0; | ||
828 | else | ||
829 | tv.tv_sec = timeout - (now - con->last_activity); | ||
830 | tv.tv_usec = 0; | ||
831 | tvp = &tv; | ||
832 | } | ||
833 | if (0 == (con->daemon->options & MHD_USE_POLL)) | 833 | if (0 == (con->daemon->options & MHD_USE_POLL)) |
834 | { | 834 | { |
835 | /* use select */ | 835 | /* use select */ |