diff options
-rw-r--r-- | include/linux/wait.h | 6 | ||||
-rw-r--r-- | net/core/datagram.c | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/include/linux/wait.h b/include/linux/wait.h index 5d631c17eaee..bc024632f365 100644 --- a/include/linux/wait.h +++ b/include/linux/wait.h | |||
@@ -440,13 +440,15 @@ void abort_exclusive_wait(wait_queue_head_t *q, wait_queue_t *wait, | |||
440 | int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key); | 440 | int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key); |
441 | int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key); | 441 | int wake_bit_function(wait_queue_t *wait, unsigned mode, int sync, void *key); |
442 | 442 | ||
443 | #define DEFINE_WAIT(name) \ | 443 | #define DEFINE_WAIT_FUNC(name, function) \ |
444 | wait_queue_t name = { \ | 444 | wait_queue_t name = { \ |
445 | .private = current, \ | 445 | .private = current, \ |
446 | .func = autoremove_wake_function, \ | 446 | .func = function, \ |
447 | .task_list = LIST_HEAD_INIT((name).task_list), \ | 447 | .task_list = LIST_HEAD_INIT((name).task_list), \ |
448 | } | 448 | } |
449 | 449 | ||
450 | #define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function) | ||
451 | |||
450 | #define DEFINE_WAIT_BIT(name, word, bit) \ | 452 | #define DEFINE_WAIT_BIT(name, word, bit) \ |
451 | struct wait_bit_queue name = { \ | 453 | struct wait_bit_queue name = { \ |
452 | .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \ | 454 | .key = __WAIT_BIT_KEY_INITIALIZER(word, bit), \ |
diff --git a/net/core/datagram.c b/net/core/datagram.c index d0de644b378d..b01a76abe1d2 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -64,13 +64,25 @@ static inline int connection_based(struct sock *sk) | |||
64 | return sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM; | 64 | return sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM; |
65 | } | 65 | } |
66 | 66 | ||
67 | static int receiver_wake_function(wait_queue_t *wait, unsigned mode, int sync, | ||
68 | void *key) | ||
69 | { | ||
70 | unsigned long bits = (unsigned long)key; | ||
71 | |||
72 | /* | ||
73 | * Avoid a wakeup if event not interesting for us | ||
74 | */ | ||
75 | if (bits && !(bits & (POLLIN | POLLERR))) | ||
76 | return 0; | ||
77 | return autoremove_wake_function(wait, mode, sync, key); | ||
78 | } | ||
67 | /* | 79 | /* |
68 | * Wait for a packet.. | 80 | * Wait for a packet.. |
69 | */ | 81 | */ |
70 | static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) | 82 | static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) |
71 | { | 83 | { |
72 | int error; | 84 | int error; |
73 | DEFINE_WAIT(wait); | 85 | DEFINE_WAIT_FUNC(wait, receiver_wake_function); |
74 | 86 | ||
75 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | 87 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
76 | 88 | ||