mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-07-23 04:14:47 +00:00
cleaning up stupid mess (lesson in regressions for Math`)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10472 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
412fc926ea
commit
9b98c2d512
@ -320,6 +320,22 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(_In_ switch_core_s
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#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
|
#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);
|
SWITCH_DECLARE(void) switch_core_session_perform_write_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2727,7 +2727,7 @@ static JSObject *new_js_session(JSContext * cx, JSObject * obj, switch_core_sess
|
|||||||
(*jss)->stack_depth = 0;
|
(*jss)->stack_depth = 0;
|
||||||
if ((JS_SetPrivate(cx, session_obj, *jss) &&
|
if ((JS_SetPrivate(cx, session_obj, *jss) &&
|
||||||
JS_DefineProperties(cx, session_obj, session_props) && JS_DefineFunctions(cx, session_obj, session_methods))) {
|
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");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Failure.\n");
|
||||||
free(*jss);
|
free(*jss);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -3508,8 +3508,9 @@ static void js_parse_and_execute(switch_core_session_t *session, const char *inp
|
|||||||
|
|
||||||
/* Emaculent conception of session object into the script if one is available */
|
/* 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))) {
|
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);
|
eval_some_js(buf, cx, javascript_global_object, &rval);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (ro) {
|
if (ro) {
|
||||||
new_request(cx, javascript_global_object, ro);
|
new_request(cx, javascript_global_object, ro);
|
||||||
|
@ -63,6 +63,34 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio
|
|||||||
return status;
|
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
|
#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)
|
SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_t *session, const char *file, const char *func, int line)
|
||||||
{
|
{
|
||||||
|
@ -421,9 +421,10 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
|
|||||||
switch_channel_get_variables(session->channel, &stream.param_event);
|
switch_channel_get_variables(session->channel, &stream.param_event);
|
||||||
expanded = switch_channel_expand_variables(session->channel, arg);
|
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_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, expanded,
|
||||||
switch_str_nil((char *) stream.data));
|
switch_str_nil((char *) stream.data));
|
||||||
|
switch_api_execute(cmd, expanded, use_session, &stream);
|
||||||
if (expanded != arg) {
|
if (expanded != arg) {
|
||||||
switch_safe_free(expanded);
|
switch_safe_free(expanded);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user