]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
--resolve FS-5478
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Mon, 8 Jul 2013 04:55:48 +0000 (00:55 -0400)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Mon, 8 Jul 2013 04:55:48 +0000 (00:55 -0400)
src/mod/applications/mod_callcenter/mod_callcenter.c

index 9f74d2f9ccf8e37725396e46490c406965ae9665..4e9e852aa964170548f2f4859365125742a9d78c 100644 (file)
@@ -1525,7 +1525,15 @@ static void *SWITCH_THREAD_FUNC outbound_agent_thread_run(switch_thread_t *threa
                                /* Switch the agent session */
                                if (real_uuid) {
                                        switch_core_session_rwunlock(agent_session);
-                                       agent_session = switch_core_session_locate(real_uuid);
+                                       if (!(agent_session = switch_core_session_locate(real_uuid))) {
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member_session), SWITCH_LOG_DEBUG, "Real session is already gone (agent '%s')\n", h->agent_name);
+                                               sql = switch_mprintf("UPDATE members SET state = '%q', serving_agent = '', serving_system = ''"
+                                                                                        " WHERE serving_agent = '%q' AND serving_system = '%q' AND uuid = '%q' AND system = 'single_box'",
+                                                                                        cc_member_state2str(CC_MEMBER_STATE_WAITING), h->agent_name, h->agent_system, h->member_uuid);
+                                               cc_execute_sql(NULL, sql, NULL);
+                                               switch_safe_free(sql);
+                                               goto done;
+                                       }
                                        agent_uuid = switch_core_session_get_uuid(agent_session);
                                        agent_channel = switch_core_session_get_channel(agent_session);