]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[DECNET]: fix SIGPIPE
authorPatrick Caulfield <patrick@tykepenguin.com>
Fri, 11 Nov 2005 20:04:28 +0000 (12:04 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 11 Nov 2005 20:04:28 +0000 (12:04 -0800)
Currently recvmsg generates SIGPIPE whereas sendmsg does not; for the
other stacks it seems to be the other way round!

It also fixes the bug where reading from a socket whose peer has shutdown
returned -EINVAL rather than 0.

Signed-off-by: Patrick Caulfield <patrick@tykepenguin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/decnet/af_decnet.c

index 3f25cadccddd4f048cdbf36d2fa5e92a8a176116..f89e55f814d9b8c1a23737d10db90fd5914502ec 100644 (file)
@@ -1664,17 +1664,15 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
                goto out;
        }
 
-       rv = dn_check_state(sk, NULL, 0, &timeo, flags);
-       if (rv)
-               goto out;
-
        if (sk->sk_shutdown & RCV_SHUTDOWN) {
-               if (!(flags & MSG_NOSIGNAL))
-                       send_sig(SIGPIPE, current, 0);
-               rv = -EPIPE;
+               rv = 0;
                goto out;
        }
 
+       rv = dn_check_state(sk, NULL, 0, &timeo, flags);
+       if (rv)
+               goto out;
+
        if (flags & ~(MSG_PEEK|MSG_OOB|MSG_WAITALL|MSG_DONTWAIT|MSG_NOSIGNAL)) {
                rv = -EOPNOTSUPP;
                goto out;
@@ -1928,6 +1926,8 @@ static int dn_sendmsg(struct kiocb *iocb, struct socket *sock,
 
        if (sk->sk_shutdown & SEND_SHUTDOWN) {
                err = -EPIPE;
+               if (!(flags & MSG_NOSIGNAL))
+                       send_sig(SIGPIPE, current, 0);
                goto out_err;
        }