Module: sems
Branch: master
Commit: 1b9b6f2bbc90a20fc581f4c31969c10bac0a1beb
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=1b9b6f2bbc90a20fc581f4c31969c10bac0a1beb

Author: Stefan Sayer <[email protected]>
Committer: Stefan Sayer <[email protected]>
Date:   Tue Jun 14 17:16:56 2011 +0200

b/f: deadlock on timer too far in the future

---

 apps/db_reg_agent/RegistrationTimer.cpp |   13 +++++++++++--
 apps/db_reg_agent/RegistrationTimer.h   |    4 ++--
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/apps/db_reg_agent/RegistrationTimer.cpp 
b/apps/db_reg_agent/RegistrationTimer.cpp
index e8f9b9e..ced6a31 100644
--- a/apps/db_reg_agent/RegistrationTimer.cpp
+++ b/apps/db_reg_agent/RegistrationTimer.cpp
@@ -45,8 +45,11 @@ int RegistrationTimer::get_bucket_index(time_t tv) {
   int bucket_index =  (tv - buckets_start_time);
   bucket_index /= TIMER_BUCKET_LENGTH;
   
-  if (bucket_index > TIMER_BUCKETS) // too far in the future
+  if (bucket_index > TIMER_BUCKETS) { // too far in the future
+    ERROR("requested timer too far in the future (index %d vs %d 
TIMER_BUCKETS)\n",
+         bucket_index, TIMER_BUCKETS);
     return -2;
+  }
 
   bucket_index += current_bucket;
   bucket_index %= TIMER_BUCKETS; // circular array
@@ -225,8 +228,14 @@ bool RegistrationTimer::insert_timer_leastloaded(RegTimer* 
timer,
   int from_index = get_bucket_index(from_time);
   int to_index = get_bucket_index(to_time);
 
-  if (from_index < 0 && to_index < 0)
+  if (from_index < 0 && to_index < 0) {
+    ERROR("could not find timer bucket indices - "
+         "from_index = %d, to_index = %d, from_time = %ld, to_time %ld, "
+         "current_bucket_start = %ld\n",
+         from_index, to_index, from_time, to_time, current_bucket_start);
+    buckets_mut.unlock();
     return false;
+  }
 
   int res_index = from_index;
   if (from_index < 0) {
diff --git a/apps/db_reg_agent/RegistrationTimer.h 
b/apps/db_reg_agent/RegistrationTimer.h
index 1a8aa6b..14e2b9a 100644
--- a/apps/db_reg_agent/RegistrationTimer.h
+++ b/apps/db_reg_agent/RegistrationTimer.h
@@ -34,8 +34,8 @@
 #include "log.h"
 #include "AmThread.h"
 
-#define TIMER_BUCKET_LENGTH 10    // 10 sec
-#define TIMER_BUCKETS       1000  // 1000 buckets
+#define TIMER_BUCKET_LENGTH 10     // 10 sec
+#define TIMER_BUCKETS       40000  // 40000 buckets (400000 sec, 111 hrs)
 
 // 100 ms == 100000 us
 #define TIMER_RESOLUTION 100000

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to