> #include <stdio.h>
> #include <unistd.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> 
> int
> main(int argc, const char* argv[])
> {
>   int retval;
>   int sockets[2];
>   char buf[1];
> 
>   retval = socketpair(PF_UNIX, SOCK_DGRAM, 0, sockets);
>   if (retval != 0)
>   {
>     perror("socketpair");
>     exit(1);
>   }
>   shutdown(sockets[0], SHUT_RDWR);
>   read(sockets[0], buf, 1);
> }

I tried to debug this issue with the kdb on 2.4.1-pre7.
Here is the stack trace

mcount+0x1f9
wait_for_packet+0x13
skb_recv_datagram+0xbb
unix_dgram_recvmsg+0x53
sock_recvmsg+0x41
sock_read+0x8f
sys_read+0xa4
system_call+0x3c

I looked at the skb_recv_datagram code and noticed that wait_for_packet is not
returning an error, even while trying to read a closed socket.
Anyways here is a patch against 2.4.1 that will fix the issue.
Please feel free to flame me about the patch :)

thanks
-- 
Prasanna Subash   ---   [EMAIL PROTECTED]   ---     TurboLinux, INC
------------------------------------------------------------------------
Linux, the choice          | Q: How do you keep a moron in suspense? 
of a GNU generation   -o)  | 
Kernel 2.2.16         /\\  | 
on a i686            _\\_v | 
                           | 
------------------------------------------------------------------------
--- 2.4.1/net/core/datagram.c	Fri Feb  2 01:00:10 2001
+++ linux/net/core/datagram.c	Fri Feb  2 01:06:59 2001
@@ -74,15 +74,15 @@
 	if (error)
 		goto out;
 
-	if (!skb_queue_empty(&sk->receive_queue))
-		goto ready;
-
+	error = -ENOTCONN;
 	/* Socket shut down? */
 	if (sk->shutdown & RCV_SHUTDOWN)
 		goto out;
 
+	if (!skb_queue_empty(&sk->receive_queue))
+		goto ready;
+
 	/* Sequenced packets can come disconnected. If so we report the problem */
-	error = -ENOTCONN;
 	if(connection_based(sk) && !(sk->state==TCP_ESTABLISHED || sk->state==TCP_LISTEN))
 		goto out;
 

PGP signature

Reply via email to