diff options
| author | Steve French <sfrench@us.ibm.com> | 2006-03-30 22:35:56 -0500 |
|---|---|---|
| committer | Steve French <sfrench@us.ibm.com> | 2006-03-30 22:35:56 -0500 |
| commit | d62e54abca1146981fc9f98f85ff398a113a22c2 (patch) | |
| tree | 870420dbc4c65e716dcef8a802aafdc0ef97a8b4 /net/unix | |
| parent | fd4a0b92db6a57cba8d03efbe1cebf91f9124ce0 (diff) | |
| parent | ce362c009250340358a7221f3cdb7954cbf19c01 (diff) | |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'net/unix')
| -rw-r--r-- | net/unix/af_unix.c | 34 | ||||
| -rw-r--r-- | net/unix/garbage.c | 7 |
2 files changed, 22 insertions, 19 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index c323cc6a28b0..d901465ce013 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
| @@ -566,7 +566,7 @@ static struct sock * unix_create1(struct socket *sock) | |||
| 566 | u->mnt = NULL; | 566 | u->mnt = NULL; |
| 567 | spin_lock_init(&u->lock); | 567 | spin_lock_init(&u->lock); |
| 568 | atomic_set(&u->inflight, sock ? 0 : -1); | 568 | atomic_set(&u->inflight, sock ? 0 : -1); |
| 569 | init_MUTEX(&u->readsem); /* single task reading lock */ | 569 | mutex_init(&u->readlock); /* single task reading lock */ |
| 570 | init_waitqueue_head(&u->peer_wait); | 570 | init_waitqueue_head(&u->peer_wait); |
| 571 | unix_insert_socket(unix_sockets_unbound, sk); | 571 | unix_insert_socket(unix_sockets_unbound, sk); |
| 572 | out: | 572 | out: |
| @@ -623,7 +623,7 @@ static int unix_autobind(struct socket *sock) | |||
| 623 | struct unix_address * addr; | 623 | struct unix_address * addr; |
| 624 | int err; | 624 | int err; |
| 625 | 625 | ||
| 626 | down(&u->readsem); | 626 | mutex_lock(&u->readlock); |
| 627 | 627 | ||
| 628 | err = 0; | 628 | err = 0; |
| 629 | if (u->addr) | 629 | if (u->addr) |
| @@ -661,7 +661,7 @@ retry: | |||
| 661 | spin_unlock(&unix_table_lock); | 661 | spin_unlock(&unix_table_lock); |
| 662 | err = 0; | 662 | err = 0; |
| 663 | 663 | ||
| 664 | out: up(&u->readsem); | 664 | out: mutex_unlock(&u->readlock); |
| 665 | return err; | 665 | return err; |
| 666 | } | 666 | } |
| 667 | 667 | ||
| @@ -744,7 +744,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 744 | goto out; | 744 | goto out; |
| 745 | addr_len = err; | 745 | addr_len = err; |
| 746 | 746 | ||
| 747 | down(&u->readsem); | 747 | mutex_lock(&u->readlock); |
| 748 | 748 | ||
| 749 | err = -EINVAL; | 749 | err = -EINVAL; |
| 750 | if (u->addr) | 750 | if (u->addr) |
| @@ -816,7 +816,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 816 | out_unlock: | 816 | out_unlock: |
| 817 | spin_unlock(&unix_table_lock); | 817 | spin_unlock(&unix_table_lock); |
| 818 | out_up: | 818 | out_up: |
| 819 | up(&u->readsem); | 819 | mutex_unlock(&u->readlock); |
| 820 | out: | 820 | out: |
| 821 | return err; | 821 | return err; |
| 822 | 822 | ||
| @@ -1427,15 +1427,15 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 1427 | while(sent < len) | 1427 | while(sent < len) |
| 1428 | { | 1428 | { |
| 1429 | /* | 1429 | /* |
| 1430 | * Optimisation for the fact that under 0.01% of X messages typically | 1430 | * Optimisation for the fact that under 0.01% of X |
| 1431 | * need breaking up. | 1431 | * messages typically need breaking up. |
| 1432 | */ | 1432 | */ |
| 1433 | 1433 | ||
| 1434 | size=len-sent; | 1434 | size = len-sent; |
| 1435 | 1435 | ||
| 1436 | /* Keep two messages in the pipe so it schedules better */ | 1436 | /* Keep two messages in the pipe so it schedules better */ |
| 1437 | if (size > sk->sk_sndbuf / 2 - 64) | 1437 | if (size > ((sk->sk_sndbuf >> 1) - 64)) |
| 1438 | size = sk->sk_sndbuf / 2 - 64; | 1438 | size = (sk->sk_sndbuf >> 1) - 64; |
| 1439 | 1439 | ||
| 1440 | if (size > SKB_MAX_ALLOC) | 1440 | if (size > SKB_MAX_ALLOC) |
| 1441 | size = SKB_MAX_ALLOC; | 1441 | size = SKB_MAX_ALLOC; |
| @@ -1545,7 +1545,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1545 | 1545 | ||
| 1546 | msg->msg_namelen = 0; | 1546 | msg->msg_namelen = 0; |
| 1547 | 1547 | ||
| 1548 | down(&u->readsem); | 1548 | mutex_lock(&u->readlock); |
| 1549 | 1549 | ||
| 1550 | skb = skb_recv_datagram(sk, flags, noblock, &err); | 1550 | skb = skb_recv_datagram(sk, flags, noblock, &err); |
| 1551 | if (!skb) | 1551 | if (!skb) |
| @@ -1600,7 +1600,7 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1600 | out_free: | 1600 | out_free: |
| 1601 | skb_free_datagram(sk,skb); | 1601 | skb_free_datagram(sk,skb); |
| 1602 | out_unlock: | 1602 | out_unlock: |
| 1603 | up(&u->readsem); | 1603 | mutex_unlock(&u->readlock); |
| 1604 | out: | 1604 | out: |
| 1605 | return err; | 1605 | return err; |
| 1606 | } | 1606 | } |
| @@ -1676,7 +1676,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1676 | memset(&tmp_scm, 0, sizeof(tmp_scm)); | 1676 | memset(&tmp_scm, 0, sizeof(tmp_scm)); |
| 1677 | } | 1677 | } |
| 1678 | 1678 | ||
| 1679 | down(&u->readsem); | 1679 | mutex_lock(&u->readlock); |
| 1680 | 1680 | ||
| 1681 | do | 1681 | do |
| 1682 | { | 1682 | { |
| @@ -1700,7 +1700,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1700 | err = -EAGAIN; | 1700 | err = -EAGAIN; |
| 1701 | if (!timeo) | 1701 | if (!timeo) |
| 1702 | break; | 1702 | break; |
| 1703 | up(&u->readsem); | 1703 | mutex_unlock(&u->readlock); |
| 1704 | 1704 | ||
| 1705 | timeo = unix_stream_data_wait(sk, timeo); | 1705 | timeo = unix_stream_data_wait(sk, timeo); |
| 1706 | 1706 | ||
| @@ -1708,7 +1708,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1708 | err = sock_intr_errno(timeo); | 1708 | err = sock_intr_errno(timeo); |
| 1709 | goto out; | 1709 | goto out; |
| 1710 | } | 1710 | } |
| 1711 | down(&u->readsem); | 1711 | mutex_lock(&u->readlock); |
| 1712 | continue; | 1712 | continue; |
| 1713 | } | 1713 | } |
| 1714 | 1714 | ||
| @@ -1774,7 +1774,7 @@ static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
| 1774 | } | 1774 | } |
| 1775 | } while (size); | 1775 | } while (size); |
| 1776 | 1776 | ||
| 1777 | up(&u->readsem); | 1777 | mutex_unlock(&u->readlock); |
| 1778 | scm_recv(sock, msg, siocb->scm, flags); | 1778 | scm_recv(sock, msg, siocb->scm, flags); |
| 1779 | out: | 1779 | out: |
| 1780 | return copied ? : err; | 1780 | return copied ? : err; |
| @@ -1878,6 +1878,8 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl | |||
| 1878 | mask |= POLLERR; | 1878 | mask |= POLLERR; |
| 1879 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 1879 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
| 1880 | mask |= POLLHUP; | 1880 | mask |= POLLHUP; |
| 1881 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
| 1882 | mask |= POLLRDHUP; | ||
| 1881 | 1883 | ||
| 1882 | /* readable? */ | 1884 | /* readable? */ |
| 1883 | if (!skb_queue_empty(&sk->sk_receive_queue) || | 1885 | if (!skb_queue_empty(&sk->sk_receive_queue) || |
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 411802bd4d37..746c2f4a5fa6 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
| @@ -76,6 +76,7 @@ | |||
| 76 | #include <linux/netdevice.h> | 76 | #include <linux/netdevice.h> |
| 77 | #include <linux/file.h> | 77 | #include <linux/file.h> |
| 78 | #include <linux/proc_fs.h> | 78 | #include <linux/proc_fs.h> |
| 79 | #include <linux/mutex.h> | ||
| 79 | 80 | ||
| 80 | #include <net/sock.h> | 81 | #include <net/sock.h> |
| 81 | #include <net/af_unix.h> | 82 | #include <net/af_unix.h> |
| @@ -169,7 +170,7 @@ static void maybe_unmark_and_push(struct sock *x) | |||
| 169 | 170 | ||
| 170 | void unix_gc(void) | 171 | void unix_gc(void) |
| 171 | { | 172 | { |
| 172 | static DECLARE_MUTEX(unix_gc_sem); | 173 | static DEFINE_MUTEX(unix_gc_sem); |
| 173 | int i; | 174 | int i; |
| 174 | struct sock *s; | 175 | struct sock *s; |
| 175 | struct sk_buff_head hitlist; | 176 | struct sk_buff_head hitlist; |
| @@ -179,7 +180,7 @@ void unix_gc(void) | |||
| 179 | * Avoid a recursive GC. | 180 | * Avoid a recursive GC. |
| 180 | */ | 181 | */ |
| 181 | 182 | ||
| 182 | if (down_trylock(&unix_gc_sem)) | 183 | if (!mutex_trylock(&unix_gc_sem)) |
| 183 | return; | 184 | return; |
| 184 | 185 | ||
| 185 | spin_lock(&unix_table_lock); | 186 | spin_lock(&unix_table_lock); |
| @@ -308,5 +309,5 @@ void unix_gc(void) | |||
| 308 | */ | 309 | */ |
| 309 | 310 | ||
| 310 | __skb_queue_purge(&hitlist); | 311 | __skb_queue_purge(&hitlist); |
| 311 | up(&unix_gc_sem); | 312 | mutex_unlock(&unix_gc_sem); |
| 312 | } | 313 | } |
