diff options
author | David S. Miller <davem@davemloft.net> | 2008-06-28 04:19:40 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-28 04:19:40 -0400 |
commit | 1b63ba8a86c85524a8d7e5953b314ce71ebcb9c9 (patch) | |
tree | fe3dc41cbb47ae12b7c3faf6a88b097349e50d5a /net/unix | |
parent | e35c3269edba151e1c703d87068a28ce2cd65bb0 (diff) | |
parent | d420895efb259a78dda50f95289571faa6e10e41 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts:
drivers/net/wireless/iwlwifi/iwl4965-base.c
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/af_unix.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index b4280490cf6e..70ceb1604ad8 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -485,8 +485,8 @@ static int unix_socketpair(struct socket *, struct socket *); | |||
485 | static int unix_accept(struct socket *, struct socket *, int); | 485 | static int unix_accept(struct socket *, struct socket *, int); |
486 | static int unix_getname(struct socket *, struct sockaddr *, int *, int); | 486 | static int unix_getname(struct socket *, struct sockaddr *, int *, int); |
487 | static unsigned int unix_poll(struct file *, struct socket *, poll_table *); | 487 | static unsigned int unix_poll(struct file *, struct socket *, poll_table *); |
488 | static unsigned int unix_datagram_poll(struct file *, struct socket *, | 488 | static unsigned int unix_dgram_poll(struct file *, struct socket *, |
489 | poll_table *); | 489 | poll_table *); |
490 | static int unix_ioctl(struct socket *, unsigned int, unsigned long); | 490 | static int unix_ioctl(struct socket *, unsigned int, unsigned long); |
491 | static int unix_shutdown(struct socket *, int); | 491 | static int unix_shutdown(struct socket *, int); |
492 | static int unix_stream_sendmsg(struct kiocb *, struct socket *, | 492 | static int unix_stream_sendmsg(struct kiocb *, struct socket *, |
@@ -532,7 +532,7 @@ static const struct proto_ops unix_dgram_ops = { | |||
532 | .socketpair = unix_socketpair, | 532 | .socketpair = unix_socketpair, |
533 | .accept = sock_no_accept, | 533 | .accept = sock_no_accept, |
534 | .getname = unix_getname, | 534 | .getname = unix_getname, |
535 | .poll = unix_datagram_poll, | 535 | .poll = unix_dgram_poll, |
536 | .ioctl = unix_ioctl, | 536 | .ioctl = unix_ioctl, |
537 | .listen = sock_no_listen, | 537 | .listen = sock_no_listen, |
538 | .shutdown = unix_shutdown, | 538 | .shutdown = unix_shutdown, |
@@ -553,7 +553,7 @@ static const struct proto_ops unix_seqpacket_ops = { | |||
553 | .socketpair = unix_socketpair, | 553 | .socketpair = unix_socketpair, |
554 | .accept = unix_accept, | 554 | .accept = unix_accept, |
555 | .getname = unix_getname, | 555 | .getname = unix_getname, |
556 | .poll = unix_datagram_poll, | 556 | .poll = unix_dgram_poll, |
557 | .ioctl = unix_ioctl, | 557 | .ioctl = unix_ioctl, |
558 | .listen = unix_listen, | 558 | .listen = unix_listen, |
559 | .shutdown = unix_shutdown, | 559 | .shutdown = unix_shutdown, |
@@ -1992,29 +1992,13 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl | |||
1992 | return mask; | 1992 | return mask; |
1993 | } | 1993 | } |
1994 | 1994 | ||
1995 | static unsigned int unix_datagram_poll(struct file *file, struct socket *sock, | 1995 | static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, |
1996 | poll_table *wait) | 1996 | poll_table *wait) |
1997 | { | 1997 | { |
1998 | struct sock *sk = sock->sk, *peer; | 1998 | struct sock *sk = sock->sk, *other; |
1999 | unsigned int mask; | 1999 | unsigned int mask, writable; |
2000 | 2000 | ||
2001 | poll_wait(file, sk->sk_sleep, wait); | 2001 | poll_wait(file, sk->sk_sleep, wait); |
2002 | |||
2003 | peer = unix_peer_get(sk); | ||
2004 | if (peer) { | ||
2005 | if (peer != sk) { | ||
2006 | /* | ||
2007 | * Writability of a connected socket additionally | ||
2008 | * depends on the state of the receive queue of the | ||
2009 | * peer. | ||
2010 | */ | ||
2011 | poll_wait(file, &unix_sk(peer)->peer_wait, wait); | ||
2012 | } else { | ||
2013 | sock_put(peer); | ||
2014 | peer = NULL; | ||
2015 | } | ||
2016 | } | ||
2017 | |||
2018 | mask = 0; | 2002 | mask = 0; |
2019 | 2003 | ||
2020 | /* exceptional events? */ | 2004 | /* exceptional events? */ |
@@ -2040,14 +2024,26 @@ static unsigned int unix_datagram_poll(struct file *file, struct socket *sock, | |||
2040 | } | 2024 | } |
2041 | 2025 | ||
2042 | /* writable? */ | 2026 | /* writable? */ |
2043 | if (unix_writable(sk) && !(peer && unix_recvq_full(peer))) | 2027 | writable = unix_writable(sk); |
2028 | if (writable) { | ||
2029 | other = unix_peer_get(sk); | ||
2030 | if (other) { | ||
2031 | if (unix_peer(other) != sk) { | ||
2032 | poll_wait(file, &unix_sk(other)->peer_wait, | ||
2033 | wait); | ||
2034 | if (unix_recvq_full(other)) | ||
2035 | writable = 0; | ||
2036 | } | ||
2037 | |||
2038 | sock_put(other); | ||
2039 | } | ||
2040 | } | ||
2041 | |||
2042 | if (writable) | ||
2044 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; | 2043 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; |
2045 | else | 2044 | else |
2046 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); | 2045 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); |
2047 | 2046 | ||
2048 | if (peer) | ||
2049 | sock_put(peer); | ||
2050 | |||
2051 | return mask; | 2047 | return mask; |
2052 | } | 2048 | } |
2053 | 2049 | ||