SIGIO broken in 2.2 on unix domain socket close

Malcolm Beattie (mbeattie@sable.ox.ac.uk)
Sun, 4 Jul 1999 17:06:20 +0100 (BST)


Async I/O via SIGIO is broken in 2.2.5 when a Unix domain peer
socket is released. Here's a test program which works in 2.0.36
(i.e. displays "in io_handle") but not in 2.2.5 (I don't have any
later 2.2.x kernels to try or look at).

--------------------------- cut here ---------------------------
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>

void io_handle(int sig)
{
write(1, "in io_handle\n", 13);
}

int main(void)
{
int fd[2];
socketpair(PF_UNIX, SOCK_STREAM, 0, fd);
signal(SIGIO, io_handle);
fcntl(fd[0], F_SETOWN, getpid());
fcntl(fd[0], F_SETFL, O_ASYNC);
close(fd[1]);
exit(0);
}

--------------------------- cut here ---------------------------

(Obviously in the real program, the socketpair is shared between
a parent and child process but the behaviour is the same.)

The Unix domain socket stuff has been rewritten between 2.0 and
2.2 and it looks as though maybe something like a sock_wake_async()
has been missed out from net/unix/af_unix.c in somewhere like:

skpair=unix_peer(sk);

if (skpair!=NULL)
{
if (sk->type==SOCK_STREAM && unix_our_peer(sk, skpair))
{
skpair->state_change(skpair);
skpair->shutdown=SHUTDOWN_MASK; /* No more writes*/
}
unix_unlock(skpair); /* It may now die */
}

Either after the state_change method gets called (or within the
state_change) there perhaps ought to be a sock_wake_async to prod
the peer?

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/