]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5019 --resolve I would rather have this fix in the core... But in the mean this...
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Fri, 18 Jan 2013 05:06:05 +0000 (00:06 -0500)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Fri, 18 Jan 2013 05:06:05 +0000 (00:06 -0500)
src/mod/applications/mod_directory/mod_directory.c

index 4e4f6d7c279c32fe9368b18aa0e3d0ad0f5b7e7e..fd9457cbe7278df9a6446d32a5781b7dbd65dbec 100644 (file)
@@ -531,6 +531,7 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro
        char *sql = NULL;
        char *sqlvalues = NULL;
        char *sqltmp = NULL;
+       int count = 0;
 
        switch_xml_t xml_root = NULL, x_domain;
        switch_xml_t ut;
@@ -633,13 +634,22 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro
                                        switch_safe_free(fullNameDigit);
                                        switch_safe_free(lastNameDigit);
                                        switch_safe_free(firstNameDigit);
+                                       
+                                       if (++count >= 100) {
+                                               count = 0;
+                                               sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
+                                               directory_execute_sql(sql, globals.mutex);
+                                               switch_safe_free(sql);
+                                               switch_safe_free(sqlvalues);
+                                       }
                                }
                        }
                }
        }
-       sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
-       directory_execute_sql(sql, globals.mutex);
-
+       if (sqlvalues) {
+               sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
+               directory_execute_sql(sql, globals.mutex);
+       }
   end:
        switch_safe_free(sql);
        switch_safe_free(sqlvalues);