]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make SLA reload more paranoid.
authorRussell Bryant <russell@russellbryant.com>
Mon, 6 May 2013 15:55:27 +0000 (15:55 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 6 May 2013 15:55:27 +0000 (15:55 +0000)
Reload support was originally not included for SLA.  It was added later,
but in a fairly non-traditional way.  It basically sets a flag
indicating that a reload is pending, and then waits for a time where it
thinks everything SLA related is idle and unused, and *then* executes
the reload.  It does this because the reload process is destructive.  It
starts by throwing everything away and starting over.

There are a number of problems with this approach.  One of them is that
the check to see if anything in use was incomplete.  This patch makes it
more complete and thus less likely for a crash to occur during reload
processing.  However, this approach still has problems so some much more
significant reworking of this code will need to come in as a next step.

Patch credit and testing by CoreDial, LLC.
........

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

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

apps/app_meetme.c

index 88e5ba802cf8cc7a3110a0497ffae6d189779d8a..67de950a0244e63a413e16737e05001f748ee6c1 100644 (file)
@@ -6435,8 +6435,8 @@ static void sla_check_reload(void)
 
        ast_mutex_lock(&sla.lock);
 
-       if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks) 
-               || !AST_LIST_EMPTY(&sla.ringing_stations)) {
+       if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks)
+               || !AST_LIST_EMPTY(&sla.ringing_stations) || !AST_LIST_EMPTY(&sla.failed_stations)) {
                ast_mutex_unlock(&sla.lock);
                return;
        }
@@ -6454,8 +6454,9 @@ static void sla_check_reload(void)
 
        AST_RWLIST_RDLOCK(&sla_trunks);
        AST_RWLIST_TRAVERSE(&sla_trunks, trunk, entry) {
-               if (trunk->ref_count)
+               if (trunk->ref_count || trunk->chan || trunk->active_stations || trunk->hold_stations) {
                        break;
+               }
        }
        AST_RWLIST_UNLOCK(&sla_trunks);
        if (trunk) {
@@ -6711,7 +6712,7 @@ static int sla_station_exec(struct ast_channel *chan, const char *data)
                return 0;
        }
 
-       AST_RWLIST_RDLOCK(&sla_stations);
+       AST_RWLIST_WRLOCK(&sla_stations);
        station = sla_find_station(station_name);
        if (station)
                ast_atomic_fetchadd_int((int *) &station->ref_count, 1);
@@ -6923,7 +6924,7 @@ static int sla_trunk_exec(struct ast_channel *chan, const char *data)
                }
        }
 
-       AST_RWLIST_RDLOCK(&sla_trunks);
+       AST_RWLIST_WRLOCK(&sla_trunks);
        trunk = sla_find_trunk(args.trunk_name);
        if (trunk)
                ast_atomic_fetchadd_int((int *) &trunk->ref_count, 1);