[Freeswitch-svn] [commit] r6882 - freeswitch/trunk/src/mod/applications/mod_limit

Freeswitch SVN anthm at freeswitch.org
Tue Dec 18 17:06:06 EST 2007


Author: anthm
Date: Tue Dec 18 17:06:06 2007
New Revision: 6882

Modified:
   freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c

Log:
delete repeat keys in db

Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	Tue Dec 18 17:06:06 2007
@@ -425,17 +425,21 @@
     
     
     if (!strcasecmp(argv[0], "insert")) {
+        sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
+        switch_assert(sql);
+        limit_execute_sql(sql, globals.mutex);
+        switch_safe_free(sql);
+        
         sql = switch_mprintf("insert into db_data values('%q','%q','%q','%q');", globals.hostname, argv[1], argv[2], argv[3]);
     } else if (!strcasecmp(argv[0], "delete")) {
         sql = switch_mprintf("delete from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
     }
 
+    switch_assert(sql);
+    limit_execute_sql(sql, globals.mutex);
+    switch_safe_free(sql);
+    return;
 
-    if (sql) {
-        limit_execute_sql(sql, globals.mutex);
-        switch_safe_free(sql);
-        return;
-    }
     
  error:
     switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "USAGE: db %s\n", DB_USAGE);
@@ -470,6 +474,7 @@
         }
         sql = switch_mprintf("delete from group_data where groupname='%q' and url='%q';", argv[1], argv[2]);
         assert(sql);
+
         limit_execute_sql(sql, NULL);
         switch_safe_free(sql);
         sql = switch_mprintf("insert into group_data values('%q','%q','%q');", globals.hostname, argv[1], argv[2]);



More information about the Freeswitch-svn mailing list