diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2006-03-25 06:07:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-25 11:22:56 -0500 |
commit | f348d70a324e15afc701a494f32ec468abb7d1eb (patch) | |
tree | a4cb43429f7f08a6621c581bd99e4a03198e8c67 | |
parent | 501f2499b897ca4be68b1acc7a4bc8cf66f5fd24 (diff) |
[PATCH] POLLRDHUP/EPOLLRDHUP handling for half-closed devices notifications
Implement the half-closed devices notifiation, by adding a new POLLRDHUP
(and its alias EPOLLRDHUP) bit to the existing poll/select sets. Since the
existing POLLHUP handling, that does not report correctly half-closed
devices, was feared to be changed, this implementation leaves the current
POLLHUP reporting unchanged and simply add a new bit that is set in the few
places where it makes sense. The same thing was discussed and conceptually
agreed quite some time ago:
http://lkml.org/lkml/2003/7/12/116
Since this new event bit is added to the existing Linux poll infrastruture,
even the existing poll/select system calls will be able to use it. As far
as the existing POLLHUP handling, the patch leaves it as is. The
pollrdhup-2.6.16.rc5-0.10.diff defines the POLLRDHUP for all the existing
archs and sets the bit in the six relevant files. The other attached diff
is the simple change required to sys/epoll.h to add the EPOLLRDHUP
definition.
There is "a stupid program" to test POLLRDHUP delivery here:
http://www.xmailserver.org/pollrdhup-test.c
It tests poll(2), but since the delivery is same epoll(2) will work equally.
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/eventpoll.c | 4 | ||||
-rw-r--r-- | include/asm-alpha/poll.h | 2 | ||||
-rw-r--r-- | include/asm-arm/poll.h | 1 | ||||
-rw-r--r-- | include/asm-arm26/poll.h | 1 | ||||
-rw-r--r-- | include/asm-cris/poll.h | 1 | ||||
-rw-r--r-- | include/asm-frv/poll.h | 1 | ||||
-rw-r--r-- | include/asm-h8300/poll.h | 1 | ||||
-rw-r--r-- | include/asm-i386/poll.h | 1 | ||||
-rw-r--r-- | include/asm-ia64/poll.h | 1 | ||||
-rw-r--r-- | include/asm-m32r/poll.h | 1 | ||||
-rw-r--r-- | include/asm-m68k/poll.h | 1 | ||||
-rw-r--r-- | include/asm-mips/poll.h | 1 | ||||
-rw-r--r-- | include/asm-parisc/poll.h | 1 | ||||
-rw-r--r-- | include/asm-powerpc/poll.h | 1 | ||||
-rw-r--r-- | include/asm-s390/poll.h | 1 | ||||
-rw-r--r-- | include/asm-sh/poll.h | 1 | ||||
-rw-r--r-- | include/asm-sh64/poll.h | 1 | ||||
-rw-r--r-- | include/asm-sparc/poll.h | 1 | ||||
-rw-r--r-- | include/asm-sparc64/poll.h | 1 | ||||
-rw-r--r-- | include/asm-v850/poll.h | 1 | ||||
-rw-r--r-- | include/asm-x86_64/poll.h | 1 | ||||
-rw-r--r-- | include/asm-xtensa/poll.h | 1 | ||||
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 3 | ||||
-rw-r--r-- | net/core/datagram.c | 2 | ||||
-rw-r--r-- | net/dccp/proto.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp.c | 2 | ||||
-rw-r--r-- | net/sctp/socket.c | 2 | ||||
-rw-r--r-- | net/unix/af_unix.c | 2 |
28 files changed, 35 insertions, 4 deletions
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 1c2b16fda13a..a0f682cdd03e 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -599,7 +599,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event) | |||
599 | switch (op) { | 599 | switch (op) { |
600 | case EPOLL_CTL_ADD: | 600 | case EPOLL_CTL_ADD: |
601 | if (!epi) { | 601 | if (!epi) { |
602 | epds.events |= POLLERR | POLLHUP; | 602 | epds.events |= POLLERR | POLLHUP | POLLRDHUP; |
603 | 603 | ||
604 | error = ep_insert(ep, &epds, tfile, fd); | 604 | error = ep_insert(ep, &epds, tfile, fd); |
605 | } else | 605 | } else |
@@ -613,7 +613,7 @@ sys_epoll_ctl(int epfd, int op, int fd, struct epoll_event __user *event) | |||
613 | break; | 613 | break; |
614 | case EPOLL_CTL_MOD: | 614 | case EPOLL_CTL_MOD: |
615 | if (epi) { | 615 | if (epi) { |
616 | epds.events |= POLLERR | POLLHUP; | 616 | epds.events |= POLLERR | POLLHUP | POLLRDHUP; |
617 | error = ep_modify(ep, epi, &epds); | 617 | error = ep_modify(ep, epi, &epds); |
618 | } else | 618 | } else |
619 | error = -ENOENT; | 619 | error = -ENOENT; |
diff --git a/include/asm-alpha/poll.h b/include/asm-alpha/poll.h index 34f333b762a0..95707182b3ed 100644 --- a/include/asm-alpha/poll.h +++ b/include/asm-alpha/poll.h | |||
@@ -13,6 +13,8 @@ | |||
13 | #define POLLWRBAND (1 << 9) | 13 | #define POLLWRBAND (1 << 9) |
14 | #define POLLMSG (1 << 10) | 14 | #define POLLMSG (1 << 10) |
15 | #define POLLREMOVE (1 << 11) | 15 | #define POLLREMOVE (1 << 11) |
16 | #define POLLRDHUP (1 << 12) | ||
17 | |||
16 | 18 | ||
17 | struct pollfd { | 19 | struct pollfd { |
18 | int fd; | 20 | int fd; |
diff --git a/include/asm-arm/poll.h b/include/asm-arm/poll.h index 2744ca831f5d..5030b2b232a3 100644 --- a/include/asm-arm/poll.h +++ b/include/asm-arm/poll.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLREMOVE 0x1000 | 18 | #define POLLREMOVE 0x1000 |
19 | #define POLLRDHUP 0x2000 | ||
19 | 20 | ||
20 | struct pollfd { | 21 | struct pollfd { |
21 | int fd; | 22 | int fd; |
diff --git a/include/asm-arm26/poll.h b/include/asm-arm26/poll.h index fdfdab064a65..9ccb7f4190ca 100644 --- a/include/asm-arm26/poll.h +++ b/include/asm-arm26/poll.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define POLLWRNORM 0x0100 | 15 | #define POLLWRNORM 0x0100 |
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLRDHUP 0x2000 | ||
18 | 19 | ||
19 | struct pollfd { | 20 | struct pollfd { |
20 | int fd; | 21 | int fd; |
diff --git a/include/asm-cris/poll.h b/include/asm-cris/poll.h index 1c0efc3e4be7..1b25d4cf498c 100644 --- a/include/asm-cris/poll.h +++ b/include/asm-cris/poll.h | |||
@@ -15,6 +15,7 @@ | |||
15 | #define POLLWRBAND 512 | 15 | #define POLLWRBAND 512 |
16 | #define POLLMSG 1024 | 16 | #define POLLMSG 1024 |
17 | #define POLLREMOVE 4096 | 17 | #define POLLREMOVE 4096 |
18 | #define POLLRDHUP 8192 | ||
18 | 19 | ||
19 | struct pollfd { | 20 | struct pollfd { |
20 | int fd; | 21 | int fd; |
diff --git a/include/asm-frv/poll.h b/include/asm-frv/poll.h index 8cbcd60e334f..c8fe8801d075 100644 --- a/include/asm-frv/poll.h +++ b/include/asm-frv/poll.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #define POLLRDBAND 128 | 12 | #define POLLRDBAND 128 |
13 | #define POLLWRBAND 256 | 13 | #define POLLWRBAND 256 |
14 | #define POLLMSG 0x0400 | 14 | #define POLLMSG 0x0400 |
15 | #define POLLRDHUP 0x2000 | ||
15 | 16 | ||
16 | struct pollfd { | 17 | struct pollfd { |
17 | int fd; | 18 | int fd; |
diff --git a/include/asm-h8300/poll.h b/include/asm-h8300/poll.h index bf49ab8ad6da..fc52103b276a 100644 --- a/include/asm-h8300/poll.h +++ b/include/asm-h8300/poll.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #define POLLRDBAND 128 | 12 | #define POLLRDBAND 128 |
13 | #define POLLWRBAND 256 | 13 | #define POLLWRBAND 256 |
14 | #define POLLMSG 0x0400 | 14 | #define POLLMSG 0x0400 |
15 | #define POLLRDHUP 0x2000 | ||
15 | 16 | ||
16 | struct pollfd { | 17 | struct pollfd { |
17 | int fd; | 18 | int fd; |
diff --git a/include/asm-i386/poll.h b/include/asm-i386/poll.h index aecc80a15d36..2cd4929abd40 100644 --- a/include/asm-i386/poll.h +++ b/include/asm-i386/poll.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLREMOVE 0x1000 | 18 | #define POLLREMOVE 0x1000 |
19 | #define POLLRDHUP 0x2000 | ||
19 | 20 | ||
20 | struct pollfd { | 21 | struct pollfd { |
21 | int fd; | 22 | int fd; |
diff --git a/include/asm-ia64/poll.h b/include/asm-ia64/poll.h index 160258a0528d..bcaf9f140242 100644 --- a/include/asm-ia64/poll.h +++ b/include/asm-ia64/poll.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define POLLWRBAND 0x0200 | 21 | #define POLLWRBAND 0x0200 |
22 | #define POLLMSG 0x0400 | 22 | #define POLLMSG 0x0400 |
23 | #define POLLREMOVE 0x1000 | 23 | #define POLLREMOVE 0x1000 |
24 | #define POLLRDHUP 0x2000 | ||
24 | 25 | ||
25 | struct pollfd { | 26 | struct pollfd { |
26 | int fd; | 27 | int fd; |
diff --git a/include/asm-m32r/poll.h b/include/asm-m32r/poll.h index 43b7acf732d5..9e0e700e727c 100644 --- a/include/asm-m32r/poll.h +++ b/include/asm-m32r/poll.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #define POLLWRBAND 0x0200 | 21 | #define POLLWRBAND 0x0200 |
22 | #define POLLMSG 0x0400 | 22 | #define POLLMSG 0x0400 |
23 | #define POLLREMOVE 0x1000 | 23 | #define POLLREMOVE 0x1000 |
24 | #define POLLRDHUP 0x2000 | ||
24 | 25 | ||
25 | struct pollfd { | 26 | struct pollfd { |
26 | int fd; | 27 | int fd; |
diff --git a/include/asm-m68k/poll.h b/include/asm-m68k/poll.h index c4b69c4a87e1..0fb8843647f8 100644 --- a/include/asm-m68k/poll.h +++ b/include/asm-m68k/poll.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define POLLWRBAND 256 | 13 | #define POLLWRBAND 256 |
14 | #define POLLMSG 0x0400 | 14 | #define POLLMSG 0x0400 |
15 | #define POLLREMOVE 0x1000 | 15 | #define POLLREMOVE 0x1000 |
16 | #define POLLRDHUP 0x2000 | ||
16 | 17 | ||
17 | struct pollfd { | 18 | struct pollfd { |
18 | int fd; | 19 | int fd; |
diff --git a/include/asm-mips/poll.h b/include/asm-mips/poll.h index a000f1f789e3..70881f8c5c50 100644 --- a/include/asm-mips/poll.h +++ b/include/asm-mips/poll.h | |||
@@ -17,6 +17,7 @@ | |||
17 | /* These seem to be more or less nonstandard ... */ | 17 | /* These seem to be more or less nonstandard ... */ |
18 | #define POLLMSG 0x0400 | 18 | #define POLLMSG 0x0400 |
19 | #define POLLREMOVE 0x1000 | 19 | #define POLLREMOVE 0x1000 |
20 | #define POLLRDHUP 0x2000 | ||
20 | 21 | ||
21 | struct pollfd { | 22 | struct pollfd { |
22 | int fd; | 23 | int fd; |
diff --git a/include/asm-parisc/poll.h b/include/asm-parisc/poll.h index 1c1da86934cf..20e4d03c74cb 100644 --- a/include/asm-parisc/poll.h +++ b/include/asm-parisc/poll.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLREMOVE 0x1000 | 18 | #define POLLREMOVE 0x1000 |
19 | #define POLLRDHUP 0x2000 | ||
19 | 20 | ||
20 | struct pollfd { | 21 | struct pollfd { |
21 | int fd; | 22 | int fd; |
diff --git a/include/asm-powerpc/poll.h b/include/asm-powerpc/poll.h index edd2054da86b..9c7d12631033 100644 --- a/include/asm-powerpc/poll.h +++ b/include/asm-powerpc/poll.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define POLLWRBAND 0x0200 | 13 | #define POLLWRBAND 0x0200 |
14 | #define POLLMSG 0x0400 | 14 | #define POLLMSG 0x0400 |
15 | #define POLLREMOVE 0x1000 | 15 | #define POLLREMOVE 0x1000 |
16 | #define POLLRDHUP 0x2000 | ||
16 | 17 | ||
17 | struct pollfd { | 18 | struct pollfd { |
18 | int fd; | 19 | int fd; |
diff --git a/include/asm-s390/poll.h b/include/asm-s390/poll.h index e90a5ca42061..6f7f65ac7d27 100644 --- a/include/asm-s390/poll.h +++ b/include/asm-s390/poll.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #define POLLWRBAND 0x0200 | 24 | #define POLLWRBAND 0x0200 |
25 | #define POLLMSG 0x0400 | 25 | #define POLLMSG 0x0400 |
26 | #define POLLREMOVE 0x1000 | 26 | #define POLLREMOVE 0x1000 |
27 | #define POLLRDHUP 0x2000 | ||
27 | 28 | ||
28 | struct pollfd { | 29 | struct pollfd { |
29 | int fd; | 30 | int fd; |
diff --git a/include/asm-sh/poll.h b/include/asm-sh/poll.h index 52f95b9188dc..dbca9b32f4a6 100644 --- a/include/asm-sh/poll.h +++ b/include/asm-sh/poll.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLREMOVE 0x1000 | 18 | #define POLLREMOVE 0x1000 |
19 | #define POLLRDHUP 0x2000 | ||
19 | 20 | ||
20 | struct pollfd { | 21 | struct pollfd { |
21 | int fd; | 22 | int fd; |
diff --git a/include/asm-sh64/poll.h b/include/asm-sh64/poll.h index a420d14eb704..3a6cbad08d28 100644 --- a/include/asm-sh64/poll.h +++ b/include/asm-sh64/poll.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #define POLLWRNORM 0x0100 | 26 | #define POLLWRNORM 0x0100 |
27 | #define POLLWRBAND 0x0200 | 27 | #define POLLWRBAND 0x0200 |
28 | #define POLLMSG 0x0400 | 28 | #define POLLMSG 0x0400 |
29 | #define POLLRDHUP 0x2000 | ||
29 | 30 | ||
30 | struct pollfd { | 31 | struct pollfd { |
31 | int fd; | 32 | int fd; |
diff --git a/include/asm-sparc/poll.h b/include/asm-sparc/poll.h index 3ddcc6481f09..26f13fb35497 100644 --- a/include/asm-sparc/poll.h +++ b/include/asm-sparc/poll.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define POLLWRBAND 256 | 13 | #define POLLWRBAND 256 |
14 | #define POLLMSG 512 | 14 | #define POLLMSG 512 |
15 | #define POLLREMOVE 1024 | 15 | #define POLLREMOVE 1024 |
16 | #define POLLRDHUP 2048 | ||
16 | 17 | ||
17 | struct pollfd { | 18 | struct pollfd { |
18 | int fd; | 19 | int fd; |
diff --git a/include/asm-sparc64/poll.h b/include/asm-sparc64/poll.h index 31b611aa7468..ab6b0d1bb4ad 100644 --- a/include/asm-sparc64/poll.h +++ b/include/asm-sparc64/poll.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define POLLWRBAND 256 | 13 | #define POLLWRBAND 256 |
14 | #define POLLMSG 512 | 14 | #define POLLMSG 512 |
15 | #define POLLREMOVE 1024 | 15 | #define POLLREMOVE 1024 |
16 | #define POLLRDHUP 2048 | ||
16 | 17 | ||
17 | struct pollfd { | 18 | struct pollfd { |
18 | int fd; | 19 | int fd; |
diff --git a/include/asm-v850/poll.h b/include/asm-v850/poll.h index 0369562c7e15..c10176c2c28f 100644 --- a/include/asm-v850/poll.h +++ b/include/asm-v850/poll.h | |||
@@ -13,6 +13,7 @@ | |||
13 | #define POLLWRBAND 0x0100 | 13 | #define POLLWRBAND 0x0100 |
14 | #define POLLMSG 0x0400 | 14 | #define POLLMSG 0x0400 |
15 | #define POLLREMOVE 0x1000 | 15 | #define POLLREMOVE 0x1000 |
16 | #define POLLRDHUP 0x2000 | ||
16 | 17 | ||
17 | struct pollfd { | 18 | struct pollfd { |
18 | int fd; | 19 | int fd; |
diff --git a/include/asm-x86_64/poll.h b/include/asm-x86_64/poll.h index c43cbba31913..c0475a9d8bb8 100644 --- a/include/asm-x86_64/poll.h +++ b/include/asm-x86_64/poll.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #define POLLWRBAND 0x0200 | 16 | #define POLLWRBAND 0x0200 |
17 | #define POLLMSG 0x0400 | 17 | #define POLLMSG 0x0400 |
18 | #define POLLREMOVE 0x1000 | 18 | #define POLLREMOVE 0x1000 |
19 | #define POLLRDHUP 0x2000 | ||
19 | 20 | ||
20 | struct pollfd { | 21 | struct pollfd { |
21 | int fd; | 22 | int fd; |
diff --git a/include/asm-xtensa/poll.h b/include/asm-xtensa/poll.h index dffe447534e0..6fd94773e866 100644 --- a/include/asm-xtensa/poll.h +++ b/include/asm-xtensa/poll.h | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | #define POLLMSG 0x0400 | 28 | #define POLLMSG 0x0400 |
29 | #define POLLREMOVE 0x0800 | 29 | #define POLLREMOVE 0x0800 |
30 | #define POLLRDHUP 0x2000 | ||
30 | 31 | ||
31 | struct pollfd { | 32 | struct pollfd { |
32 | int fd; | 33 | int fd; |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index fb031fe9be9e..469eda0f0dfd 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -238,6 +238,9 @@ unsigned int bt_sock_poll(struct file * file, struct socket *sock, poll_table *w | |||
238 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) | 238 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
239 | mask |= POLLERR; | 239 | mask |= POLLERR; |
240 | 240 | ||
241 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
242 | mask |= POLLRDHUP; | ||
243 | |||
241 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 244 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
242 | mask |= POLLHUP; | 245 | mask |= POLLHUP; |
243 | 246 | ||
diff --git a/net/core/datagram.c b/net/core/datagram.c index b8ce6bf81188..aecddcc30401 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -500,6 +500,8 @@ unsigned int datagram_poll(struct file *file, struct socket *sock, | |||
500 | /* exceptional events? */ | 500 | /* exceptional events? */ |
501 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) | 501 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
502 | mask |= POLLERR; | 502 | mask |= POLLERR; |
503 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
504 | mask |= POLLRDHUP; | ||
503 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 505 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
504 | mask |= POLLHUP; | 506 | mask |= POLLHUP; |
505 | 507 | ||
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index d4b293e16283..1ff7328b0e17 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -350,7 +350,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock, | |||
350 | if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) | 350 | if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED) |
351 | mask |= POLLHUP; | 351 | mask |= POLLHUP; |
352 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 352 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
353 | mask |= POLLIN | POLLRDNORM; | 353 | mask |= POLLIN | POLLRDNORM | POLLRDHUP; |
354 | 354 | ||
355 | /* Connected? */ | 355 | /* Connected? */ |
356 | if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { | 356 | if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) { |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 4b0272c92d66..19ea5c0b094b 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -365,7 +365,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
365 | if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == TCP_CLOSE) | 365 | if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == TCP_CLOSE) |
366 | mask |= POLLHUP; | 366 | mask |= POLLHUP; |
367 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 367 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
368 | mask |= POLLIN | POLLRDNORM; | 368 | mask |= POLLIN | POLLRDNORM | POLLRDHUP; |
369 | 369 | ||
370 | /* Connected? */ | 370 | /* Connected? */ |
371 | if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) { | 371 | if ((1 << sk->sk_state) & ~(TCPF_SYN_SENT | TCPF_SYN_RECV)) { |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 0ea947eb6813..b6e4b89539b3 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -4894,6 +4894,8 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
4894 | /* Is there any exceptional events? */ | 4894 | /* Is there any exceptional events? */ |
4895 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) | 4895 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
4896 | mask |= POLLERR; | 4896 | mask |= POLLERR; |
4897 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
4898 | mask |= POLLRDHUP; | ||
4897 | if (sk->sk_shutdown == SHUTDOWN_MASK) | 4899 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
4898 | mask |= POLLHUP; | 4900 | mask |= POLLHUP; |
4899 | 4901 | ||
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 2b4cc2eea5b3..d901465ce013 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -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) || |