]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5832 additional hostname updates for failover behavior
authorNathan Neulinger <nneul@neulinger.org>
Wed, 2 Oct 2013 17:24:34 +0000 (12:24 -0500)
committerNathan Neulinger <nneul@neulinger.org>
Wed, 2 Oct 2013 17:24:34 +0000 (12:24 -0500)
src/switch_console.c
src/switch_core_sqldb.c

index 1f34d1342841eb67a2b5018538f6a0bfb44e19c5..63fe5758566f17d129390656c29568d0e2b8c5f7 100644 (file)
@@ -1882,7 +1882,8 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
                        } else if (!strcasecmp(argv[0], "del")) {
                                char *what = argv[1];
                                if (!strcasecmp(what, "*")) {
-                                       switch_core_sql_exec("delete from complete");
+                                       mystream.write_function(&mystream, "delete from complete where hostname='%s'", switch_core_get_hostname());
+                                       switch_core_sql_exec(mystream.data);
                                } else {
                                        mystream.write_function(&mystream, "delete from complete where ");
                                        for (x = 0; x < argc - 1; x++) {
index afae37872a179bb4979756a9fa9f39175d66c88d..a9c8d22fbc3ba695c28722a354432d82d885e452 100644 (file)
@@ -2317,7 +2317,7 @@ static void core_event_handler(switch_event_t *event)
                new_sql() = switch_mprintf("delete from channels where hostname='%q';"
                                                                   "delete from interfaces where hostname='%q';"
                                                                   "delete from calls where hostname='%q'",
-                                                                  switch_core_get_switchname(), switch_core_get_switchname(), switch_core_get_switchname()
+                                                                  switch_core_get_switchname(), switch_core_get_hostname(), switch_core_get_switchname()
                                                                   );
                break;
        case SWITCH_EVENT_LOG:
@@ -3106,7 +3106,7 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
        case SCDB_TYPE_ODBC:
                if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {
                        char sql[512] = "";
-                       char *tables[] = { "channels", "calls", "interfaces", "tasks", NULL };
+                       char *tables[] = { "channels", "calls", "tasks", NULL };
                        int i;
                        const char *hostname = switch_core_get_switchname();
 
@@ -3265,8 +3265,18 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
                break;
        }
 
+       if (switch_test_flag((&runtime), SCF_CLEAR_SQL)) {
+               char sql[512] = "";
+               char *tables[] = { "complete", "interfaces", NULL };
+               int i;
+               const char *hostname = switch_core_get_hostname();
+
+               for (i = 0; tables[i]; i++) {
+                       switch_snprintfv(sql, sizeof(sql), "delete from %q where hostname='%q'", tables[i], hostname);
+                       switch_cache_db_execute_sql(sql_manager.dbh, sql, NULL);
+               }
+       }
 
-       switch_cache_db_execute_sql(sql_manager.dbh, "delete from complete where sticky=0", NULL);
        switch_cache_db_execute_sql(sql_manager.dbh, "delete from aliases where sticky=0", NULL);
        switch_cache_db_execute_sql(sql_manager.dbh, "delete from nat where sticky=0", NULL);
        switch_cache_db_execute_sql(sql_manager.dbh, "create index alias1 on aliases (alias)", NULL);