]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
lot of event can cause api timeout FS-3347
authorTamas Cseke <tamas.cseke@virtual-call-center.eu>
Mon, 10 Mar 2014 10:44:56 +0000 (11:44 +0100)
committerTamas Cseke <tamas.cseke@virtual-call-center.eu>
Mon, 10 Mar 2014 10:44:56 +0000 (11:44 +0100)
make event and log bulk configurable

src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h

index 12c5fe2b4813aad58f112bb96229da2ea3b99f62..d211fc7e7ab626f9852ed301379c8b22d499c4a1 100644 (file)
@@ -755,7 +755,7 @@ static int check_log_queue(listener_t *listener)
 
        /* send out any pending crap in the log queue */
        if (switch_test_flag(listener, LFLAG_LOG)) {
-               while (msgs_sent < 100 && switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+               while (msgs_sent < prefs.max_log_bulk && switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
                        switch_log_node_t *dnode = (switch_log_node_t *) pop;
 
                        if (dnode->data) {
@@ -817,7 +817,7 @@ static int check_event_queue(listener_t *listener)
 
        /* send out any pending crap in the event queue */
        if (switch_test_flag(listener, LFLAG_EVENTS)) {
-               while (msgs_sent < 100 && switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+               while (msgs_sent < prefs.max_event_bulk && switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
 
                        switch_event_t *pevent = (switch_event_t *) pop;
 
@@ -998,7 +998,7 @@ static void listener_main_loop(listener_t *listener)
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%d messages sent in a loop\n", msgs_sent);
 #endif
                } else { /* no more messages right now, relax */
-                       switch_yield(100000);
+                       switch_yield(10000);
                }
        }
        if (prefs.done) {
@@ -1157,6 +1157,9 @@ static int config(void)
        prefs.shortname = SWITCH_TRUE;
        prefs.encoding = ERLANG_STRING;
        prefs.compat_rel = 0;
+       prefs.max_event_bulk = 1;
+       prefs.max_log_bulk = 1;
+       
 
        if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
@@ -1199,6 +1202,10 @@ static int config(void)
                                        } else {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Max acl records of %d reached\n", MAX_ACL);
                                        }
+                               } else if (!strcasecmp(var, "max-event-bulk") && !zstr(val)) {
+                                       prefs.max_event_bulk = atoi(val);
+                               } else if (!strcasecmp(var, "max-log-bulk") && !zstr(val)) {
+                                       prefs.max_log_bulk = atoi(val);
                                }
                        }
                }
index d84fd0f50513951f4ea16c1d440287739b40e6c5..719210dca819a9b6b1a6655be5061e0cbaa39b0c 100644 (file)
@@ -216,6 +216,8 @@ struct prefs_struct {
        uint32_t id;
        erlang_encoding_t encoding;
        int compat_rel;
+       int max_event_bulk;
+       int max_log_bulk;
 };
 typedef struct prefs_struct prefs_t;