]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_dahdi: CLI "core stop gracefully" has needless delay for PRI and SS7.
authorRichard Mudgett <rmudgett@digium.com>
Wed, 25 Sep 2013 20:28:29 +0000 (20:28 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 25 Sep 2013 20:28:29 +0000 (20:28 +0000)
The PRI and SS7 link control threads are not stopped correctly when the
chan_dahdi.so module is unloaded.  The link control threads pri_dchannel()
and ss7_linkset() are not awakened from a poll() to cancel the thread.

* Added a SIGURG signal after requesting the thread cancel to break the
link control thread poll() immediately.

For SS7 it was slightly worse, the link poll() timeout would always be
whatever was the last libss7 scheduled event time used.  If no libss7
scheduled event was pending, the thread could run more often than
necessary.

* Set nextms to 60 seconds for the ss7_linkset() poll() if there is no
other libss7 scheduled event.
........

Merged revisions 399818 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@399834 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/sig_ss7.c

index 9159118410973113231e3eab7f6bc4fa066dfc51..98e2b15bd3f2f594537180aec7c7b739daaa208c 100644 (file)
@@ -17065,8 +17065,10 @@ static int __unload_module(void)
 
 #ifdef HAVE_PRI
        for (i = 0; i < NUM_SPANS; i++) {
-               if (pris[i].pri.master != AST_PTHREADT_NULL)
+               if (pris[i].pri.master != AST_PTHREADT_NULL) {
                        pthread_cancel(pris[i].pri.master);
+                       pthread_kill(pris[i].pri.master, SIGURG);
+               }
        }
        ast_cli_unregister_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli));
        ast_unregister_application(dahdi_send_keypad_facility_app);
@@ -17076,9 +17078,11 @@ static int __unload_module(void)
 #endif
 #if defined(HAVE_SS7)
        for (i = 0; i < NUM_SPANS; i++) {
-               if (linksets[i].ss7.master != AST_PTHREADT_NULL)
+               if (linksets[i].ss7.master != AST_PTHREADT_NULL) {
                        pthread_cancel(linksets[i].ss7.master);
+                       pthread_kill(linksets[i].ss7.master, SIGURG);
                }
+       }
        ast_cli_unregister_multiple(dahdi_ss7_cli, ARRAY_LEN(dahdi_ss7_cli));
 #endif /* defined(HAVE_SS7) */
 #if defined(HAVE_OPENR2)
@@ -17122,8 +17126,9 @@ static int __unload_module(void)
 
 #if defined(HAVE_PRI)
        for (i = 0; i < NUM_SPANS; i++) {
-               if (pris[i].pri.master && (pris[i].pri.master != AST_PTHREADT_NULL))
+               if (pris[i].pri.master && (pris[i].pri.master != AST_PTHREADT_NULL)) {
                        pthread_join(pris[i].pri.master, NULL);
+               }
                for (j = 0; j < SIG_PRI_NUM_DCHANS; j++) {
                        dahdi_close_pri_fd(&(pris[i]), j);
                }
@@ -17138,8 +17143,9 @@ static int __unload_module(void)
 
 #if defined(HAVE_SS7)
        for (i = 0; i < NUM_SPANS; i++) {
-               if (linksets[i].ss7.master && (linksets[i].ss7.master != AST_PTHREADT_NULL))
+               if (linksets[i].ss7.master && (linksets[i].ss7.master != AST_PTHREADT_NULL)) {
                        pthread_join(linksets[i].ss7.master, NULL);
+               }
                for (j = 0; j < SIG_SS7_NUM_DCHANS; j++) {
                        dahdi_close_ss7_fd(&(linksets[i]), j);
                }
index baf152d4e902e38c36463ca9c185c7ee98e98fab..e6e11bed6011c61a8c4be9b109122bfbd3da2890 100644 (file)
@@ -788,7 +788,9 @@ void *ss7_linkset(void *data)
        ss7_event *e = NULL;
        struct sig_ss7_chan *p;
        struct pollfd pollers[SIG_SS7_NUM_DCHANS];
-       int nextms = 0;
+       int nextms;
+
+#define SS7_MAX_POLL   60000   /* Maximum poll time in ms. */
 
        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 
@@ -813,6 +815,11 @@ void *ss7_linkset(void *data)
                        }
                        nextms = tv.tv_sec * 1000;
                        nextms += tv.tv_usec / 1000;
+                       if (SS7_MAX_POLL < nextms) {
+                               nextms = SS7_MAX_POLL;
+                       }
+               } else {
+                       nextms = SS7_MAX_POLL;
                }
 
                for (i = 0; i < linkset->numsigchans; i++) {