mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-25 04:01:55 +00:00
fix up some event issues
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5541 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
46e564502a
commit
25057d40ac
@ -83,10 +83,12 @@ static struct {
|
|||||||
} listen_list;
|
} listen_list;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
switch_mutex_t *mutex;
|
||||||
char *ip;
|
char *ip;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
char *password;
|
char *password;
|
||||||
int done;
|
int done;
|
||||||
|
int threads;
|
||||||
} prefs;
|
} prefs;
|
||||||
|
|
||||||
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip)
|
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip)
|
||||||
@ -137,7 +139,7 @@ static void event_handler(switch_event_t *event)
|
|||||||
if (l->event_list[SWITCH_EVENT_ALL]) {
|
if (l->event_list[SWITCH_EVENT_ALL]) {
|
||||||
send = 1;
|
send = 1;
|
||||||
} else if ((l->event_list[event->event_id])) {
|
} else if ((l->event_list[event->event_id])) {
|
||||||
if (event->event_id != SWITCH_EVENT_CUSTOM || (event->subclass && switch_core_hash_find(l->event_hash, event->subclass->name))) {
|
if (event->event_id != SWITCH_EVENT_CUSTOM || !event->subclass || (switch_core_hash_find(l->event_hash, event->subclass->name))) {
|
||||||
send = 1;
|
send = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -265,11 +267,19 @@ static void close_socket(switch_socket_t ** sock)
|
|||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown)
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown)
|
||||||
{
|
{
|
||||||
listener_t *l;
|
listener_t *l;
|
||||||
|
int sanity = 0;
|
||||||
|
|
||||||
prefs.done = 1;
|
prefs.done = 1;
|
||||||
|
|
||||||
close_socket(&listen_list.sock);
|
close_socket(&listen_list.sock);
|
||||||
|
|
||||||
|
while(prefs.threads) {
|
||||||
|
switch_yield(10000);
|
||||||
|
if (++sanity == 1000) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch_mutex_lock(listen_list.mutex);
|
switch_mutex_lock(listen_list.mutex);
|
||||||
for (l = listen_list.listeners; l; l = l->next) {
|
for (l = listen_list.listeners; l; l = l->next) {
|
||||||
close_socket(&l->sock);
|
close_socket(&l->sock);
|
||||||
@ -346,7 +356,7 @@ static switch_status_t read_packet(listener_t * listener, switch_event_t **event
|
|||||||
start = time(NULL);
|
start = time(NULL);
|
||||||
ptr = mbuf;
|
ptr = mbuf;
|
||||||
|
|
||||||
while (listener->sock) {
|
while (listener->sock && !prefs.done) {
|
||||||
uint8_t do_sleep = 1;
|
uint8_t do_sleep = 1;
|
||||||
mlen = 1;
|
mlen = 1;
|
||||||
status = switch_socket_recv(listener->sock, ptr, &mlen);
|
status = switch_socket_recv(listener->sock, ptr, &mlen);
|
||||||
@ -857,7 +867,7 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
|||||||
if (type == SWITCH_EVENT_ALL) {
|
if (type == SWITCH_EVENT_ALL) {
|
||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
for (x = 0; x < SWITCH_EVENT_ALL; x++) {
|
for (x = 0; x < SWITCH_EVENT_ALL; x++) {
|
||||||
listener->event_list[x] = 0;
|
listener->event_list[x] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
listener->event_list[type] = 1;
|
listener->event_list[type] = 1;
|
||||||
@ -904,8 +914,9 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
|||||||
uint32_t x = 0;
|
uint32_t x = 0;
|
||||||
key_count++;
|
key_count++;
|
||||||
|
|
||||||
if (type == SWITCH_EVENT_ALL) {
|
if (type == SWITCH_EVENT_CUSTOM) {
|
||||||
|
custom++;
|
||||||
|
} else if (type == SWITCH_EVENT_ALL) {
|
||||||
for (x = 0; x <= SWITCH_EVENT_ALL; x++) {
|
for (x = 0; x <= SWITCH_EVENT_ALL; x++) {
|
||||||
listener->event_list[x] = 0;
|
listener->event_list[x] = 0;
|
||||||
}
|
}
|
||||||
@ -918,10 +929,6 @@ static switch_status_t parse_command(listener_t * listener, switch_event_t *even
|
|||||||
}
|
}
|
||||||
listener->event_list[type] = 0;
|
listener->event_list[type] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SWITCH_EVENT_CUSTOM) {
|
|
||||||
custom++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur = next;
|
cur = next;
|
||||||
@ -980,6 +987,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
|
|||||||
switch_core_session_t *session = NULL;
|
switch_core_session_t *session = NULL;
|
||||||
switch_channel_t *channel = NULL;
|
switch_channel_t *channel = NULL;
|
||||||
|
|
||||||
|
switch_mutex_lock(listen_list.mutex);
|
||||||
|
prefs.threads++;
|
||||||
|
switch_mutex_unlock(listen_list.mutex);
|
||||||
|
|
||||||
assert(listener != NULL);
|
assert(listener != NULL);
|
||||||
|
|
||||||
@ -1113,6 +1123,9 @@ static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t * thread, void *obj
|
|||||||
switch_core_destroy_memory_pool(&pool);
|
switch_core_destroy_memory_pool(&pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_mutex_lock(listen_list.mutex);
|
||||||
|
prefs.threads--;
|
||||||
|
switch_mutex_unlock(listen_list.mutex);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1226,7 +1239,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_event_socket_runtime)
|
|||||||
switch_log_bind_logger(socket_logger, SWITCH_LOG_DEBUG);
|
switch_log_bind_logger(socket_logger, SWITCH_LOG_DEBUG);
|
||||||
|
|
||||||
|
|
||||||
for (;;) {
|
for(;;) {
|
||||||
if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) {
|
if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -354,12 +354,12 @@ static JSBool event_construct(JSContext * cx, JSObject * obj, uintN argc, jsval
|
|||||||
|
|
||||||
if (etype == SWITCH_EVENT_CUSTOM) {
|
if (etype == SWITCH_EVENT_CUSTOM) {
|
||||||
char *subclass_name;
|
char *subclass_name;
|
||||||
if (argc < 1) {
|
if (argc > 1) {
|
||||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
subclass_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
|
||||||
return JS_TRUE;
|
} else {
|
||||||
|
subclass_name = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
subclass_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
|
|
||||||
if (switch_event_create_subclass(&event, etype, subclass_name) != SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create_subclass(&event, etype, subclass_name) != SWITCH_STATUS_SUCCESS) {
|
||||||
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
|
||||||
return JS_TRUE;
|
return JS_TRUE;
|
||||||
|
@ -455,7 +455,10 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_subclass(switch_event_t **ev
|
|||||||
(*event)->event_id = event_id;
|
(*event)->event_id = event_id;
|
||||||
|
|
||||||
if (subclass_name) {
|
if (subclass_name) {
|
||||||
|
if (!((*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
|
||||||
|
switch_event_reserve_subclass((char *)subclass_name);
|
||||||
(*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
|
(*event)->subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name);
|
||||||
|
}
|
||||||
switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", "%s", subclass_name);
|
switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", "%s", subclass_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user