On 15 March 2017 at 20:17, Evgeny Grin <k...@yandex.ru> wrote: > If you resume connection - it timeout timer will be restarted. So, right > after resume connection should not timeout. > [...] > Sorry, still unclear for me, why do you need custom timeout connected > with suspend/resume. And what is not working.
My current application logic is as described below: 0. We are inside DH, current connection is #0 (active uploader) and there is second connection #1 1. DH #0 calls MHD_suspend_connection( #1 ) 2. After #0 finished a work, DH #0 or Completed callback #0 calls MHD_resume_connection( #1 ) 3. You are thinking that MHD_resume_connection() will reset a timer. But this is wrong, see below. src/microhttpd/connection.c 2732 int 2733 MHD_connection_handle_idle (struct MHD_Connection *connection) 2734 { ... 3218 timeout = connection->connection_timeout; 3219 if ( (0 != timeout) && 3220 (timeout <= (MHD_monotonic_sec_counter() - connection->last_activity)) ) 3221 { 3222 MHD_connection_close_ (connection, 3223 MHD_REQUEST_TERMINATED_TIMEOUT_REACHED); 3224 connection->in_idle = false; 3225 return MHD_YES; 3226 } 3227 MHD_connection_update_event_loop_info (connection); 3228 #ifdef EPOLL_SUPPORT 3229 if (0 != (daemon->options & MHD_USE_EPOLL)) 3230 return MHD_connection_epoll_update_ (connection); 3231 #endif /* EPOLL_SUPPORT */ 3232 return MHD_YES; 3233 } In my case the problem is on line 3220, more exactly this is a cause of the problem: timeout <= (MHD_monotonic_sec_counter() - connection->last_activity A difference between git and 0.9.51, 0.9.52: 1. git version calls MHD_RequestCompletedCallback with MHD_REQUEST_TERMINATED_TIMEOUT_REACHED (and it is cool). 2. non-git versions don't do this, instead they send INTERNAL_ERROR silently & immediately (don't know why). I hope now it is clear. > Why not to limit number of connection to 1 by > MHD_OPTION_CONNECTION_LIMIT? Then you will process single connection > only at any time. > To force close connection after response, add "Connection: close" header. Because there are also clients with GET requests, the server must send responses to them. Let's say, the server is working in some kind of a stupid database mode: it provides read access to anyone and there is must be only one writer. > Patches are always welcome. If you improve MHD functionality and don't > break anything - we will merge it. I sent the patch already: http://lists.gnu.org/archive/html/libmicrohttpd/2017-03/msg00031.html There is typo in both notes (.h & .c): s/setting/getting/. Sorry, I missed it. -- With Best Regards, Vitaliy V. Tokarev