[Freeswitch-svn] [commit] r5541 - in freeswitch/trunk/src: . mod/event_handlers/mod_event_socket mod/languages/mod_spidermonkey
Freeswitch SVN
anthm at freeswitch.org
Tue Jul 24 17:26:05 EDT 2007
Author: anthm
Date: Tue Jul 24 17:26:04 2007
New Revision: 5541
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
freeswitch/trunk/src/switch_event.c
Log:
fix up some event issues
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Tue Jul 24 17:26:04 2007
@@ -83,10 +83,12 @@
} listen_list;
static struct {
+ switch_mutex_t *mutex;
char *ip;
uint16_t port;
char *password;
int done;
+ int threads;
} prefs;
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_pref_ip, prefs.ip)
@@ -137,7 +139,7 @@
if (l->event_list[SWITCH_EVENT_ALL]) {
send = 1;
} 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;
}
}
@@ -265,11 +267,19 @@
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_event_socket_shutdown)
{
listener_t *l;
+ int sanity = 0;
prefs.done = 1;
close_socket(&listen_list.sock);
+ while(prefs.threads) {
+ switch_yield(10000);
+ if (++sanity == 1000) {
+ break;
+ }
+ }
+
switch_mutex_lock(listen_list.mutex);
for (l = listen_list.listeners; l; l = l->next) {
close_socket(&l->sock);
@@ -346,7 +356,7 @@
start = time(NULL);
ptr = mbuf;
- while (listener->sock) {
+ while (listener->sock && !prefs.done) {
uint8_t do_sleep = 1;
mlen = 1;
status = switch_socket_recv(listener->sock, ptr, &mlen);
@@ -857,7 +867,7 @@
if (type == SWITCH_EVENT_ALL) {
uint32_t x = 0;
for (x = 0; x < SWITCH_EVENT_ALL; x++) {
- listener->event_list[x] = 0;
+ listener->event_list[x] = 1;
}
}
listener->event_list[type] = 1;
@@ -904,8 +914,9 @@
uint32_t x = 0;
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++) {
listener->event_list[x] = 0;
}
@@ -918,10 +929,6 @@
}
listener->event_list[type] = 0;
}
-
- if (type == SWITCH_EVENT_CUSTOM) {
- custom++;
- }
}
cur = next;
@@ -980,6 +987,9 @@
switch_core_session_t *session = NULL;
switch_channel_t *channel = NULL;
+ switch_mutex_lock(listen_list.mutex);
+ prefs.threads++;
+ switch_mutex_unlock(listen_list.mutex);
assert(listener != NULL);
@@ -1113,6 +1123,9 @@
switch_core_destroy_memory_pool(&pool);
}
+ switch_mutex_lock(listen_list.mutex);
+ prefs.threads--;
+ switch_mutex_unlock(listen_list.mutex);
return NULL;
}
@@ -1226,7 +1239,7 @@
switch_log_bind_logger(socket_logger, SWITCH_LOG_DEBUG);
- for (;;) {
+ for(;;) {
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");
goto fail;
Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (original)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c Tue Jul 24 17:26:04 2007
@@ -354,12 +354,12 @@
if (etype == SWITCH_EVENT_CUSTOM) {
char *subclass_name;
- if (argc < 1) {
- *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
- return JS_TRUE;
+ if (argc > 1) {
+ subclass_name = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
+ } 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) {
*rval = BOOLEAN_TO_JSVAL(JS_FALSE);
return JS_TRUE;
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Tue Jul 24 17:26:04 2007
@@ -455,7 +455,10 @@
(*event)->event_id = event_id;
if (subclass_name) {
- (*event)->subclass = switch_core_hash_find(CUSTOM_HASH, 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);
+ }
switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Subclass", "%s", subclass_name);
}
More information about the Freeswitch-svn
mailing list