Skip to content

Commit

Permalink
Add wait_for_completion_killable
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
  • Loading branch information
Matthew Wilcox authored and Matthew Wilcox committed Dec 6, 2007
1 parent 1411d5a commit 009e577
Showing 2 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/linux/completion.h
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ static inline void init_completion(struct completion *x)

extern void wait_for_completion(struct completion *);
extern int wait_for_completion_interruptible(struct completion *x);
extern int wait_for_completion_killable(struct completion *x);
extern unsigned long wait_for_completion_timeout(struct completion *x,
unsigned long timeout);
extern unsigned long wait_for_completion_interruptible_timeout(
15 changes: 13 additions & 2 deletions kernel/sched.c
Original file line number Diff line number Diff line change
@@ -3881,8 +3881,10 @@ do_wait_for_common(struct completion *x, long timeout, int state)
wait.flags |= WQ_FLAG_EXCLUSIVE;
__add_wait_queue_tail(&x->wait, &wait);
do {
if (state == TASK_INTERRUPTIBLE &&
signal_pending(current)) {
if ((state == TASK_INTERRUPTIBLE &&
signal_pending(current)) ||
(state == TASK_KILLABLE &&
fatal_signal_pending(current))) {
__remove_wait_queue(&x->wait, &wait);
return -ERESTARTSYS;
}
@@ -3942,6 +3944,15 @@ wait_for_completion_interruptible_timeout(struct completion *x,
}
EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);

int __sched wait_for_completion_killable(struct completion *x)
{
long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
if (t == -ERESTARTSYS)
return t;
return 0;
}
EXPORT_SYMBOL(wait_for_completion_killable);

static long __sched
sleep_on_common(wait_queue_head_t *q, int state, long timeout)
{

0 comments on commit 009e577

Please sign in to comment.