]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add multiple-registrations flag to the core similar to mod_sofia
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Feb 2011 18:12:43 +0000 (12:12 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 17 Feb 2011 18:12:43 +0000 (12:12 -0600)
src/include/private/switch_core_pvt.h
src/switch_core.c
src/switch_core_sqldb.c

index f8c6a794b965a5313f7a48953203eea88cab31e3..ab0777ed3b864302839663342b2fb8f9c3870ac8 100644 (file)
@@ -248,6 +248,7 @@ struct switch_runtime {
        int max_sql_buffer_len;
        switch_dbtype_t odbc_dbtype;
        char hostname[256];
+       int multiple_registrations;
 };
 
 extern struct switch_runtime runtime;
index 66731b61c85c762916586aa5370557373fff3945..5479229100f9b930c0df478034cf553b540f56e1 100644 (file)
@@ -1549,6 +1549,8 @@ static void switch_load_core_config(const char *file)
                                        if (tmp > -1 && tmp < 11) {
                                                switch_core_session_ctl(SCSC_DEBUG_LEVEL, &tmp);
                                        }
+                               } else if (!strcasecmp(var, "multiple-registrations")) {
+                                       runtime.multiple_registrations = switch_true(val);
                                } else if (!strcasecmp(var, "sql-buffer-len")) {
                                        int tmp = atoi(val);
 
index f135e9586dc4b7ae89c9a96d11829854e5db9fb7..1274213893fdd560e0239e2774843f9768b65ad4 100644 (file)
@@ -1653,7 +1653,14 @@ SWITCH_DECLARE(switch_status_t) switch_core_add_registration(const char *user, c
                return SWITCH_STATUS_FALSE;
        }
 
-       sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')", switch_core_get_hostname(), url, switch_str_nil(token));
+       if (runtime.multiple_registrations) {
+               sql = switch_mprintf("delete from registrations where hostname='%q' and (url='%q' or token='%q')", 
+                                                        switch_core_get_hostname(), url, switch_str_nil(token));
+       } else {
+               sql = switch_mprintf("delete from registrations where reg_user='%q' and realm='%q' and hostname='%q'", 
+                                                        user, realm, switch_core_get_hostname());
+       }
+
        switch_cache_db_execute_sql(dbh, sql, NULL);
        free(sql);