Changeset 639:95a784729cac in freeDiameter for extensions/dbg_interactive/sessions.i
- Timestamp:
- Dec 20, 2010, 1:07:06 PM (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/sessions.i
r638 r639 39 39 40 40 %{ 41 /* store the python callback function here */42 static PyObject * py_cleanup_cb = NULL;43 41 /* call it (might be called from a different thread than the interpreter, when session times out) */ 44 static void call_the_python_cleanup_callback(session_state * state, char * sid ) {42 static void call_the_python_cleanup_callback(session_state * state, char * sid, void * cb) { 45 43 PyObject *result; 46 if (!py_cleanup_cb) 44 if (!cb) { 45 fd_log_debug("Internal error: missing callback object!\n"); 47 46 return; 47 } 48 48 49 49 /* Call the function */ 50 50 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 51 result = PyEval_CallFunction( py_cleanup_cb, "(Os)", state, sid);51 result = PyEval_CallFunction((PyObject *)cb, "(Os)", state, sid); 52 52 Py_XDECREF(result); 53 53 SWIG_PYTHON_THREAD_END_BLOCK; … … 64 64 struct session_handler * hdl = NULL; 65 65 int ret; 66 if (py_cleanup_cb) {67 DI_ERROR(EINVAL, PyExc_SyntaxError, "Only one session handler at a time is supported at the moment in this extension\n.");68 return NULL;69 }70 py_cleanup_cb = PyCb;71 Py_XINCREF(py_cleanup_cb);72 66 73 ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback ); 67 Py_XINCREF(PyCb); 68 69 ret = fd_sess_handler_create_internal ( &hdl, call_the_python_cleanup_callback, PyCb ); 74 70 if (ret != 0) { 75 71 DI_ERROR(ret, NULL, NULL); … … 80 76 ~session_handler() { 81 77 struct session_handler * hdl = self; 82 int ret = fd_sess_handler_destroy(&hdl); 78 PyObject * cb = NULL; 79 80 int ret = fd_sess_handler_destroy(&hdl, (void *)&cb); 83 81 if (ret != 0) { 84 82 DI_ERROR(ret, NULL, NULL); 85 83 } 86 84 /* Now free the callback */ 87 Py_XDECREF(py_cleanup_cb); 88 py_cleanup_cb = NULL; 85 Py_XDECREF(cb); 89 86 return; 90 87 }
Note: See TracChangeset
for help on using the changeset viewer.