diff options
-rw-r--r-- | include/linux/completion.h | 1 | ||||
-rw-r--r-- | kernel/sched.c | 15 |
2 files changed, 14 insertions, 2 deletions
diff --git a/include/linux/completion.h b/include/linux/completion.h index 33d6aaf94447..d2961b66d53d 100644 --- a/include/linux/completion.h +++ b/include/linux/completion.h | |||
@@ -44,6 +44,7 @@ static inline void init_completion(struct completion *x) | |||
44 | 44 | ||
45 | extern void wait_for_completion(struct completion *); | 45 | extern void wait_for_completion(struct completion *); |
46 | extern int wait_for_completion_interruptible(struct completion *x); | 46 | extern int wait_for_completion_interruptible(struct completion *x); |
47 | extern int wait_for_completion_killable(struct completion *x); | ||
47 | extern unsigned long wait_for_completion_timeout(struct completion *x, | 48 | extern unsigned long wait_for_completion_timeout(struct completion *x, |
48 | unsigned long timeout); | 49 | unsigned long timeout); |
49 | extern unsigned long wait_for_completion_interruptible_timeout( | 50 | extern unsigned long wait_for_completion_interruptible_timeout( |
diff --git a/kernel/sched.c b/kernel/sched.c index 50a0faae585f..d2f77fab0f46 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -3881,8 +3881,10 @@ do_wait_for_common(struct completion *x, long timeout, int state) | |||
3881 | wait.flags |= WQ_FLAG_EXCLUSIVE; | 3881 | wait.flags |= WQ_FLAG_EXCLUSIVE; |
3882 | __add_wait_queue_tail(&x->wait, &wait); | 3882 | __add_wait_queue_tail(&x->wait, &wait); |
3883 | do { | 3883 | do { |
3884 | if (state == TASK_INTERRUPTIBLE && | 3884 | if ((state == TASK_INTERRUPTIBLE && |
3885 | signal_pending(current)) { | 3885 | signal_pending(current)) || |
3886 | (state == TASK_KILLABLE && | ||
3887 | fatal_signal_pending(current))) { | ||
3886 | __remove_wait_queue(&x->wait, &wait); | 3888 | __remove_wait_queue(&x->wait, &wait); |
3887 | return -ERESTARTSYS; | 3889 | return -ERESTARTSYS; |
3888 | } | 3890 | } |
@@ -3942,6 +3944,15 @@ wait_for_completion_interruptible_timeout(struct completion *x, | |||
3942 | } | 3944 | } |
3943 | EXPORT_SYMBOL(wait_for_completion_interruptible_timeout); | 3945 | EXPORT_SYMBOL(wait_for_completion_interruptible_timeout); |
3944 | 3946 | ||
3947 | int __sched wait_for_completion_killable(struct completion *x) | ||
3948 | { | ||
3949 | long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE); | ||
3950 | if (t == -ERESTARTSYS) | ||
3951 | return t; | ||
3952 | return 0; | ||
3953 | } | ||
3954 | EXPORT_SYMBOL(wait_for_completion_killable); | ||
3955 | |||
3945 | static long __sched | 3956 | static long __sched |
3946 | sleep_on_common(wait_queue_head_t *q, int state, long timeout) | 3957 | sleep_on_common(wait_queue_head_t *q, int state, long timeout) |
3947 | { | 3958 | { |