Re: Closing an accepting BSD socket from a different thread


Stephan Gatzka
 

You're assuming Unix signals work...
https://lwn.net/Articles/414618/ Unfixable designs
Well, not really. I know the drawbacks of dealing with signals and in Linux with epoll() and nearly everything being a file descriptor you can put into epoll() there is no need to rely on signals.

But because poll() in zephyr only accepts socket fd's, I have to build another mechanism for asynchronous I/O (for sockets, files, timers, DNS resolution etc.).

variables. E.g., following is a well-know pattern:
=== main loop thread ===
while (!should_exit) {
...
poll(..., MAIN_LOOP_PERIOD);
...
}
close(...);
exit();
=== other threads ===
should_exit = true;
Yeah sure, put this is polling and a waste of resources.
Even if MAIN_LOOP_PERIOD is somewhat longer than the network protocol timeout(s) after which the socket should be closed anyway if the other end disappears?
Well, for a normal socket connection this might be probably o.k., but what about a server socket blocking on an accept()? There is no such thing like a network timeout.

Join users@lists.zephyrproject.org to automatically receive all group messages.