]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
Revert "af_unix: Revert 'lock_interruptible' in stream receive code"
authorAndy Whitcroft <apw@canonical.com>
Fri, 5 Feb 2016 13:20:56 +0000 (13:20 +0000)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 29 Feb 2016 16:01:53 +0000 (09:01 -0700)
This reverts commit 3822b5c2fc62e3de8a0f33806ff279fb7df92432.

BugLink: http://bugs.launchpad.net/bugs/1540731
Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
net/unix/af_unix.c

index e3f85bc8b135d8feb13d60432e5f6cdb1064fbd6..7793b09532e710b6970fea2acc2d896ac5f60f61 100644 (file)
@@ -2286,7 +2286,14 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
        /* Lock the socket to prevent queue disordering
         * while sleeps in memcpy_tomsg
         */
-       mutex_lock(&u->readlock);
+       err = mutex_lock_interruptible(&u->readlock);
+       if (unlikely(err)) {
+               /* recvmsg() in non blocking mode is supposed to return -EAGAIN
+                * sk_rcvtimeo is not honored by mutex_lock_interruptible()
+                */
+               err = noblock ? -EAGAIN : -ERESTARTSYS;
+               goto out;
+       }
 
        if (flags & MSG_PEEK)
                skip = sk_peek_offset(sk, flags);
@@ -2330,12 +2337,12 @@ again:
                        timeo = unix_stream_data_wait(sk, timeo, last,
                                                      last_len);
 
-                       if (signal_pending(current)) {
+                       if (signal_pending(current) ||
+                           mutex_lock_interruptible(&u->readlock)) {
                                err = sock_intr_errno(timeo);
                                goto out;
                        }
 
-                       mutex_lock(&u->readlock);
                        continue;
 unlock:
                        unix_state_unlock(sk);