[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Double regarding suspended connection and pthread_ex
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] Double regarding suspended connection and pthread_exit |
Date: |
Tue, 17 Mar 2020 01:52:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
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, silvioprog wrote:
> 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 <address@hidden
> <mailto:address@hidden>> wrote:
>
> The CTRL-C / SIGTERM will be required by the application, so after
> this advice, I'm going to use a list with mutex and join (or cancel)
> the active threads before shutting down the server.
>
> Supposing this new design, what is the best point to call the
> "resume" function? For example:
>
> static void *thread_cb(void *cls) {
> /* this is inside new thread */
> struct req *r = cls;
> // MHD_resume_connection(r->con); *// position 1*
> r->cb(); *// possible long time processing data*
> MHD_resume_connection(r->con); *// position 2*
> return NULL;
> }
>
> int ahc(...) {
> ...
> MHD_suspend_connection(r->con);
> ret = pthread_create(&thread, NULL, thread_cb, r);
> return ret;
> }
>
>
> --
> Silvio Clécio
signature.asc
Description: OpenPGP digital signature