libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Hanging connections


From: Kenneth Mastro
Subject: Re: [libmicrohttpd] Hanging connections
Date: Tue, 3 Nov 2015 17:33:50 -0500

Hmm.  I don't know what the defaults are for 'thread per connection' mode.  I use that mode and everything is fine, so unless it's a new bug... I kind of suspect there might be no defaults and you have to specify the parameters.  That is, you may need to tell MHD how many threads to create/maintain/allow.  Otherwise, I don't see anything wrong with your 'start_daemon' call.  That 'connectionCallback' function of yours really should be called.

I know the 'use select internally' mode is working for you, but if you'd like to try to continue using 'thread per connection', you could try adding something like the following to your 'start_daemon' call:

MHD_OPTION_CONNECTION_LIMIT,   // specifies that the next arg is the max number of simultaneous connections
(unsigned int)10,             // the number of permitted simultaneous connections
MHD_OPTION_CONNECTION_TIMEOUT, // specifies that the next arg is how long any given connection can live
(unsigned int)60,              // the number of seconds connections are allowed to live (0 would allow them to live indefinitely)


If you don't have any long-lived requests, 'use select internally' is likely a good choice anyway.  You just have to be mindful that you can't service multiple requests simultaneously (unless you use the suspend/resume functionality and/or a thread pool).


Regarding the static method in the C++ class - I suspect you're right.  That should work.  Personally, I'm having it call a C function that has been 'externed' (to avoid any chance of function name mangling) and then have that call back into my C++ class.  One way or the other, I need access to persistent data in my class, so a static method versus a C function aren't really all that different.


Ken

PS: Christian's the real hero on the mailing list (and for MHD, obviously).  I've been using MHD for about a year and a half now, and in that time he's always been very responsive to people's questions.  It's amazing how much that helps an open source project.


On Tue, Nov 3, 2015 at 5:02 PM, Phil Rosenberg <address@hidden> wrote:
Hi Ken
Thanks for the advice. As you say, my callback is not being called AT
ALL. Here is my start call

m_daemon = MHD_start_daemon(
MHD_USE_THREAD_PER_CONNECTION,
port,
NULL,
NULL,
&HttpDaemon::connectionCallback,
this,
MHD_OPTION_NOTIFY_COMPLETED, &HttpDaemon::completeCallback, NULL,
//variables which allow post to be processed
MHD_OPTION_END);

Since posting I have tried MHD_USE_SELECT_INTERNALLY and this seems to
be working fine. Processing each request is very fast so the multi
threading I guess isn't needed.
You may notice above that my callback is actually a static method of a
C++ class, but as a static method is equivalent to a regular function
I don't believe this is a problem and it has never been a problem for
other libraries where I have used callbacks (e.g. libCURL).

I had the same isuue with GET too.

I had seen the info about being called twice and (at least I believe )
I am dealing with that.

I will have a look at firebug and try to work things out from that end
when I get a chance and I will see if I can create a minimal sample
too.

Thanks for all the ideas. It's always great to find what seems like a
keen and active group at the other end of an email list. Now that I am
running with select internally MHD seems perfect for my needs.

Phil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]