]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
tweaks
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Jul 2010 03:13:20 +0000 (22:13 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 1 Jul 2010 03:13:20 +0000 (22:13 -0500)
src/mod/applications/mod_fifo/mod_fifo.c
src/switch_core_sqldb.c

index bc6159172db51c72604434af14bb13015adf02c3..04bbe950ba30e19f9e9b049bc52884063ff2390e 100644 (file)
@@ -662,7 +662,8 @@ static switch_status_t hanguphook(switch_core_session_t *session)
        if (state == CS_HANGUP || state == CS_ROUTING) {
                if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) {
                        switch_snprintf(sql, sizeof(sql),
-                                                       "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'",
+                                                       "update fifo_outbound set use_count=use_count-1, "
+                                                       "outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s' and use_count > 0",
                                                        (long) switch_epoch_time_now(NULL), uuid);
 
                        fifo_execute_sql(sql, globals.sql_mutex);
@@ -817,7 +818,8 @@ static void *SWITCH_THREAD_FUNC ringall_thread_run(switch_thread_t *thread, void
                for (i = 0; i < cbh->rowcount; i++) {
                        struct call_helper *h = cbh->rows[i];
                        switch_snprintf(sql, sizeof(sql),
-                                                       "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
+                                                       "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, "
+                                                       "next_avail=%ld + lag where uuid='%s' and use_count > 0",
                                                        (long) switch_epoch_time_now(NULL), h->uuid);
                        fifo_execute_sql(sql, globals.sql_mutex);
                }
@@ -908,7 +910,8 @@ static void *SWITCH_THREAD_FUNC o_thread_run(switch_thread_t *thread, void *obj)
 
        if (status != SWITCH_STATUS_SUCCESS) {
                switch_snprintf(sql, sizeof(sql),
-                                               "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
+                                               "update fifo_outbound set use_count=use_count-1, "
+                                               "outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s' and use_count > 0",
                                                (long) switch_epoch_time_now(NULL), h->uuid);
                fifo_execute_sql(sql, globals.sql_mutex);
                goto end;
index 678e352a2e513bc4aaff8a2766c0f6232393050d..e9849502bece4b8041a89f93affd959fbf5f9930 100644 (file)
@@ -1153,7 +1153,7 @@ static void core_event_handler(switch_event_t *event)
                new_sql() = switch_mprintf("update channels set call_uuid='%q' where uuid='%s' and hostname='%q'",
                                                                   switch_event_get_header_nil(event, "channel-call-uuid"),
                                                                   switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
-               new_sql() = switch_mprintf("insert into calls (cal_uuid,call_created,call_created_epoch,function,caller_cid_name,"
+               new_sql() = switch_mprintf("insert into calls (call_uuid,call_created,call_created_epoch,function,caller_cid_name,"
                                                                   "caller_cid_num,caller_dest_num,caller_chan_name,caller_uuid,callee_cid_name,"
                                                                   "callee_cid_num,callee_dest_num,callee_chan_name,callee_uuid,hostname) "
                                                                   "values ('%s', '%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s','%q')",