summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2009-08-04 16:24:24 +0000
committerShaun Ruffell <sruffell@digium.com>2009-08-04 16:24:24 +0000
commit9339d5cce9593fcc4ce7a4297735cd8a787a00dc (patch)
tree39fe812e35275314225a1168c7b6ee03430d5087
parent75ff751f904456c4e92991e005c06307b88c886c (diff)
Merged revisions 6933 via svnmerge from
https://origsvn.digium.com/svn/dahdi/linux/trunk ........ r6933 | sruffell | 2009-08-04 11:22:39 -0500 (Tue, 04 Aug 2009) | 10 lines dahdi_dummy: Do not allow jumps in system time to lock up the system. Since dahdi_dummy uses the number of milliseconds that has actually passed to determine how many times to call dahdi_receive, it is possible that if the system time shifts after dahdi is started, that the system can appear to lock up while dahdi_dummy attempts to catch up. This change prevents soft lock ups under these conditions. (closes issue #15647) Reported by: missnebun ........ git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.2@6934 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/dahdi_dummy.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/dahdi/dahdi_dummy.c b/drivers/dahdi/dahdi_dummy.c
index 97949e3..590cc9b 100644
--- a/drivers/dahdi/dahdi_dummy.c
+++ b/drivers/dahdi/dahdi_dummy.c
@@ -161,12 +161,31 @@ static void dahdi_dummy_timer(unsigned long param)
unsigned long ms_since_start;
struct timespec now;
const unsigned long MAX_INTERVAL = 100000L;
+ const unsigned long MS_LIMIT = 3000;
if (!atomic_read(&shutdown))
mod_timer(&timer, jiffies + JIFFIES_INTERVAL);
now = current_kernel_time();
ms_since_start = timespec_diff_ms(&ztd->start_interval, &now);
+
+ /*
+ * If the system time has changed, it is possible for us to be far
+ * behind. If we are more than MS_LIMIT milliseconds behind, just
+ * reset our time base and continue so that we do not hang the system
+ * here.
+ *
+ */
+ if (unlikely((ms_since_start - ztd->calls_since_start) > MS_LIMIT)) {
+ if (printk_ratelimit()) {
+ printk(KERN_INFO
+ "dahdi_dummy: Detected time shift.\n");
+ }
+ ztd->calls_since_start = 0;
+ ztd->start_interval = now;
+ return;
+ }
+
while (ms_since_start > ztd->calls_since_start) {
ztd->calls_since_start++;
dahdi_receive(&ztd->span);