aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 29fc8bee9702..94404f19f9de 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -163,9 +163,8 @@ static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb)
163 163
164static inline unsigned int unix_hash_fold(__wsum n) 164static inline unsigned int unix_hash_fold(__wsum n)
165{ 165{
166 unsigned int hash = (__force unsigned int)n; 166 unsigned int hash = (__force unsigned int)csum_fold(n);
167 167
168 hash ^= hash>>16;
169 hash ^= hash>>8; 168 hash ^= hash>>8;
170 return hash&(UNIX_HASH_SIZE-1); 169 return hash&(UNIX_HASH_SIZE-1);
171} 170}
@@ -1788,8 +1787,11 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
1788 goto out; 1787 goto out;
1789 1788
1790 err = mutex_lock_interruptible(&u->readlock); 1789 err = mutex_lock_interruptible(&u->readlock);
1791 if (err) { 1790 if (unlikely(err)) {
1792 err = sock_intr_errno(sock_rcvtimeo(sk, noblock)); 1791 /* recvmsg() in non blocking mode is supposed to return -EAGAIN
1792 * sk_rcvtimeo is not honored by mutex_lock_interruptible()
1793 */
1794 err = noblock ? -EAGAIN : -ERESTARTSYS;
1793 goto out; 1795 goto out;
1794 } 1796 }
1795 1797
@@ -1914,6 +1916,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1914 struct unix_sock *u = unix_sk(sk); 1916 struct unix_sock *u = unix_sk(sk);
1915 DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name); 1917 DECLARE_SOCKADDR(struct sockaddr_un *, sunaddr, msg->msg_name);
1916 int copied = 0; 1918 int copied = 0;
1919 int noblock = flags & MSG_DONTWAIT;
1917 int check_creds = 0; 1920 int check_creds = 0;
1918 int target; 1921 int target;
1919 int err = 0; 1922 int err = 0;
@@ -1929,7 +1932,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1929 goto out; 1932 goto out;
1930 1933
1931 target = sock_rcvlowat(sk, flags&MSG_WAITALL, size); 1934 target = sock_rcvlowat(sk, flags&MSG_WAITALL, size);
1932 timeo = sock_rcvtimeo(sk, flags&MSG_DONTWAIT); 1935 timeo = sock_rcvtimeo(sk, noblock);
1933 1936
1934 /* Lock the socket to prevent queue disordering 1937 /* Lock the socket to prevent queue disordering
1935 * while sleeps in memcpy_tomsg 1938 * while sleeps in memcpy_tomsg
@@ -1941,8 +1944,11 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
1941 } 1944 }
1942 1945
1943 err = mutex_lock_interruptible(&u->readlock); 1946 err = mutex_lock_interruptible(&u->readlock);
1944 if (err) { 1947 if (unlikely(err)) {
1945 err = sock_intr_errno(timeo); 1948 /* recvmsg() in non blocking mode is supposed to return -EAGAIN
1949 * sk_rcvtimeo is not honored by mutex_lock_interruptible()
1950 */
1951 err = noblock ? -EAGAIN : -ERESTARTSYS;
1946 goto out; 1952 goto out;
1947 } 1953 }
1948 1954