[noPoll] nopoll_loop_wait(ctx,0) unexpectedly exited
Tony Mountifield
tony en softins.co.uk
Mar Sep 19 13:30:56 CEST 2017
In article <opqsrq$9gp$1 at softins.softins.co.uk>,
Tony Mountifield <tony at softins.co.uk> wrote:
> I just had a strange occurrence, and wondered how to go about understanding it.
>
> I have a websocket thread that calls nopoll_loop_wait(ctx,0), which I expected
> to continue running until another thread calls nopoll_loop_stop(ctx) as part
> of the process termination.
>
> Today, while testing, nopoll_look_wait() had been running fine, but then exited
> when I closed one of the accepted connections. I hadn't captured the return status,
> but will add code to do that for next time.
>
> I am certain nopoll_loop_stop() had not been called, so I was wondering if there
> is any other reason nopoll_loop_wait(ctx,0) would exit after running fine for a time?
>
> I've only ever seen it happen the once.
>
> I'll dig into the code, but wanted to ask here for ideas!
OK, looking in the code for nopoll_loop_wait(), it appears the only two ways
the loop can exit are:
- ctx->keep_looping cets cleared. This only happens in nopoll_loop_stop()
- the wait operation exits with -1 for some reason
I didn't have nopoll logging enabled, so can't tell if it was the second.
It looks like I could recover from the latter situation with the kludge:
do {
nopoll_loop_wait(ctx,0);
} while(ctx->keep_looping);
That would re-invoke it if it had exited abnormally due to a wait error.
Cheers
Tony
--
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org
Más información sobre la lista de distribución noPoll