tech-net archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: A possible bug with non-blocking sockets and SIGIO
On Thu, Feb 17, 2011 at 10:58:10AM +0300, Dmitry Matveev wrote:
> I have discovered a bug (at least it looks like a bug) in NetBSD's
> socket layer.
I disagree, see below.
> Background information
> ----------------------
>
> Suppose there is a single-threaded server. It uses SIGIO to maintain
> incoming connections and data from clients.
Using SIGIO is bad idea in general. Please use poll(2) or
kqueue(2) + kevent(2) instead.
> Server process does not receive SIGIO on incoming data on the client
> socket.
Because you never setup the acceptor socket to do so.
Here are my comment about your source code:
void incoming_data (int i) {
if (i != SIGIO)
exit (0);
It is not safe to use exit(3) from a signal handler, please use
_exit(2) instead.
g_client = accept_client (g_server);
CLOG ("client accepted");
Here is your problem. You newer setup asynchronous I/O on this socket.
You need to use fcntl(2) to set O_ASYNC just as you do on the
acceptor socket.
Kind regards
--
Matthias Scheler http://zhadum.org.uk/
Home |
Main Index |
Thread Index |
Old Index