diff options
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r-- | net/unix/af_unix.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 515e7a692f9b..060bba4567d2 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -457,7 +457,7 @@ static int unix_release_sock (struct sock *sk, int embrion) | |||
457 | * What the above comment does talk about? --ANK(980817) | 457 | * What the above comment does talk about? --ANK(980817) |
458 | */ | 458 | */ |
459 | 459 | ||
460 | if (atomic_read(&unix_tot_inflight)) | 460 | if (unix_tot_inflight) |
461 | unix_gc(); /* Garbage collect fds */ | 461 | unix_gc(); /* Garbage collect fds */ |
462 | 462 | ||
463 | return 0; | 463 | return 0; |
@@ -599,15 +599,14 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
599 | struct sock *sk = NULL; | 599 | struct sock *sk = NULL; |
600 | struct unix_sock *u; | 600 | struct unix_sock *u; |
601 | 601 | ||
602 | if (atomic_read(&unix_nr_socks) >= 2*get_max_files()) | 602 | atomic_inc(&unix_nr_socks); |
603 | if (atomic_read(&unix_nr_socks) > 2 * get_max_files()) | ||
603 | goto out; | 604 | goto out; |
604 | 605 | ||
605 | sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto); | 606 | sk = sk_alloc(net, PF_UNIX, GFP_KERNEL, &unix_proto); |
606 | if (!sk) | 607 | if (!sk) |
607 | goto out; | 608 | goto out; |
608 | 609 | ||
609 | atomic_inc(&unix_nr_socks); | ||
610 | |||
611 | sock_init_data(sock,sk); | 610 | sock_init_data(sock,sk); |
612 | lockdep_set_class(&sk->sk_receive_queue.lock, | 611 | lockdep_set_class(&sk->sk_receive_queue.lock, |
613 | &af_unix_sk_receive_queue_lock_key); | 612 | &af_unix_sk_receive_queue_lock_key); |
@@ -625,6 +624,8 @@ static struct sock * unix_create1(struct net *net, struct socket *sock) | |||
625 | init_waitqueue_head(&u->peer_wait); | 624 | init_waitqueue_head(&u->peer_wait); |
626 | unix_insert_socket(unix_sockets_unbound, sk); | 625 | unix_insert_socket(unix_sockets_unbound, sk); |
627 | out: | 626 | out: |
627 | if (sk == NULL) | ||
628 | atomic_dec(&unix_nr_socks); | ||
628 | return sk; | 629 | return sk; |
629 | } | 630 | } |
630 | 631 | ||
@@ -1636,8 +1637,15 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1636 | mutex_lock(&u->readlock); | 1637 | mutex_lock(&u->readlock); |
1637 | 1638 | ||
1638 | skb = skb_recv_datagram(sk, flags, noblock, &err); | 1639 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
1639 | if (!skb) | 1640 | if (!skb) { |
1641 | unix_state_lock(sk); | ||
1642 | /* Signal EOF on disconnected non-blocking SEQPACKET socket. */ | ||
1643 | if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN && | ||
1644 | (sk->sk_shutdown & RCV_SHUTDOWN)) | ||
1645 | err = 0; | ||
1646 | unix_state_unlock(sk); | ||
1640 | goto out_unlock; | 1647 | goto out_unlock; |
1648 | } | ||
1641 | 1649 | ||
1642 | wake_up_interruptible_sync(&u->peer_wait); | 1650 | wake_up_interruptible_sync(&u->peer_wait); |
1643 | 1651 | ||