merge fix for MODLANG-33 and MODLANG-34.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5374 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris
2007-06-15 17:25:41 +00:00
parent 27561c6560
commit f45d060172
9 changed files with 847 additions and 574 deletions
+19 -3
View File
@@ -30,6 +30,8 @@ switch_status_t PythonDTMFCallback(switch_core_session_t *session,
switch_file_handle_t *fh = NULL;
PyThreadState *threadState = NULL;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "PythonDTMFCallback\n");
if (!buf) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "buf pointer is null");
return SWITCH_STATUS_FALSE;
@@ -39,11 +41,14 @@ switch_status_t PythonDTMFCallback(switch_core_session_t *session,
func = (PyObject *) cb_state->function;
if (!func) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "cb_state->function is null\n");
return SWITCH_STATUS_FALSE;
}
else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "cb_state->function is NOT null\n");
}
if (!PyCallable_Check(func)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "function not callable\n");
return SWITCH_STATUS_FALSE;
}
@@ -57,14 +62,22 @@ switch_status_t PythonDTMFCallback(switch_core_session_t *session,
threadState = (PyThreadState *) cb_state->threadState;
if (!threadState) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error, invalid threadstate\n");
return SWITCH_STATUS_FALSE;
}
else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restoring threadstate: %p\n", threadState);
}
PyEval_RestoreThread(threadState); // nasty stuff happens when py interp has no thread state
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "restored threadstate, calling python function: %p\n", func);
result = PyEval_CallObject(func, arglist);
threadState = PyEval_SaveThread();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "called python function\n");
Py_DECREF(arglist); // Trash arglist
if (result && result != Py_None) {
@@ -88,6 +101,9 @@ switch_status_t process_callback_result(char *ret,
switch_file_handle_t *fh = NULL;
fh = (switch_file_handle_t *) cb_state->extra;
if (!fh) {
return SWITCH_STATUS_FALSE;
}
if (!ret) {
return SWITCH_STATUS_FALSE;