Hi Olivier,

Thanks for the report, I've done a visual inspection of the code based
on your report, and I think I've found the issue.  Please try it by
using SVN 36568 or the attached diff, and let me know if this fixes the
problem (as I didn't reproduce it myself).

(If I'm right, it only occurs if your client sends the next request
before having received the fully response, and it arrives faster at the
server than the server can process the previous response, and does so
continuously, resulting in a shrinking buffer (which may cause the
server to be again slower, further increasing the speed-advantage of the
client. And it's limited to the duration of one TCP connection, so one
needs to massively pipeline POSTs to trigger it, which explains nicely
why only you noticed...).

Happy hacking!

Christian

On 10/24/2015 10:54 PM, Olivier Delhomme wrote:
> Hi to everyone,
> 
> I'm new to libmicrohttpd and found something related to the
> calls of MHD_AccessHandlerCallback function that I can not
> explain.
> 
> I'm calling libmicrohttpd this way:
> 
> MHD_start_daemon(MHD_USE_THREAD_PER_CONNECTION | MHD_USE_DEBUG, 
> serveur_struct->opt->port, NULL, NULL, &ahc, serveur_struct, 
> MHD_OPTION_CONNECTION_MEMORY_LIMIT, (size_t) 131070 , 
> MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 120, MHD_OPTION_END);
> 
> 'ahc' function is the MHD_AccessHandlerCallback function.
> 
> I implemented only GET and POST commands. I'm using
> POST to send json data (no field at all) from a client 
> (libcurl). The connection is kept by libcurl and reused
> to make a lot of POST commands.
> 
> Everything just works fine. Except that over time the
> parameter 'upload_data_size' of MHD_AccessHandlerCallback
> function is getting smaller and smaller. For instance
> it can be as big as 16332 bytes at the beginning and 
> be as small as 1700 bytes 10 minutes later (I never saw
> it growing again). I do not understand this. 
> 
> Can someone explain it ? 
> 
> How do I tell libmicrohttpd not to lower this parameter ?
> 
> Thanks for any insights. 
> 
> Regards, Olivier.
> 
> The project is: https://github.com/dupgit/sauvegarde
> Use of libmicrohttpd is in this file (MHD_start_daemon
> at line 835):
> https://github.com/dupgit/sauvegarde/blob/master/serveur/serveur.c
> 
> 

Index: src/microhttpd/connection.c
===================================================================
--- src/microhttpd/connection.c	(revision 36565)
+++ src/microhttpd/connection.c	(working copy)
@@ -2555,7 +2555,7 @@
               connection->read_buffer
                 = MHD_pool_reset (connection->pool,
                                   connection->read_buffer,
-                                  connection->read_buffer_size);
+                                  connection->read_buffer_offset);
             }
 	  connection->client_aware = MHD_NO;
           connection->client_context = NULL;

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to