From e5be942c842fc22c1c752da6ec68a45d91f37c0e Mon Sep 17 00:00:00 2001
From: Marcus Brinkmann <marcus@gnu.org>
Date: Sun, 14 Oct 2001 23:33:38 +0000
Subject: 2001-10-14  Marcus Brinkmann  <marcus@gnu.org>

	* glue-include/linux/sched.h (process_schedule_timeout): New
	function used as timer callback for schedule_timeout.
	(schedule_timeout): Implement it.
---
 pfinet/glue-include/linux/sched.h | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

(limited to 'pfinet/glue-include/linux')

diff --git a/pfinet/glue-include/linux/sched.h b/pfinet/glue-include/linux/sched.h
index 897a2df0..f57de2c3 100644
--- a/pfinet/glue-include/linux/sched.h
+++ b/pfinet/glue-include/linux/sched.h
@@ -149,11 +149,38 @@ schedule (void)
   interruptible_sleep_on (current->next_wait);
 }
 
+static inline void
+process_schedule_timeout (unsigned long data)
+{
+  struct wait_queue **sleep = (struct wait_queue **) data;
+
+  wake_up_interruptible (sleep);
+}
+
 static inline long
 schedule_timeout (long timeout)
 {
-  /* XXX this is only ever called to do SO_LINGER, which we don't support */
-  assert (!"schedule_timeout");
+  long expire = timeout + jiffies;
+  struct timer_list timer;
+  struct wait_queue *sleep = 0;  /* See comment in wait.h why this suffices.  */
+
+  init_timer (&timer);
+  timer.expires = expire;
+  timer.data = (unsigned long) &sleep;
+  timer.function = process_schedule_timeout;
+  add_timer (&timer);
+
+  interruptible_sleep_on (&sleep);
+  if (signal_pending (current))
+    {
+      /* We were canceled.  */
+      del_timer (&timer);
+      expire -= jiffies;
+      if (expire >= 0)
+	return expire;
+      else
+	return 0;
+    }
   return 0;
 }
 
-- 
cgit v1.2.3