mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-26 12:37:26 +00:00
fix disconnect issue in event socket and fix a few small bugs
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11234 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
169ced2f93
commit
6f8e06f087
@ -37,7 +37,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Written by Marc Espie, public domain */
|
/* Written by Marc Espie, public domain */
|
||||||
#define ESL_CTYPE_NUM_CHARS 256
|
#define ESL_CTYPE_NUM_CHARS 256
|
||||||
|
|
||||||
@ -181,6 +180,48 @@ ESL_DECLARE(const char *)esl_stristr(const char *instr, const char *str)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
int vasprintf(char **ret, const char *format, va_list ap);
|
||||||
|
|
||||||
|
ESL_DECLARE(int) esl_vasprintf(char **ret, const char *fmt, va_list ap)
|
||||||
|
{
|
||||||
|
#if !defined(WIN32) && !defined(__sun)
|
||||||
|
return vasprintf(ret, fmt, ap);
|
||||||
|
#else
|
||||||
|
char *buf;
|
||||||
|
int len;
|
||||||
|
size_t buflen;
|
||||||
|
va_list ap2;
|
||||||
|
char *tmp = NULL;
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#if _MSC_VER >= 1500
|
||||||
|
/* hack for incorrect assumption in msvc header files for code analysis */
|
||||||
|
__analysis_assume(tmp);
|
||||||
|
#endif
|
||||||
|
ap2 = ap;
|
||||||
|
#else
|
||||||
|
va_copy(ap2, ap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
len = vsnprintf(tmp, 0, fmt, ap2);
|
||||||
|
|
||||||
|
if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
|
||||||
|
len = vsnprintf(buf, buflen, fmt, ap);
|
||||||
|
*ret = buf;
|
||||||
|
} else {
|
||||||
|
*ret = NULL;
|
||||||
|
len = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(ap2);
|
||||||
|
return len;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...)
|
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -236,8 +277,9 @@ static const char *cut_path(const char *in)
|
|||||||
static void default_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
|
static void default_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
const char *fp;
|
const char *fp;
|
||||||
char data[1024];
|
char *data;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (level < 0 || level > 7) {
|
if (level < 0 || level > 7) {
|
||||||
level = 7;
|
level = 7;
|
||||||
@ -250,10 +292,12 @@ static void default_logger(const char *file, const char *func, int line, int lev
|
|||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
vsnprintf(data, sizeof(data), fmt, ap);
|
ret = esl_vasprintf(&data, fmt, ap);
|
||||||
|
|
||||||
|
|
||||||
|
if (ret != -1) {
|
||||||
fprintf(stderr, "[%s] %s:%d %s() %s", LEVEL_NAMES[level], file, line, func, data);
|
fprintf(stderr, "[%s] %s:%d %s() %s", LEVEL_NAMES[level], file, line, func, data);
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
@ -334,6 +378,14 @@ ESL_DECLARE(char *)esl_url_decode(char *s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sock_setup(esl_handle_t *handle)
|
||||||
|
{
|
||||||
|
int x = 1;
|
||||||
|
|
||||||
|
setsockopt(handle->sock, IPPROTO_TCP, TCP_NODELAY, &x, sizeof(x));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t socket, struct sockaddr_in addr)
|
ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t socket, struct sockaddr_in addr)
|
||||||
{
|
{
|
||||||
handle->sock = socket;
|
handle->sock = socket;
|
||||||
@ -350,6 +402,8 @@ ESL_DECLARE(esl_status_t) esl_attach_handle(esl_handle_t *handle, esl_socket_t s
|
|||||||
|
|
||||||
handle->connected = 1;
|
handle->connected = 1;
|
||||||
|
|
||||||
|
sock_setup(handle);
|
||||||
|
|
||||||
esl_send_recv(handle, "connect\n\n");
|
esl_send_recv(handle, "connect\n\n");
|
||||||
|
|
||||||
|
|
||||||
@ -413,6 +467,39 @@ ESL_DECLARE(esl_status_t) esl_execute(esl_handle_t *handle, const char *app, con
|
|||||||
return esl_send_recv(handle, send_buf);
|
return esl_send_recv(handle, send_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ESL_DECLARE(esl_status_t) esl_filter(esl_handle_t *handle, const char *header, const char *value)
|
||||||
|
{
|
||||||
|
char send_buf[1024] = "";
|
||||||
|
|
||||||
|
if (!handle->connected) {
|
||||||
|
return ESL_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(send_buf, sizeof(send_buf), "filter %s %s\n\n", header, value);
|
||||||
|
|
||||||
|
return esl_send_recv(handle, send_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ESL_DECLARE(esl_status_t) esl_events(esl_handle_t *handle, esl_event_type_t etype, const char *value)
|
||||||
|
{
|
||||||
|
char send_buf[1024] = "";
|
||||||
|
const char *type = "plain";
|
||||||
|
|
||||||
|
if (!handle->connected) {
|
||||||
|
return ESL_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (etype == ESL_EVENT_TYPE_XML) {
|
||||||
|
type = "xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(send_buf, sizeof(send_buf), "event %s %s\n\n", type, value);
|
||||||
|
|
||||||
|
return esl_send_recv(handle, send_buf);
|
||||||
|
}
|
||||||
|
|
||||||
static int esl_socket_reuseaddr(esl_socket_t socket)
|
static int esl_socket_reuseaddr(esl_socket_t socket)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -536,6 +623,8 @@ ESL_DECLARE(esl_status_t) esl_connect(esl_handle_t *handle, const char *host, es
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sock_setup(handle);
|
||||||
|
|
||||||
handle->connected = 1;
|
handle->connected = 1;
|
||||||
|
|
||||||
if (esl_recv(handle)) {
|
if (esl_recv(handle)) {
|
||||||
|
@ -311,45 +311,6 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st
|
|||||||
return ESL_SUCCESS;
|
return ESL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int vasprintf(char **ret, const char *format, va_list ap);
|
|
||||||
|
|
||||||
static int esl_vasprintf(char **ret, const char *fmt, va_list ap)
|
|
||||||
{
|
|
||||||
#if !defined(WIN32) && !defined(__sun)
|
|
||||||
return vasprintf(ret, fmt, ap);
|
|
||||||
#else
|
|
||||||
char *buf;
|
|
||||||
int len;
|
|
||||||
size_t buflen;
|
|
||||||
va_list ap2;
|
|
||||||
char *tmp = NULL;
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#if _MSC_VER >= 1500
|
|
||||||
/* hack for incorrect assumption in msvc header files for code analysis */
|
|
||||||
__analysis_assume(tmp);
|
|
||||||
#endif
|
|
||||||
ap2 = ap;
|
|
||||||
#else
|
|
||||||
va_copy(ap2, ap);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
len = vsnprintf(tmp, 0, fmt, ap2);
|
|
||||||
|
|
||||||
if (len > 0 && (buf = malloc((buflen = (size_t) (len + 1)))) != NULL) {
|
|
||||||
len = vsnprintf(buf, buflen, fmt, ap);
|
|
||||||
*ret = buf;
|
|
||||||
} else {
|
|
||||||
*ret = NULL;
|
|
||||||
len = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap2);
|
|
||||||
return len;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ESL_DECLARE(esl_status_t) esl_event_add_header(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *fmt, ...)
|
ESL_DECLARE(esl_status_t) esl_event_add_header(esl_event_t *event, esl_stack_t stack, const char *header_name, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -496,6 +457,8 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
|
|||||||
* the memory, allocate and only reallocate if we need more. This avoids an alloc, free CPU
|
* the memory, allocate and only reallocate if we need more. This avoids an alloc, free CPU
|
||||||
* destroying loop.
|
* destroying loop.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
new_len = (strlen(hp->value) * 3) + 1;
|
new_len = (strlen(hp->value) * 3) + 1;
|
||||||
|
|
||||||
if (encode_len < new_len) {
|
if (encode_len < new_len) {
|
||||||
@ -575,6 +538,7 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
|
|||||||
snprintf(buf + len, dlen - len, "\n");
|
snprintf(buf + len, dlen - len, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*str = buf;
|
*str = buf;
|
||||||
|
|
||||||
return ESL_SUCCESS;
|
return ESL_SUCCESS;
|
||||||
|
@ -42,6 +42,12 @@
|
|||||||
typedef struct esl_event_header esl_event_header_t;
|
typedef struct esl_event_header esl_event_header_t;
|
||||||
typedef struct esl_event esl_event_t;
|
typedef struct esl_event esl_event_t;
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ESL_EVENT_TYPE_PLAIN,
|
||||||
|
ESL_EVENT_TYPE_XML
|
||||||
|
} esl_event_type_t;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define ESL_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
|
#define ESL_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
|
||||||
#define ESL_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
|
#define ESL_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
|
||||||
@ -164,6 +170,7 @@ typedef struct esl_event esl_event_t;
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
#include <netinet/tcp.h>
|
||||||
#include <sys/signal.h>
|
#include <sys/signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@ -290,6 +297,9 @@ typedef enum {
|
|||||||
#define ESL_LOG_EMERG ESL_PRE, ESL_LOG_LEVEL_EMERG
|
#define ESL_LOG_EMERG ESL_PRE, ESL_LOG_LEVEL_EMERG
|
||||||
typedef void (*esl_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
|
typedef void (*esl_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
|
ESL_DECLARE(int) esl_vasprintf(char **ret, const char *fmt, va_list ap);
|
||||||
|
|
||||||
ESL_DECLARE_DATA extern esl_logger_t esl_log;
|
ESL_DECLARE_DATA extern esl_logger_t esl_log;
|
||||||
|
|
||||||
ESL_DECLARE(void) esl_global_set_logger(esl_logger_t logger);
|
ESL_DECLARE(void) esl_global_set_logger(esl_logger_t logger);
|
||||||
@ -320,6 +330,9 @@ ESL_DECLARE(esl_status_t) esl_send(esl_handle_t *handle, const char *cmd);
|
|||||||
ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **save_event);
|
ESL_DECLARE(esl_status_t) esl_recv_event(esl_handle_t *handle, esl_event_t **save_event);
|
||||||
ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, esl_event_t **save_event);
|
ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms, esl_event_t **save_event);
|
||||||
ESL_DECLARE(esl_status_t) esl_send_recv(esl_handle_t *handle, const char *cmd);
|
ESL_DECLARE(esl_status_t) esl_send_recv(esl_handle_t *handle, const char *cmd);
|
||||||
|
ESL_DECLARE(esl_status_t) esl_filter(esl_handle_t *handle, const char *header, const char *value);
|
||||||
|
ESL_DECLARE(esl_status_t) esl_events(esl_handle_t *handle, esl_event_type_t etype, const char *value);
|
||||||
|
|
||||||
#define esl_recv(_h) esl_recv_event(_h, NULL)
|
#define esl_recv(_h) esl_recv_event(_h, NULL)
|
||||||
#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, NULL)
|
#define esl_recv_timed(_h, _ms) esl_recv_event_timed(_h, _ms, NULL)
|
||||||
|
|
||||||
|
@ -11,17 +11,18 @@ static void mycallback(esl_socket_t server_sock, esl_socket_t client_sock, struc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esl_attach_handle(&handle, client_sock, addr);
|
esl_attach_handle(&handle, client_sock, addr);
|
||||||
|
|
||||||
printf("Connected! %d\n", handle.sock);
|
printf("Connected! %d\n", handle.sock);
|
||||||
|
|
||||||
|
esl_filter(&handle, "unique-id", esl_event_get_header(handle.info_event, "caller-unique-id"));
|
||||||
|
esl_events(&handle, ESL_EVENT_TYPE_PLAIN, "SESSION_HEARTBEAT CHANNEL_ANSWER CHANNEL_ORIGINATE CHANNEL_PROGRESS CHANNEL_HANGUP "
|
||||||
|
"CHANNEL_BRIDGE CHANNEL_UNBRIDGE CHANNEL_OUTGOING CHANNEL_EXECUTE CHANNEL_EXECUTE_COMPLETE DTMF CUSTOM conference::maintenance");
|
||||||
|
|
||||||
esl_execute(&handle, "answer", NULL, NULL);
|
esl_execute(&handle, "answer", NULL, NULL);
|
||||||
esl_execute(&handle, "playback", "/ram/swimp.raw", NULL);
|
esl_execute(&handle, "conference", "3000@default", NULL);
|
||||||
|
|
||||||
sleep(30);
|
while(esl_recv(&handle) == ESL_SUCCESS);
|
||||||
|
|
||||||
esl_disconnect(&handle);
|
esl_disconnect(&handle);
|
||||||
}
|
}
|
||||||
|
@ -946,6 +946,8 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_threa
|
|||||||
#define SWITCH_SO_SNDBUF 64
|
#define SWITCH_SO_SNDBUF 64
|
||||||
#define SWITCH_SO_RCVBUF 128
|
#define SWITCH_SO_RCVBUF 128
|
||||||
#define SWITCH_SO_DISCONNECTED 256
|
#define SWITCH_SO_DISCONNECTED 256
|
||||||
|
#define SWITCH_SO_TCP_NODELAY 512
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @def SWITCH_INET
|
* @def SWITCH_INET
|
||||||
|
@ -74,7 +74,6 @@ struct listener {
|
|||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
int lost_events;
|
int lost_events;
|
||||||
int lost_logs;
|
int lost_logs;
|
||||||
int hup;
|
|
||||||
time_t last_flush;
|
time_t last_flush;
|
||||||
uint32_t timeout;
|
uint32_t timeout;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
@ -385,6 +384,7 @@ SWITCH_STANDARD_APP(socket_function)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_socket_opt_set(new_sock, SWITCH_SO_KEEPALIVE, 1);
|
switch_socket_opt_set(new_sock, SWITCH_SO_KEEPALIVE, 1);
|
||||||
|
switch_socket_opt_set(new_sock, SWITCH_SO_TCP_NODELAY, 1);
|
||||||
|
|
||||||
if (switch_socket_connect(new_sock, sa) != SWITCH_STATUS_SUCCESS) {
|
if (switch_socket_connect(new_sock, sa) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Socket Error!\n");
|
||||||
@ -978,17 +978,6 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_test_flag(listener, LFLAG_MYEVENTS) && !listener->hup && channel && !switch_channel_ready(channel)) {
|
|
||||||
listener->hup = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (listener->hup == 2 ||
|
|
||||||
((!switch_test_flag(listener, LFLAG_MYEVENTS) && !switch_test_flag(listener, LFLAG_EVENTS)) &&
|
|
||||||
channel && !switch_channel_ready(channel)) ) {
|
|
||||||
status = SWITCH_STATUS_FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mlen) {
|
if (mlen) {
|
||||||
bytes += mlen;
|
bytes += mlen;
|
||||||
do_sleep = 0;
|
do_sleep = 0;
|
||||||
@ -1126,7 +1115,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (switch_test_flag(listener, LFLAG_EVENTS)) {
|
if (switch_test_flag(listener, LFLAG_EVENTS)) {
|
||||||
if (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||||
char hbuf[512];
|
char hbuf[512];
|
||||||
switch_event_t *pevent = (switch_event_t *) pop;
|
switch_event_t *pevent = (switch_event_t *) pop;
|
||||||
char *etype;
|
char *etype;
|
||||||
@ -1148,10 +1137,7 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!listener->ebuf) {
|
switch_assert(listener->ebuf);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No event data (allocation error?)\n");
|
|
||||||
goto endloop;
|
|
||||||
}
|
|
||||||
|
|
||||||
len = strlen(listener->ebuf);
|
len = strlen(listener->ebuf);
|
||||||
|
|
||||||
@ -1167,17 +1153,16 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
|
|||||||
|
|
||||||
endloop:
|
endloop:
|
||||||
|
|
||||||
if (listener->hup == 1 && pevent->event_id == SWITCH_EVENT_CHANNEL_HANGUP) {
|
|
||||||
char *uuid = switch_event_get_header(pevent, "unique-id");
|
|
||||||
if (!strcmp(uuid, switch_core_session_get_uuid(listener->session))) {
|
|
||||||
listener->hup = 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_event_destroy(&pevent);
|
switch_event_destroy(&pevent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channel && !switch_channel_ready(channel)) {
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (do_sleep) {
|
if (do_sleep) {
|
||||||
switch_cond_next();
|
switch_cond_next();
|
||||||
}
|
}
|
||||||
@ -1775,6 +1760,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_socket_opt_set(listener->sock, SWITCH_SO_TCP_NODELAY, TRUE);
|
||||||
|
switch_socket_opt_set(listener->sock, SWITCH_SO_NONBLOCK, TRUE);
|
||||||
|
|
||||||
if (prefs.acl_count && listener->sa && !switch_strlen_zero(listener->remote_ip)) {
|
if (prefs.acl_count && listener->sa && !switch_strlen_zero(listener->remote_ip)) {
|
||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
|
|
||||||
@ -1932,10 +1920,18 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
|||||||
switch_mutex_unlock(listener->filter_mutex);
|
switch_mutex_unlock(listener->filter_mutex);
|
||||||
if (listener->sock) {
|
if (listener->sock) {
|
||||||
char disco_buf[512] = "";
|
char disco_buf[512] = "";
|
||||||
const char message[] = "Disconnected, goodbye!\nSee you at ClueCon http://www.cluecon.com/ !!!\n";
|
const char message[] = "Disconnected, goodbye.\nSee you at ClueCon! http://www.cluecon.com/\n";
|
||||||
int mlen = strlen(message);
|
int mlen = strlen(message);
|
||||||
|
|
||||||
|
if (listener->session) {
|
||||||
|
switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n"
|
||||||
|
"Controlled-Session-UUID: %s\n"
|
||||||
|
"Content-Length: %d\n\n",
|
||||||
|
switch_core_session_get_uuid(listener->session), mlen);
|
||||||
|
} else {
|
||||||
switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\nContent-Length: %d\n\n", mlen);
|
switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\nContent-Length: %d\n\n", mlen);
|
||||||
|
}
|
||||||
|
|
||||||
len = strlen(disco_buf);
|
len = strlen(disco_buf);
|
||||||
switch_socket_send(listener->sock, disco_buf, &len);
|
switch_socket_send(listener->sock, disco_buf, &len);
|
||||||
len = mlen;
|
len = mlen;
|
||||||
|
@ -453,7 +453,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(switch_core_session_t *se
|
|||||||
switch_time_t b4, aftr;
|
switch_time_t b4, aftr;
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s Command Execute %s(%s)\n",
|
||||||
switch_channel_get_name(channel), app_name, app_arg);
|
switch_channel_get_name(channel), app_name, switch_str_nil(app_arg));
|
||||||
b4 = switch_timestamp_now();
|
b4 = switch_timestamp_now();
|
||||||
switch_core_session_exec(session, application_interface, app_arg);
|
switch_core_session_exec(session, application_interface, app_arg);
|
||||||
aftr = switch_timestamp_now();
|
aftr = switch_timestamp_now();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user