aboutsummaryrefslogtreecommitdiffstats
path: root/net/unix/af_unix.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-07-25 05:37:07 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-25 05:37:07 -0400
commit0e2f65ee30eee2db054f7fd73f462c5da33ec963 (patch)
tree26c61eb7745da0c0d9135e9d12088f570cb8530d /net/unix/af_unix.c
parentda7878d75b8520c9ae00d27dfbbce546a7bfdfbb (diff)
parentfb2e405fc1fc8b20d9c78eaa1c7fd5a297efde43 (diff)
Merge branch 'linus' into x86/pebs
Conflicts: arch/x86/Kconfig.cpu arch/x86/kernel/cpu/intel.c arch/x86/kernel/setup_64.c Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'net/unix/af_unix.c')
-rw-r--r--net/unix/af_unix.c54
1 files changed, 24 insertions, 30 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 657835f227d3..70ceb1604ad8 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -8,8 +8,6 @@
8 * as published by the Free Software Foundation; either version 8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version. 9 * 2 of the License, or (at your option) any later version.
10 * 10 *
11 * Version: $Id: af_unix.c,v 1.133 2002/02/08 03:57:19 davem Exp $
12 *
13 * Fixes: 11 * Fixes:
14 * Linus Torvalds : Assorted bug cures. 12 * Linus Torvalds : Assorted bug cures.
15 * Niibe Yutaka : async I/O support. 13 * Niibe Yutaka : async I/O support.
@@ -487,8 +485,8 @@ static int unix_socketpair(struct socket *, struct socket *);
487static int unix_accept(struct socket *, struct socket *, int); 485static int unix_accept(struct socket *, struct socket *, int);
488static int unix_getname(struct socket *, struct sockaddr *, int *, int); 486static int unix_getname(struct socket *, struct sockaddr *, int *, int);
489static unsigned int unix_poll(struct file *, struct socket *, poll_table *); 487static unsigned int unix_poll(struct file *, struct socket *, poll_table *);
490static unsigned int unix_datagram_poll(struct file *, struct socket *, 488static unsigned int unix_dgram_poll(struct file *, struct socket *,
491 poll_table *); 489 poll_table *);
492static int unix_ioctl(struct socket *, unsigned int, unsigned long); 490static int unix_ioctl(struct socket *, unsigned int, unsigned long);
493static int unix_shutdown(struct socket *, int); 491static int unix_shutdown(struct socket *, int);
494static int unix_stream_sendmsg(struct kiocb *, struct socket *, 492static int unix_stream_sendmsg(struct kiocb *, struct socket *,
@@ -534,7 +532,7 @@ static const struct proto_ops unix_dgram_ops = {
534 .socketpair = unix_socketpair, 532 .socketpair = unix_socketpair,
535 .accept = sock_no_accept, 533 .accept = sock_no_accept,
536 .getname = unix_getname, 534 .getname = unix_getname,
537 .poll = unix_datagram_poll, 535 .poll = unix_dgram_poll,
538 .ioctl = unix_ioctl, 536 .ioctl = unix_ioctl,
539 .listen = sock_no_listen, 537 .listen = sock_no_listen,
540 .shutdown = unix_shutdown, 538 .shutdown = unix_shutdown,
@@ -555,7 +553,7 @@ static const struct proto_ops unix_seqpacket_ops = {
555 .socketpair = unix_socketpair, 553 .socketpair = unix_socketpair,
556 .accept = unix_accept, 554 .accept = unix_accept,
557 .getname = unix_getname, 555 .getname = unix_getname,
558 .poll = unix_datagram_poll, 556 .poll = unix_dgram_poll,
559 .ioctl = unix_ioctl, 557 .ioctl = unix_ioctl,
560 .listen = unix_listen, 558 .listen = unix_listen,
561 .shutdown = unix_shutdown, 559 .shutdown = unix_shutdown,
@@ -1994,29 +1992,13 @@ static unsigned int unix_poll(struct file * file, struct socket *sock, poll_tabl
1994 return mask; 1992 return mask;
1995} 1993}
1996 1994
1997static unsigned int unix_datagram_poll(struct file *file, struct socket *sock, 1995static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
1998 poll_table *wait) 1996 poll_table *wait)
1999{ 1997{
2000 struct sock *sk = sock->sk, *peer; 1998 struct sock *sk = sock->sk, *other;
2001 unsigned int mask; 1999 unsigned int mask, writable;
2002 2000
2003 poll_wait(file, sk->sk_sleep, wait); 2001 poll_wait(file, sk->sk_sleep, wait);
2004
2005 peer = unix_peer_get(sk);
2006 if (peer) {
2007 if (peer != sk) {
2008 /*
2009 * Writability of a connected socket additionally
2010 * depends on the state of the receive queue of the
2011 * peer.
2012 */
2013 poll_wait(file, &unix_sk(peer)->peer_wait, wait);
2014 } else {
2015 sock_put(peer);
2016 peer = NULL;
2017 }
2018 }
2019
2020 mask = 0; 2002 mask = 0;
2021 2003
2022 /* exceptional events? */ 2004 /* exceptional events? */
@@ -2042,14 +2024,26 @@ static unsigned int unix_datagram_poll(struct file *file, struct socket *sock,
2042 } 2024 }
2043 2025
2044 /* writable? */ 2026 /* writable? */
2045 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)
2046 mask |= POLLOUT | POLLWRNORM | POLLWRBAND; 2043 mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
2047 else 2044 else
2048 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); 2045 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
2049 2046
2050 if (peer)
2051 sock_put(peer);
2052
2053 return mask; 2047 return mask;
2054} 2048}
2055 2049