Re: [libmicrohttpd] TCP connection callbacks - problem

2018-10-30 Thread Daniel Bujnik
Hi Christian,

Many thanks for prompt action. I can confirm now, that your fix with recent
change is working and TCP callbacks are being delivered as expected.

Kind regards,
Daniel




On Mon, 29 Oct 2018 at 19:38, Christian Grothoff 
wrote:

> Hi Daniel,
>
> I did some more testing, and my previous patch required on manually
> setting MHD_USE_ITC. I've now changed the code to automatically set this
> option in your situation, so please try 47281241..777d5e04
>
> Happy hacking!
>
> Christian
>
> On 10/26/18 2:21 PM, Daniel Bujnik wrote:
> > Hi Christian,
> >
> > I have just had a chance to test your change. Unfortunately I have to
> > say that it does not make any difference and closing notification is
> > still NOT  being triggered on TCP connection closure. I have tested with
> > current master.
> > Please let me know if you have any other idea on how to fix it.
> >
> > Kind regards,
> > Daniel
> >
> >
> > On Sat, 20 Oct 2018 at 11:46, Christian Grothoff  > > wrote:
> >
> > Dear Daniel,
> >
> > You didn't mention which thread mode you were using, but manual
> > inspection suggests your issue should occur in thread-per-connection
> > modes (only).  In that case, I've pushed a (likely) fix in
> > b55cd46b..47281241 to Git master.
> >
> > Please test and report back!
> >
> > Happy hacking!
> >
> > Christian
> >
> > On 10/19/2018 03:53 PM, Daniel Bujnik wrote:
> > > Hello,
> > >
> > > I am using libmicrohttpd with MHD_OPTION_NOTIFY_CONNECTION
> > parameter to
> > > receive notifications for TCP connection opening/closing.
> > Notifications
> > > for opening case are coming through as expected, however I am
> > > experiencing problems with closing case, where I am NOT getting the
> > > callback when my client terminates, though I can see client FIN
> packet
> > > in tcpdump on the server side and connection stops appearing in
> > netstat.
> > >
> > > Eventually the closing notification is being delivered by
> > libmicrohttpd
> > > but that is just after a new TCP connection is opened. The
> sequence of
> > > callbacks I am seeing is as followed:
> > >
> > > 1) callback with MHD_CONNECTION_NOTIFY_STARTED - TCP connection  A
> > opened
> > > 2) callback with MHD_CONNECTION_NOTIFY_STARTED - new TCP
> > connection B is
> > > opened
> > > 3)  callback with MHD_CONNECTION_NOTIFY_CLOSED - TCP connection  A
> > closed
> > >
> > > Of course I would expect nr 3 to come before nr 2. I am using nc to
> > > open/close sockets on client end.
> > >
> > > I would appreciate any comments on the described issue. Is that
> > behavior
> > > correct? If not is there a way to make it right?
> > >
> > > Kind regards,
> > > Daniel
> > >
> >
>
>


[libmicrohttpd] MHD_add_connection and EPOLL

2018-10-30 Thread José Bollo
Hi,

I try to add the selection of the interfaces to serve on MHD. I was
using MHD_USE_EPOLL and was managing to include the epoll in the
external main loop with MHD_get_daemon_info(daemon,
MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY) -> listen_fd

But it appears that setting MHD_USE_EPOLL and MHD_USE_NO_LISTEN_SOCKET
together is unsupported. So it doesn't work. listen_fd is -1 always.

I think that my expectation is valuable. Do you agree?

Best regards
José Bollo



Re: [libmicrohttpd] MHD_add_connection and EPOLL

2018-10-30 Thread José Bollo
On Tue, 30 Oct 2018 15:51:19 +0100
José Bollo  wrote:

> Hi,
> 
> I try to add the selection of the interfaces to serve on MHD. I was
> using MHD_USE_EPOLL and was managing to include the epoll in the
> external main loop with MHD_get_daemon_info(daemon,
> MHD_DAEMON_INFO_EPOLL_FD_LINUX_ONLY) -> listen_fd

hum! ->epoll_fd is much better no?

> But it appears that setting MHD_USE_EPOLL and MHD_USE_NO_LISTEN_SOCKET
> together is unsupported. So it doesn't work. listen_fd is -1 always.
> 
> I think that my expectation is valuable. Do you agree?
> 
> Best regards
> José Bollo

The patch below seems okay:


diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c
index cd2ca189..b877e560 100644
--- a/src/microhttpd/daemon.c
+++ b/src/microhttpd/daemon.c
@@ -5990,8 +5990,7 @@ MHD_start_daemon_va (unsigned int flags,
 
 #ifdef EPOLL_SUPPORT
   if ( (0 != (*pflags & MHD_USE_EPOLL)) &&
-   (0 == daemon->worker_pool_size) &&
-   (0 == (*pflags & MHD_USE_NO_LISTEN_SOCKET)) )
+   (0 == daemon->worker_pool_size) )
 {
   if (0 != (*pflags & MHD_USE_THREAD_PER_CONNECTION))
{



Re: [libmicrohttpd] Web Socket disconnect behaviour

2018-10-30 Thread silvioprog
José, thanks a lot for sharing.

This example is awesome! I'm not expert in WS but it seems this example can
run without any external dependencies. I'll test it this weekend.

Since this code is small and clear, what do you think about to make it as a
official MHD WS example in the examples folder? :-) It would be useful and
a bootstrap for who wants to start in web sockets + MHD.

Thank you for sharing!

On Thu, Oct 11, 2018 at 4:22 AM José Bollo  wrote:

> On Mon, 8 Oct 2018 23:41:02 -0300
> silvioprog  wrote:
>
> > Hi dudes.
> >
> > @Christian, just for curiosity, is there any document or example
> > showing MHD + WS? I can't provide it since I'm not familiar with WS,
> > but it would be nice if someone could provide one for us. 😅
> >
>
> Hello Sylvio,
>
> I'm using LMHD for websocket-ing. I point you a central file that may
> help (or not -hope to not confuse you-).
>
>
> https://git.automotivelinux.org/src/app-framework-binder/tree/src/afb-websock.c
>
> Best regards
> José Bollo
>
> > Thank you!
> >
> > On Wed, Sep 5, 2018 at 11:56 AM Christian Grothoff
> >  wrote:
> > [...]
> >
> > > You need to initiate another HTTP request from the client, again do
> > > the upgrade and then handle resumption within your application
> > > protocol.
> > >
> > > Happy hacking!
> > >
> > > Christian
> > >
> >
>
>

-- 
Silvio Clécio


Re: [libmicrohttpd] Web Socket disconnect behaviour

2018-10-30 Thread José Bollo
On Tue, 30 Oct 2018 12:30:46 -0300
silvioprog  wrote:

> José, thanks a lot for sharing.

Hi Silvio,

> This example is awesome! I'm not expert in WS but it seems this
> example can run without any external dependencies. I'll test it this
> weekend.
> 
> Since this code is small and clear, what do you think about to make
> it as a official MHD WS example in the examples folder? :-) It would
> be useful and a bootstrap for who wants to start in web sockets + MHD.

It can be pick in MHD example folder if maintainers see interest in
that. But after a tiny cleanup. Are you volunteer?

> Thank you for sharing!

You are welcome. I just hope your trial will be successful easily.

Best regards
José

> On Thu, Oct 11, 2018 at 4:22 AM José Bollo  wrote:
> 
> > On Mon, 8 Oct 2018 23:41:02 -0300
> > silvioprog  wrote:
> >  
> > > Hi dudes.
> > >
> > > @Christian, just for curiosity, is there any document or example
> > > showing MHD + WS? I can't provide it since I'm not familiar with
> > > WS, but it would be nice if someone could provide one for us. 😅
> > >  
> >
> > Hello Sylvio,
> >
> > I'm using LMHD for websocket-ing. I point you a central file that
> > may help (or not -hope to not confuse you-).
> >
> >
> > https://git.automotivelinux.org/src/app-framework-binder/tree/src/afb-websock.c
> >
> > Best regards
> > José Bollo
> >  
> > > Thank you!
> > >
> > > On Wed, Sep 5, 2018 at 11:56 AM Christian Grothoff
> > >  wrote:
> > > [...]
> > >  
> > > > You need to initiate another HTTP request from the client,
> > > > again do the upgrade and then handle resumption within your
> > > > application protocol.
> > > >
> > > > Happy hacking!
> > > >
> > > > Christian
> > > >  
> > >  
> >
> >  
> 




Re: [libmicrohttpd] Web Socket disconnect behaviour

2018-10-30 Thread silvioprog
I hope Christian/Evgeny and others agree with us too. :-) Websockets is a
very interesting subject!

I took a look at http://websocket.org and it seems the "Echo Test
" is the easiest example. I can write the
client part (at least in the example comments) in a small JS, but it would
be nice to write a small client using libcurl too.

On Tue, Oct 30, 2018 at 12:47 PM José Bollo  wrote:

> On Tue, 30 Oct 2018 12:30:46 -0300
> silvioprog  wrote:
>
> > José, thanks a lot for sharing.
>
> Hi Silvio,
>
> > This example is awesome! I'm not expert in WS but it seems this
> > example can run without any external dependencies. I'll test it this
> > weekend.
> >
> > Since this code is small and clear, what do you think about to make
> > it as a official MHD WS example in the examples folder? :-) It would
> > be useful and a bootstrap for who wants to start in web sockets + MHD.
>
> It can be pick in MHD example folder if maintainers see interest in
> that. But after a tiny cleanup. Are you volunteer?
>
> > Thank you for sharing!
>
> You are welcome. I just hope your trial will be successful easily.
>
> Best regards
> José
>
> > On Thu, Oct 11, 2018 at 4:22 AM José Bollo  wrote:
> >
> > > On Mon, 8 Oct 2018 23:41:02 -0300
> > > silvioprog  wrote:
> > >
> > > > Hi dudes.
> > > >
> > > > @Christian, just for curiosity, is there any document or example
> > > > showing MHD + WS? I can't provide it since I'm not familiar with
> > > > WS, but it would be nice if someone could provide one for us. 😅
> > > >
> > >
> > > Hello Sylvio,
> > >
> > > I'm using LMHD for websocket-ing. I point you a central file that
> > > may help (or not -hope to not confuse you-).
> > >
> > >
> > >
> https://git.automotivelinux.org/src/app-framework-binder/tree/src/afb-websock.c
> > >
> > > Best regards
> > > José Bollo
> > >
> > > > Thank you!
> > > >
> > > > On Wed, Sep 5, 2018 at 11:56 AM Christian Grothoff
> > > >  wrote:
> > > > [...]
> > > >
> > > > > You need to initiate another HTTP request from the client,
> > > > > again do the upgrade and then handle resumption within your
> > > > > application protocol.
> > > > >
> > > > > Happy hacking!
> > > > >
> > > > > Christian
> > > > >
> > > >
> > >
> > >
> >
>
>

-- 
Silvio Clécio