mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-02-08 08:51:50 +00:00
Merge in some recent event_socket changes, mainly the new log data structure
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11018 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
79cced2d52
commit
386f0b9388
@ -142,9 +142,14 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l
|
|||||||
switch_mutex_lock(globals.listener_mutex);
|
switch_mutex_lock(globals.listener_mutex);
|
||||||
for (l = listen_list.listeners; l; l = l->next) {
|
for (l = listen_list.listeners; l; l = l->next) {
|
||||||
if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) {
|
if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) {
|
||||||
char *data = strdup(node->data);
|
|
||||||
if (data) {
|
switch_log_node_t *dnode = malloc(sizeof(*node));
|
||||||
if (switch_queue_trypush(l->log_queue, data) == SWITCH_STATUS_SUCCESS) {
|
switch_assert(dnode);
|
||||||
|
*dnode = *node;
|
||||||
|
dnode->data = strdup(node->data);
|
||||||
|
switch_assert(dnode->data);
|
||||||
|
|
||||||
|
if (switch_queue_trypush(l->log_queue, dnode) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (l->lost_logs) {
|
if (l->lost_logs) {
|
||||||
int ll = l->lost_logs;
|
int ll = l->lost_logs;
|
||||||
switch_event_t *event;
|
switch_event_t *event;
|
||||||
@ -156,12 +161,10 @@ static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_safe_free(data);
|
switch_safe_free(dnode->data);
|
||||||
|
switch_safe_free(dnode);
|
||||||
l->lost_logs++;
|
l->lost_logs++;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error!\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch_mutex_unlock(globals.listener_mutex);
|
switch_mutex_unlock(globals.listener_mutex);
|
||||||
@ -936,7 +939,7 @@ sendevent_fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
if ((session = switch_core_session_locate(uuid))) {
|
if (!switch_strlen_zero(uuid) && (session = switch_core_session_locate(uuid))) {
|
||||||
} else {
|
} else {
|
||||||
ei_x_encode_tuple_header(rbuf, 2);
|
ei_x_encode_tuple_header(rbuf, 2);
|
||||||
ei_x_encode_atom(rbuf, "error");
|
ei_x_encode_atom(rbuf, "error");
|
||||||
@ -980,6 +983,7 @@ sendevent_fail:
|
|||||||
ei_x_encode_atom(rbuf, "error");
|
ei_x_encode_atom(rbuf, "error");
|
||||||
ei_x_encode_atom(rbuf, "badmem");
|
ei_x_encode_atom(rbuf, "badmem");
|
||||||
}
|
}
|
||||||
|
/* switch_core_session_rwunlock(session); */ /* XXX is this needed? */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sendmsg_fail:
|
sendmsg_fail:
|
||||||
@ -1262,20 +1266,48 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
|
|||||||
/* send out any pending crap in the log queue */
|
/* send out any pending crap in the log queue */
|
||||||
if (switch_test_flag(listener, LFLAG_LOG)) {
|
if (switch_test_flag(listener, LFLAG_LOG)) {
|
||||||
if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
|
||||||
char *data = (char *) pop;
|
switch_log_node_t *dnode = (switch_log_node_t *) pop;
|
||||||
|
|
||||||
if (data) {
|
if (dnode->data) {
|
||||||
ei_x_buff lbuf;
|
ei_x_buff lbuf;
|
||||||
ei_x_new_with_version(&lbuf);
|
ei_x_new_with_version(&lbuf);
|
||||||
ei_x_encode_tuple_header(&lbuf, 2);
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
ei_x_encode_atom(&lbuf, "log");
|
ei_x_encode_atom(&lbuf, "log");
|
||||||
ei_x_encode_string(&lbuf, data);
|
ei_x_encode_list_header(&lbuf, 6);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "level");
|
||||||
|
ei_x_encode_char(&lbuf, (unsigned char)dnode->level);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "text_channel");
|
||||||
|
ei_x_encode_char(&lbuf, (unsigned char)dnode->level);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "file");
|
||||||
|
ei_x_encode_string(&lbuf, dnode->file);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "func");
|
||||||
|
ei_x_encode_string(&lbuf, dnode->func);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "line");
|
||||||
|
ei_x_encode_ulong(&lbuf, (unsigned long)dnode->line);
|
||||||
|
|
||||||
|
ei_x_encode_tuple_header(&lbuf, 2);
|
||||||
|
ei_x_encode_atom(&lbuf, "data");
|
||||||
|
ei_x_encode_string(&lbuf, dnode->data);
|
||||||
|
|
||||||
|
ei_x_encode_empty_list(&lbuf);
|
||||||
|
|
||||||
switch_mutex_lock(listener->sock_mutex);
|
switch_mutex_lock(listener->sock_mutex);
|
||||||
ei_send(listener->sockfd, &listener->log_pid, lbuf.buff, lbuf.index);
|
ei_send(listener->sockfd, &listener->log_pid, lbuf.buff, lbuf.index);
|
||||||
switch_mutex_unlock(listener->sock_mutex);
|
switch_mutex_unlock(listener->sock_mutex);
|
||||||
|
|
||||||
ei_x_free(&lbuf);
|
ei_x_free(&lbuf);
|
||||||
|
free(dnode->data);
|
||||||
|
free(dnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user