libmicrohttpd
[Top][All Lists]
Advanced

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

Re: [libmicrohttpd] How to close all upgraded connections when shutting


From: Evgeny Grin
Subject: Re: [libmicrohttpd] How to close all upgraded connections when shutting down MHD_Daemon?
Date: Thu, 4 May 2017 16:23:04 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

>> MHD_stop_daemon() will close all connections including "upgraded"
>> connections. So you can't use "upgraded" connections after
>> MHD_stop_daemon().
>>
> The problem I have is that MHD_stop_daemon() doesn't close all the
> connections. Instead, it looks like it waits for the active connections
> to close by themselves and I have the following log message:
> Initiated daemon shutdown while "upgraded" connection was not closed.
> 

Do you use HTTP or HTTPS?
You must not call MHD_stop_daemon() while you still have some not closed
"upgraded" connections.
May be we should add more alarming message in case of such API violation.

>> Could you explain a bit more situation that you need to solve?
>> Do you want to implement graceful MHD shutdown after closing all
>> upgraded connections?
>>
> I guess what I'd rather have is for the upgraded connections to be
> closed by MHD when MHD_stop_daemon() is called, so the upgrade callback
> could interpret it easily.
> Silvio's suggestion might work too, some signal like a
> "MHD_DAEMON_INFO_WAS_QUIESCED" or, in my case
> "MHD_DAEMON_INFO_WAS_STOPPED".
> 
> My current implementation is the following.
> When a websocket upgrade is called by the client, the websocket callback
> is executed:
> https://github.com/babelouest/ulfius/blob/2.0/src/ulfius.c#L432
> Then the program loops on listening to the socket
> https://github.com/babelouest/ulfius/blob/2.0/src/u_websocket.c#L115
> 
> But in my example program, when the user stops the program by pressing
> the <enter> key while connections are active, the program doesn't stop
> and waits for the open websockets to close.
> https://github.com/babelouest/ulfius/blob/2.0/example_programs/websocket_example/websocket_example.c

Could you provide a minimal example?

-- 
Wishes,
Evgeny



reply via email to

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