Whamcloud - gitweb
b=20722 Fix watchdog timer messages to be more clear.
[fs/lustre-release.git] / libcfs / libcfs / user-lock.c
index 1f392f6..0a3471a 100644 (file)
@@ -147,6 +147,20 @@ void __up(struct semaphore *s)
  * - wait_for_completion(c)
  */
 
+static cfs_wait_handler_t wait_handler;
+
+void init_completion_module(cfs_wait_handler_t handler)
+{
+        wait_handler = handler;
+}
+
+int call_wait_handler(int timeout)
+{
+        if (!wait_handler)
+                return -ENOSYS;
+        return wait_handler(timeout);
+}
+
 void init_completion(struct completion *c)
 {
         LASSERT(c != NULL);
@@ -164,11 +178,19 @@ void complete(struct completion *c)
 void wait_for_completion(struct completion *c)
 {
         LASSERT(c != NULL);
+        do {
+                if (call_wait_handler(1000) < 0)
+                        break;
+        } while (c->done == 0);
 }
 
 int wait_for_completion_interruptible(struct completion *c)
 {
         LASSERT(c != NULL);
+        do {
+                if (call_wait_handler(1000) < 0)
+                        break;
+        } while (c->done == 0);
         return 0;
 }
 
@@ -227,6 +249,12 @@ void up_write(struct rw_semaphore *s)
         (void)s;
 }
 
+void fini_rwsem(struct rw_semaphore *s)
+{
+        LASSERT(s != NULL);
+        (void)s;
+}
+
 #ifdef HAVE_LIBPTHREAD
 
 /*