]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Add wait_for_completion_killable
authorMatthew Wilcox <matthew@wil.cx>
Thu, 6 Dec 2007 17:29:54 +0000 (12:29 -0500)
committerMatthew Wilcox <willy@linux.intel.com>
Thu, 6 Dec 2007 22:40:19 +0000 (17:40 -0500)
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
include/linux/completion.h
kernel/sched.c

index 33d6aaf944472db15ec205cc2624c2074338e2b0..d2961b66d53dbab52a3f69cd30a441725c4000ee 100644 (file)
@@ -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(
index 50a0faae585fa7cd169fd2e0f19d2eb3d977524f..d2f77fab0f4621a68b2b8bb95558bf146b40cec7 100644 (file)
@@ -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)
 {