Commit Graph
1203 Commits
Author SHA1 Message Date
Christian Grothoff d5571974e5 fix #3560 as suggested by reporter 2014-12-01 10:55:44 +00:00
Christian Grothoff 774e50c035 Hi Christian,
the recently added MHD_DAEMON_INFO_CURRENT_CONNECTIONS can return quite
outdated values in MHD_USE_THREAD_PER_CONNECTION mode. The reason is
that closed connections are collected in MHD_cleanup_connections, which
is called only from the select thread. In the
MHD_USE_THREAD_PER_CONNECTION mode that happens only after accepting an
connection -- therefore, the last connection is always not collected and
MHD_DAEMON_INFO_CURRENT_CONNECTIONS returns >= 1, even when there are no
connections. That makes it very unusable to detect whether all
connections have been handled.

Would you consider the attached patch, which calls
MHD_cleanup_connections whenever MHD_DAEMON_INFO_CURRENT_CONNECTIONS is
called? It makes MHD_DAEMON_INFO_CURRENT_CONNECTIONS slower, but the
returned value is much more accurate.

Cheers,
Milan Straka
2014-11-18 12:54:01 +00:00
Christian Grothoff b6db4c24d4 -bump 2014-10-29 19:54:14 +00:00
Christian Grothoff fd94723863 Hi Christian,
I attach the first attempt on SO_REUSEPORT. The patch is available
either at https://github.com/foxik/libmicrohttpd/commit/9ce9422742e10458f87275ea202a982e00c2b88c
or attached. (It is against the version with
MHD_DAEMON_OPTION_CURRENT_CONNECTIONS, but I can rebase it to current
SVN HEAD if you want.)

It seems that a reasonably multiplatform way of detecting SO_REUSEPORT is
  #ifdef SO_REPOSEPORT
which is used for example by Perl. For SO_EXCLUSIVEADDRUSE, the same
strategy seems to work too, according to Windows SDK headers and MinGW
WinAPI headers.

The current patch adds an option to allowing/disallowing address:port
reuse. One remark:
- currently both nonexisting SO_xxx and setsockopt failure are fatal and
  MHD_start_daemon fails. That may be too harsh -- maybe the
  MHD_OPTION_LISTENING_ADDRESS_REUSE should be only a hint.

  Nevertheless, as one can freely not use
  MHD_OPTION_LISTENING_ADDRESS_REUSE option, I chose the "fail on error"
  behaviour.

Thanks,
cheers,
Milan Straka

Original patch modified to get rid of some redundant USE_DEBUG
checks, fix indentation, and #ifndef SO_REUSEPORT on Linux,
we try be #defining it to 15 ourselves.
2014-10-29 19:50:58 +00:00
Christian Grothoff cde3691e85 handle bogus return value from send() call 2014-10-29 15:53:17 +00:00
Christian Grothoff 5c51824265 make sure we always set non-zero errno in send_tls_adapter 2014-10-29 15:46:17 +00:00
Christian Grothoff 19d66bd8c1 -no comma at end of enum 2014-10-29 15:32:10 +00:00
Christian Grothoff d50980a765 From: Milan Straka <fox@ucw.cz>
Date: Wed, 29 Oct 2014 09:59:09 +0100
Subject: [PATCH 2/2] Add MHD_DAEMON_INFO_CURRENT_CONNECTIONS to
 MHD_DaemonInfoType.

The MHD_DAEMON_INFO_CURRENT_CONNECTIONS returns number of current
connections handled by the daemon.

Useful after MHD_quiesce_daemon to find out whether all connections
have been served.
2014-10-29 15:29:31 +00:00
Christian Grothoff e38d4e283e minor code clean up via CSE 2014-10-29 15:22:14 +00:00
Christian Grothoff 8ed7052d5e From: Milan Straka <fox@ucw.cz>
Date: Wed, 29 Oct 2014 09:17:42 +0100
Subject: [PATCH 1/2] Split daemon->max_connections to connections and
 connection_limit.

In order to be able to return number of parallel connections, we need
to now both the actual number and the limit. Nevertheless, until now only
  max_connections = connection_limit - connections
was kept. We now store both the connection_limit and connections.
2014-10-29 15:20:25 +00:00
Christian Grothoff 4d1fd8c61d Milan is right.
>> Nevertheless, this means that there is an unhandled special case.
>> Consider MHD_USE_THREAD_PER_CONNECTION (either with or without
>> MHD_USE_POLL). Then wpipe is not created. After MHD_quiesce_daemon,
>> socket_fd = -1. Then, after the current select/poll in the
>> MHD_select_thread exits, there will be no fds to wait for (the socket_fd
>> is -1 and wpipe was not created), so the MHD_select_thread will be
>> busy-waiting for daemon->shutdown. Therefore, another condition should
>> be added to the beginning of MHD_quiesce_daemon:
>> current:
>>
>>   MHD_quiesce_daemon (struct MHD_Daemon *daemon)
>>   {                                                                                                                                                                                        
>>     unsigned int i;                                                                                                                                                                        
>>     int ret;                                                                                                                                                                               
>>                                                                                                                                                                                            
>>     ret = daemon->socket_fd;                                                                                                                                                               
>>     if (-1 == ret)                                                                                                                                                                         
>>       return -1;                                                                                                                                                                           
>>     if ( (-1 == daemon->wpipe[1]) &&                                                                                                                                                       
>>          (0 != (daemon->options & MHD_USE_SELECT_INTERNALLY)) )                                                                                                                            
>>     {                                                                                                                                                                                      
>> #if HAVE_MESSAGES                                                                                                                                                                          
>>       MHD_DLOG (daemon,                                                                                                                                                                    
>>                 "Using MHD_quiesce_daemon in this mode requires MHD_USE_PIPE_FOR_SHUTDOWN\n");                                                                                             
>> #endif                                                                                                                                                                                     
>>       return -1;
>>     }
>>
>> new:
>>
>>     if ( (-1 == daemon->wpipe[1]) &&
>>          (0 != (daemon->options & (MHD_USE_SELECT_INTERNALLY | MHD_USE_THREAD_PER_CONNECTION )) ))
>>
>> Did I get it right?
>
> I don't think so.  Note that the 'socket_fd' in the thread's
> select()/poll() call is not the (closed) listen socket, but the thread's
> TCP connection to the client.  So the thread can still be terminated by
> calling shutdown() on that TCP connection socket.
> (The code is a bit confusing here, as both structs have a member called
> 'socket_fd').

(I am sorry I cannot make myself clear enough.)

I still think what I wrote holds. I am talking about the thread
executing MHD_select_thread, i.e., the one created in MHD_start_daemon_va.
It gets the daemon structure as parameter and accesses daemon->socket_fd.
I believe you are talking about threads executing MHD_handle_connection,
created in internal_add_connection.

The problem is that the listening thread might run out of FDs to wait
for. In the MHD_USE_THREAD_PER_CONNECTION case, the main listening
thread only selects/polls on two FDs -- daemon->socket_fd, and
daemon->wpipe[0]. And when daemon->socket_fd is closed and
daemon->wpipe[0] does not exist, problem occurs.

The same issue could happen when there is a thread_pool, but that is
taken care of in MHD_quiesce_daemon -- in this case, if there is no
wpipe, MHD_quiesce_daemon fails. What I am suggesting that this test
should also include the MHD_USE_THREAD_PER_CONNECTION case.

Cheers,
Milan Straka
2014-10-28 08:55:50 +00:00
Christian Grothoff 5ad10328b3 -doxygen fix 2014-10-27 20:35:53 +00:00
Christian Grothoff 67d953de64 -preping for release 0.9.38 2014-10-03 12:40:39 +00:00
Christian Grothoff 2b47dfd735 -bump 2014-09-29 20:36:31 +00:00
Christian Grothoff ee47d16366 fix '+' unescape logic for URI-encoded POST data 2014-09-29 20:35:58 +00:00
David Barksdale 4327f75e67 Do not move a connection between timeout lists if it is suspended
When a connection is suspended it is not in a timeout list.
2014-08-17 14:17:43 +00:00
Sree Harsha Totakura c94103be0f Mention the timeout as milliseconds. 2014-08-05 13:17:57 +00:00
Christian Grothoff d8a567a469 code cleanup, expand assertions 2014-07-12 18:57:56 +00:00
Christian Grothoff 2118763c48 -typo 2014-07-08 14:28:49 +00:00
Christian Grothoff ed9dfcdad4 fix failure to terminate quickly in thread-per-connection mode if clients have open connections 2014-06-26 19:07:19 +00:00
Christian Grothoff 280d6c473f -do not be so picky about except set, we do not use it anyway 2014-06-23 21:22:44 +00:00
Christian Grothoff 44467484f7 better fix for the concurrent response modification issue: do not modify response to add extra headers, only add them into the connection output buffer 2014-06-22 10:25:46 +00:00
Christian Grothoff 86cbb04673 lock when modifying response object to add missing headers 2014-06-21 22:22:55 +00:00
Christian Grothoff 95f6ae86c1 -spell Keep-Alive consistently 2014-06-20 13:28:29 +00:00
Christian Grothoff 69cacd7e02 -fix lack of adding listen FD to epoll set for external select before first call to MHD_run (see mailinglist) 2014-06-19 15:35:25 +00:00
Christian Grothoff 5209abc676 -add missing extern 2014-06-10 22:32:30 +00:00
Christian Grothoff ea8bac4745 adding MHD_set_response_options function 2014-06-08 13:11:50 +00:00
Christian Grothoff 1f4a53507e fix #3413 2014-06-01 22:08:47 +00:00
Christian Grothoff fd764222b8 -version bump 2014-05-28 13:49:18 +00:00
Christian Grothoff d71165ed3a second attempt to properly commit patch for #3392 2014-05-28 13:48:57 +00:00
Christian Grothoff 07e0a5ea0a releasing 0.9.36 2014-05-25 18:20:18 +00:00
Evgeny Grin (Karlson2k) 56b7b801ec W32: fix building with --disable-static 2014-05-25 15:46:28 +00:00
Christian Grothoff 14a0065869 never notify twice 2014-05-17 04:47:33 +00:00
Christian Grothoff 51da5739fe -fix #3397 2014-05-13 16:26:49 +00:00
David Barksdale bc0dcd4cbb Add test for empty entity. 2014-05-06 15:07:52 +00:00
Christian Grothoff 7231b7f830 fix #3391 2014-05-02 18:43:17 +00:00
Christian Grothoff 1bd97426ba fix rare epoll/resume issue, also simplifying logic 2014-05-02 18:37:35 +00:00
Christian Grothoff c94a82388f improve documentation for key-value iterator 2014-04-24 19:41:30 +00:00
Evgeny Grin (Karlson2k) f1f821746b W32: remove dependency on libgcc dll with latest GCC 2014-04-15 14:41:01 +00:00
Christian Grothoff 2964021746 -fix warning 2014-04-10 07:49:43 +00:00
Christian Grothoff 17b849eb47 -eliminate warnings 2014-04-10 07:46:35 +00:00
Christian Grothoff 14ca1719e9 fix #3371 2014-04-10 07:43:05 +00:00
Evgeny Grin (Karlson2k) 2bffe00f07 Added ability to use native W32 threads, added --with-threads=LIB configure parameter 2014-04-08 14:46:06 +00:00
Evgeny Grin (Karlson2k) 1c5f53ac93 Simplify pthread_join() calls 2014-04-08 09:07:48 +00:00
Evgeny Grin (Karlson2k) 5cab359556 Fixed MHD base tests with non-default path to GnuTLS includes, removed duplicated include 2014-04-07 21:50:20 +00:00
Evgeny Grin (Karlson2k) 5fe37b899b Fix curl HTTPS test with GnuTLS specific version 2014-04-07 20:50:28 +00:00
Evgeny Grin (Karlson2k) c196047666 Updated doxygen for MHD_FEATURE with new option name, fixed check of initialisaion of ligcrypt < 1.6.0 2014-04-07 20:26:20 +00:00
Christian Grothoff ca3a7d621c add MHD_OPTION_HTTPS_MEM_DHPARAMS to support PFS 2014-04-07 11:27:18 +00:00
Evgeny Grin (Karlson2k) 8172eecea0 Check result of initialisaion of libgcrypt, runtime check for required libgcrypt version 2014-04-04 17:02:43 +00:00
Evgeny Grin (Karlson2k) 30da663666 W32: use critical section instead of waitable object as MHD require synchronization only within one process 2014-04-04 11:19:41 +00:00