Commit Graph
1510 Commits
Author SHA1 Message Date
Christian Grothoff 00a5e29287 trying to fix #3584 2014-12-19 23:17:14 +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
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
Christian Grothoff 9e8530eea8 fix #3543 2014-09-12 15:35:01 +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 013a50dc96 -addressing #3461 2014-07-01 17:32:21 +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 cb4bd812c4 Bernd Kuhls <berndkuhls@hotmail.com> wrote:
Hi,

the latest release added

AC_CHECK_FILE([$with_gnutls/include/gnutls/gnutls.h],

to configure.ac which is not cross-compile aware, for the precise error 
message have a look at the bottom of 
http://autobuild.buildroot.net/results/cb2/cb2cec1295a40667a3c21060864dd0e65a
312c3e/build-end.log

The following patch fixes the problem

--- configure.ac       2014-05-02 20:38:40.000000000 +0200
+++ configure.ac   2014-05-04 09:17:00.000000000 +0200
@@ -639,8 +639,7 @@
         SAVE_CPPFLAGS="$CPPFLAGS"
         LDFLAGS="-L$with_gnutls/lib $LDFLAGS"
         CPPFLAGS="-I$with_gnutls/include $CPPFLAGS"
-        AC_CHECK_FILE([$with_gnutls/include/gnutls/gnutls.h],
-          [AC_CHECK_HEADERS([gnutls/gnutls.h],
+          AC_CHECK_HEADERS([gnutls/gnutls.h],
             [AC_CHECK_LIB([gnutls], [gnutls_priority_set],
               [
                 GNUTLS_CPPFLAGS="-I$with_gnutls/include"
@@ -648,7 +647,7 @@
                 GNUTLS_LIBS="-lgnutls"
                 AC_CHECK_LIB([gnutls], [gnutls_load_file], [AC_CHECK_LIB
([gnutls], [gnutls_privkey_import_x509_raw], [have_gnutls_sni=yes])])
                 have_gnutls=yes
-              ])])])
+              ])])
         AS_IF([test "x$have_gnutls" != "xyes"], [AC_MSG_ERROR([can't find 
usable libgnutls at specified prefix $with_gnutls])])
         LDFLAGS="$SAVE_LDFLAGS"
         CPPFLAGS="$SAVE_CPPFLAGS"

Regards, Bernd
2014-05-04 09:06:27 +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 312d11ec19 fix #3392 as suggested by reporter 2014-05-02 18:23:58 +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 c34947db86 -correct documentation 2014-04-14 17:55:32 +00:00
Christian Grothoff 2964021746 -fix warning 2014-04-10 07:49:43 +00:00