[PATCH] Fix delayed shutdown when smsbox vanishes with high MO traffic

Stipe Tolj <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Kannel Software Foundation (KSF)
Message-ID <[email protected]>
Hi list,

when having a high IO scenario, i.e. a lot of DLRs coming in from the 
upstream SMSC side, and the smsbox connection vanished, then the thread 
gw/bb_box.c:sms_to_smsboxes() is most likely in the gwthread_sleep() 
loop captured. If we SIGTERM bearerbox it will iterate one more time, 
since the bb_status hasn't reflected the fact that we're in shutdown now 
and we need to wait 1m until the bearerbox goes down.

This is unnecessary IMO, since the MO/DLRs are persistent in the store, 
and we're not accepting any smsbox connection anyway when in shutdown 
mode. So we can make sure we wakeup-all in the main() scope and test for 
the corresponding bb_status in the while loop of the thread.

Please find the corresponding patch attached. If no objections arise, 
I'll commit the patch during the end of the week.

Stipe

-- 
-------------------------------------------------------------------
Kölner Landstrasse 419
40589 DÃŒsseldorf, NRW, Germany

Kannel Foundation                 tolj.org system architecture
http://www.kannel.org/            http://www.tolj.org/

mailto:stolj_{at}_kannel.org      mailto:st_{at}_tolj.org
-------------------------------------------------------------------
sms_to_smsboxes-shutdown.diff (text/plain, 802 B)
Index: gw/bb_boxc.c
===================================================================
--- gw/bb_boxc.c	(revision 5138)
+++ gw/bb_boxc.c	(working copy)
@@ -1681,7 +1681,7 @@
 
     newmsg = startmsg = msg = NULL;
 
-    while(bb_status != BB_DEAD) {
+    while (bb_status != BB_SHUTDOWN && bb_status != BB_DEAD) {
 
         if (newmsg == startmsg) {
             /* check if we are in shutdown phase */
Index: gw/bearerbox.c
===================================================================
--- gw/bearerbox.c	(revision 5138)
+++ gw/bearerbox.c	(working copy)
@@ -789,6 +789,9 @@
     /* call shutdown */
     bb_shutdown();
 
+    /* wake up any sleeping threads */
+    gwthread_wakeup_all();
+
     /* wait until flow threads exit */
     while (gwlist_consume(flow_threads) != NULL)
         ;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.