[Freeswitch-svn] [commit] r10472 - in freeswitch/trunk/src: . include mod/languages/mod_spidermonkey

FreeSWITCH SVN anthm at freeswitch.org
Wed Nov 19 18:27:59 PST 2008


Author: anthm
Date: Wed Nov 19 21:27:59 2008
New Revision: 10472

Log:
cleaning up stupid mess (lesson in regressions for Math`)

Modified:
   freeswitch/trunk/src/include/switch_core.h
   freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c
   freeswitch/trunk/src/switch_core_rwlock.c
   freeswitch/trunk/src/switch_core_state_machine.c

Modified: freeswitch/trunk/src/include/switch_core.h
==============================================================================
--- freeswitch/trunk/src/include/switch_core.h	(original)
+++ freeswitch/trunk/src/include/switch_core.h	Wed Nov 19 21:27:59 2008
@@ -321,6 +321,22 @@
 
 
 #ifdef SWITCH_DEBUG_RWLOCKS
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
+#endif
+
+/*! 
+  \brief Acquire a read lock on the session
+  \param session the session to acquire from
+  \return success if it is safe to read from the session
+*/
+#ifdef SWITCH_DEBUG_RWLOCKS
+#define switch_core_session_read_lock(session) switch_core_session_perform_read_lock_hangup(session, __FILE__, __SWITCH_FUNC__, __LINE__)
+#else
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session);
+#endif
+
+
+#ifdef SWITCH_DEBUG_RWLOCKS
 SWITCH_DECLARE(void) switch_core_session_perform_write_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
 #endif
 

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	Wed Nov 19 21:27:59 2008
@@ -2727,7 +2727,7 @@
 		(*jss)->stack_depth = 0;
 		if ((JS_SetPrivate(cx, session_obj, *jss) &&
 			 JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
-			if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
+			if (switch_core_session_read_lock_hangup(session) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Failure.\n");
 				free(*jss);
 				return NULL;
@@ -3508,8 +3508,9 @@
 
 		/* Emaculent conception of session object into the script if one is available */
 		if (!(session && new_js_session(cx, javascript_global_object, session, &jss, "session", flags))) {
-			switch_snprintf(buf, sizeof(buf), "~var session = false;");
+			switch_snprintf(buf, sizeof(buf), "~var session = new Object();");
 			eval_some_js(buf, cx, javascript_global_object, &rval);
+			return;
 		}
 		if (ro) {
 			new_request(cx, javascript_global_object, ro);

Modified: freeswitch/trunk/src/switch_core_rwlock.c
==============================================================================
--- freeswitch/trunk/src/switch_core_rwlock.c	(original)
+++ freeswitch/trunk/src/switch_core_rwlock.c	Wed Nov 19 21:27:59 2008
@@ -63,6 +63,34 @@
 	return status;
 }
 
+
+#ifdef SWITCH_DEBUG_RWLOCKS
+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(switch_core_session_t *session, const char *file, const char *func, int line)
+#else
+SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock_hangup(switch_core_session_t *session)
+#endif
+{
+	switch_status_t status = SWITCH_STATUS_FALSE;
+
+	if (session->rwlock) {
+		if (switch_test_flag(session, SSF_DESTROYED) || switch_channel_get_state(session->channel) >= CS_DONE) {
+			status = SWITCH_STATUS_FALSE;
+#ifdef SWITCH_DEBUG_RWLOCKS
+			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock FAIL\n",
+							  switch_channel_get_name(session->channel));
+#endif
+		} else {
+			status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock);
+#ifdef SWITCH_DEBUG_RWLOCKS
+			switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "%s Read lock ACQUIRED\n",
+							  switch_channel_get_name(session->channel));
+#endif
+		}
+	}
+
+	return status;
+}
+
 #ifdef SWITCH_DEBUG_RWLOCKS
 SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line)
 {

Modified: freeswitch/trunk/src/switch_core_state_machine.c
==============================================================================
--- freeswitch/trunk/src/switch_core_state_machine.c	(original)
+++ freeswitch/trunk/src/switch_core_state_machine.c	Wed Nov 19 21:27:59 2008
@@ -421,9 +421,10 @@
 						switch_channel_get_variables(session->channel, &stream.param_event);
 						expanded = switch_channel_expand_variables(session->channel, arg);
 						
-						switch_api_execute(cmd, expanded, use_session, &stream);
+
 						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, expanded,
 										  switch_str_nil((char *) stream.data));
+						switch_api_execute(cmd, expanded, use_session, &stream);
 						if (expanded != arg) {
 							switch_safe_free(expanded);
 						}



More information about the Freeswitch-svn mailing list