Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
Oh, sent accidentally by Ctrl+Enter with wrong subject. I meant: "Doubt regarding suspended connection and pthread_exit". On Mon, Mar 16, 2020 at 4:00 PM silvioprog wrote: > Hi. > > I have a routine which suspends a MHD connection and calls the following > functions when it starts: > > 1. MHD_su

[libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
Hi. I have a routine which suspends a MHD connection and calls the following functions when it starts: 1. MHD_suspend_connection() 2. pthread_create() 3. pthread_detach() and the following when it finishes: 1. MHD_resume_connection() 2. *some callback()* 3. pthread_exit() but the server may be

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread Christian Grothoff
This seems kind-of OK (I personally think pthread_detach is always messy and in 99.9% of cases a bad idea). What you do need to (somehow) ensure is that you do MHD_resume_connection() (and let it finish) *before* calling MHD_stop_daemon(). On 3/16/20 8:00 PM, silvioprog wrote: > Hi. > > I have a

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
On Mon, Mar 16, 2020 at 4:29 PM Christian Grothoff wrote: > This seems kind-of OK (I personally think pthread_detach is always messy > and in 99.9% of cases a bad idea). Hm... Could you point the disadvantages of using detached threads? I'm a little newbie with this feature of pthreads. I'm go

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread Christian Grothoff
On 3/16/20 9:16 PM, silvioprog wrote: > On Mon, Mar 16, 2020 at 4:29 PM Christian Grothoff > wrote: > > This seems kind-of OK (I personally think pthread_detach is always messy > and in 99.9% of cases a bad idea). > > > Hm... Could you point the disadvantage

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
On Mon, Mar 16, 2020 at 7:37 PM Christian Grothoff wrote: > Usually, you will eventually find that you do need to wait on the thread > to finish for a controlled shutdown, and at that point it is then better > to keep the thread handles in some data structure so you can join. At > least I found t

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
Complementing, I have done some tests resuming at "position 1" and the server doesn't lock. Should I use at that point? 🤔 (the MHD_resume_connection() inside ahc() in previous example was a typo) On Mon, Mar 16, 2020 at 9:27 PM silvioprog wrote: > The CTRL-C / SIGTERM will be required by the ap

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread Christian Grothoff
You should resume once the data is available, which _likely_ means position 2 (I don't know enough about your code to be sure). You also need a way to stop the 'long time processing of data' if you get the SIGTERM, and then join the thread before calling MHD_stop_daemon(). On 3/17/20 1:39 AM, sil

Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit

2020-03-16 Thread silvioprog
Now I totally understand what you meant. All the explanations helped me a lot. Thank you very much for all help! ☺ On Mon, Mar 16, 2020 at 9:52 PM Christian Grothoff wrote: > You should resume once the data is available, which _likely_ means > position 2 (I don't know enough about your code to