Changeset 1014:908ffbb81f60 in freeDiameter for extensions/dbg_interactive/messages.i
- Timestamp:
- Mar 29, 2013, 6:30:59 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/dbg_interactive/messages.i
r1013 r1014 41 41 struct anscb_py_layer { 42 42 PyObject * cb; 43 PyObject * expcb; 43 44 PyObject * data; 44 45 }; … … 67 68 result = PyObject_CallFunction(l->cb, "(OO)", PyMsg, l->data); 68 69 Py_XDECREF(l->cb); 70 Py_XDECREF(l->expcb); 69 71 Py_XDECREF(l->data); 70 72 free(l); … … 86 88 /* it actually happens automatically when we do nothing. */ 87 89 } 90 91 static void expcb_python(void *cbdata, DiamId_t sentto, size_t senttolen, struct msg ** msg) { 92 /* The python callback is received in cbdata */ 93 PyObject * result, *PyMsg; 94 struct anscb_py_layer * l = cbdata; 95 96 if (!l) { 97 fd_log_debug("Internal error! Python callback disappeared..."); 98 return; 99 } 100 101 SWIG_PYTHON_THREAD_BEGIN_BLOCK; 102 103 if (!msg || !*msg) { 104 PyMsg = Py_None; 105 } else { 106 PyMsg = SWIG_NewPointerObj((void *)*msg, SWIGTYPE_p_msg, 0 ); 107 } 108 109 result = PyObject_CallFunction(l->expcb, "(Os#O)", PyMsg, sentto, senttolen, l->data); 110 Py_XDECREF(l->cb); 111 Py_XDECREF(l->expcb); 112 Py_XDECREF(l->data); 113 free(l); 114 115 /* The callback is supposed to return a message or NULL */ 116 if (!SWIG_IsOK(SWIG_ConvertPtr(result, (void *)msg, SWIGTYPE_p_msg, SWIG_POINTER_DISOWN))) { 117 fd_log_debug("Error: Cannot convert the return value to message."); 118 *msg = NULL; 119 } 120 121 Py_XDECREF(result); 122 123 SWIG_PYTHON_THREAD_END_BLOCK; 124 125 } 126 127 128 88 129 %} 89 130 … … 128 169 /* SEND THE MESSAGE */ 129 170 %delobject send; /* when this has been called, the msg must not be freed anymore */ 130 void send(PyObject * PyCb = NULL, PyObject * data = NULL, unsigned int timeout = 0) {171 void send(PyObject * PyCb = NULL, PyObject * data = NULL, PyObject * PyExpCb = NULL, unsigned int timeout = 0) { 131 172 int ret; 132 173 struct msg * m = $self; … … 142 183 Py_XINCREF(PyCb); 143 184 Py_XINCREF(data); 185 Py_XINCREF(PyExpCb); 186 l->expcb = PyExpCb; 144 187 l->cb = PyCb; 145 188 l->data = data; … … 150 193 (void) clock_gettime(CLOCK_REALTIME, &ts); 151 194 ts.tv_sec += timeout; 152 ret = fd_msg_send_timeout(&m, anscb_python, l, &ts);195 ret = fd_msg_send_timeout(&m, anscb_python, l, expcb_python, &ts); 153 196 } else { 154 197 ret = fd_msg_send(&m, PyCb ? anscb_python : NULL, l);
Note: See TracChangeset
for help on using the changeset viewer.