Commit Graph
1240 Commits
Author SHA1 Message Date
Evgeny Grin (Karlson2k) cfec37c1c3 fix autoinit_funcs.h reference in makefile EXTRA_DIST 2014-12-24 20:50:40 +00:00
Evgeny Grin (Karlson2k) f1ffd2e889 [w32] Set thread name 2014-12-24 19:00:33 +00:00
Evgeny Grin (Karlson2k) 7c2493d59c One more strcasecmp() replace with macro 2014-12-24 19:00:23 +00:00
Christian Grothoff 0016974ba8 -fix dist issue 2014-12-24 15:03:58 +00:00
Evgeny Grin (Karlson2k) 9303922d47 Add and use header for multiplatform support of Init/Deinit functions 2014-12-22 19:43:04 +00:00
Evgeny Grin (Karlson2k) 5a85e40649 [w32] Help code to detect IPPROTO_IPV6 on VC 2014-12-22 19:42:50 +00:00
Evgeny Grin (Karlson2k) 2ee782685c MHD_get_version: support extraction version number from MHD_VERSION if PACKAGE_VERSION is not defined 2014-12-22 19:42:44 +00:00
Evgeny Grin (Karlson2k) 49d17ea85e Rework _MHD_EXTERN definition for VS project 2014-12-22 19:42:38 +00:00
Evgeny Grin (Karlson2k) 001c1fdad5 Replace char variable size arrays with malloc'ed buffers 2014-12-22 19:42:31 +00:00
Evgeny Grin (Karlson2k) 03af50116d response.c: include additional header for W32 2014-12-22 19:42:24 +00:00
Evgeny Grin (Karlson2k) 54edb3cd8f Replace snprintf with platform-independent macro 2014-12-22 19:42:18 +00:00
Evgeny Grin (Karlson2k) 913ced4bdd [w32] Add W32 emulation for snprintf() 2014-12-22 19:42:08 +00:00
Evgeny Grin (Karlson2k) 2a2a389a34 Replace strcasecmp/strncasecmp with platform-independent macros 2014-12-22 19:42:00 +00:00
Evgeny Grin (Karlson2k) ba88f0d733 daemon.c: Fix macro check with HAVE_ACCEPT4 == 0 in MHD_accept_connection() 2014-12-22 19:41:51 +00:00
Evgeny Grin (Karlson2k) 4d264fe823 platform.h: conditionally include unistd.h
Was already supported by configure
2014-12-22 19:41:45 +00:00
Evgeny Grin (Karlson2k) 7d18a1a3ed platform.h: define ssize_t for MSVC compiler 2014-12-22 19:41:39 +00:00
Evgeny Grin (Karlson2k) 76311f9249 tsearch.c/.h: support compiling by MSVC 2014-12-22 19:41:33 +00:00
Evgeny Grin (Karlson2k) 7f534d0df7 daemon.c: update ifdefs to support non-MinGW w32 native build 2014-12-22 19:41:26 +00:00
Christian Grothoff bdc0a8d958 getting ready for 0.9.39 2014-12-22 15:41:45 +00:00
Christian Grothoff bbe7aa94e0 -just to be sure, also check if client set Connection: close at the end 2014-12-20 01:31:24 +00:00
Christian Grothoff 0a930d349c -avoid cmp with uninitialized pointer, even if harmless 2014-12-20 01:01:14 +00:00
Christian Grothoff 599ccf8fb5 -check malloc rval 2014-12-20 00:55:21 +00:00
Christian Grothoff eb31c3c9ba -check malloc rval 2014-12-20 00:54:51 +00:00
Christian Grothoff 51e9b51e26 -check fgetc rval even if feof said it wouldn't be EOF 2014-12-20 00:40:16 +00:00
Christian Grothoff ce0e99c545 -handle NULL vlaue 2014-12-20 00:37:06 +00:00
Christian Grothoff 6c80b16d18 -check malloc() return value 2014-12-20 00:36:00 +00:00
Christian Grothoff a29e7f538c -fix (potential) memory leak on certain control flow paths 2014-12-20 00:35:01 +00:00
Christian Grothoff 6bb3128a41 -cleaner code: avoid trivial fall-through case, make it explicit instead 2014-12-20 00:31:51 +00:00
Christian Grothoff 8c24a9bd24 -check RVals 2014-12-20 00:30:53 +00:00
Christian Grothoff a4030d4473 -check RVals 2014-12-20 00:25:22 +00:00
Christian Grothoff b457435a88 use __buildin_unreachable() after MHD_PANIC() -- if supported by gcc 2014-12-20 00:18:06 +00:00
Christian Grothoff 18b1972b40 -fix linker issue 2014-12-19 23:42:32 +00:00
Christian Grothoff b2a041e934 make MHD_http_unescape() part of API (#3585) 2014-12-19 23:38:18 +00:00
Evgeny Grin (Karlson2k) 16e9746859 fix building with --disable-messages 2014-12-18 21:39:33 +00:00
Christian Grothoff 9407787c06 writing down my current thoughts on the WebSocket API 2014-12-14 14:00:14 +00:00
Christian Grothoff def7c593ea -clarify comment 2014-12-08 13:49:07 +00:00
Christian Grothoff 6ee22efc8b From:
"Junker, Gregory" <gregory.junker@intel.com>
Date:
12/04/2014 12:30 AM
To:
"libmicrohttpd@gnu.org" <libmicrohttpd@gnu.org>

Hi all

I need a tiny addition made to connection.c.

In keepalive_possible(), can we change the line that says

    if (0 == strcasecmp (end, "close"))

to



    if (0 == strcasecmp (end, "close") || 0 == strcasecmp (end, "upgrade"))

?

This would make it possible to use libmicrohttpd in a WebSocket (RFC6455) environment. Currently, the way that the WebSocket protocol works, it sends "Connection: Upgrade" in the headers with the initial handshake, which causes this check to fail and (ultimately) insert "Connection: Keep-Alive" in the response headers (which cause any compliant WebSocket client to fail the handshake, since it needs "Connection: Upgrade" in the response headers, and there is no way to remove this keepalive header from the response from outside of MHD, as it is added automatically to the response buffer).

Note that this is only an HTTP/1.1 issue, AFAIK (I am pretty sure, though not positive, that WebSocket is not compatible with HTTP/1.0).

Thanks!
Greg
2014-12-03 23:47:40 +00:00
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