Re: [PATCH] removed socket buffer in unix domain socket

From: Alexander Viro (
Date: Mon Jan 07 2002 - 04:11:16 EST

On Mon, 7 Jan 2002, Yasuma Takeda wrote:

> Hi,
> I found a problem to unix domain socket.
> The unix_gc function removes socket buffers of the socket
> which is connectted but not acceptted yet.
> After one process executes "Mark phase" of unix_gc function,
> another process registers socket buffer by using sendmsg with SCM_RIGHTS.
> At the next moment, the socket buffer is removed.
> I attached the test program.
> When I execute one server and two clients on SMP machine
> (kernel 2.4.16 and PentiumIII x 2), I can reporduce this problem.
> Following is a patch to avoid this problem.

It looks bogus. Are you sure that listening socket is not garbage at that
point in your testcase?

Your patch is definitely wrong - consider the case when we send fd1 to
ourselves (fd2 would be receiving end), then send fd2 (fd3 would be
receiving end), then close fd3. We want _both_ packets (carrying fd1
and fd2 resp.) to be taken out of queues in that loop. So added check
is broken.

We scan the queues of listening sockets, all right, but only if listening
socket itself becomes a garbage. I.e. only if connection is never going
to be accepted...

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 21:00:33 EST