Make SLA reload more paranoid.
[asterisk/asterisk.git] / apps / app_meetme.c
index 0ff035a..def1e74 100644 (file)
@@ -6447,8 +6447,8 @@ static void sla_check_reload(void)
        struct sla_station *station;
        struct sla_trunk *trunk;
 
-       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)) {
                return;
        }
 
@@ -6464,8 +6464,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) {
@@ -6718,7 +6719,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);
@@ -6930,7 +6931,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);