@@ -173,12 +173,11 @@ callback_shim(getdns_context *context, getdns_callback_type_t type, getdns_dict
173
173
return ;
174
174
/* need to throw exceptiion XXX */
175
175
}
176
-
177
176
/* Python callback prototype: */
178
177
/* callback(context, callback_type, response, userarg, tid) */
179
178
state = PyGILState_Ensure ();
180
- PyObject_CallFunction (getdns_runner , "OHOsl " , context , type , response ,
181
- callback_data -> userarg , tid );
179
+ PyObject_CallFunction (getdns_runner , "OHOsi " , context , type , response ,
180
+ callback_data -> userarg , ( int ) tid );
182
181
PyGILState_Release (state );
183
182
}
184
183
@@ -255,7 +254,7 @@ dispatch_query(PyObject *context_capsule,
255
254
uint16_t request_type ,
256
255
PyDictObject * extensions_obj ,
257
256
void * userarg ,
258
- long tid ,
257
+ int tid ,
259
258
char * callback )
260
259
261
260
{
@@ -346,7 +345,6 @@ dispatch_query(PyObject *context_capsule,
346
345
return NULL ;
347
346
}
348
347
349
- callback_data -> userarg = userarg ;
350
348
if ((ret = getdns_extension_set_libevent_base (context , gen_event_base )) != GETDNS_RETURN_GOOD ) {
351
349
PyErr_SetString (getdns_error , GETDNS_RETURN_GENERIC_ERROR_TEXT );
352
350
return NULL ;
@@ -409,6 +407,7 @@ do_query(PyObject *context_capsule,
409
407
PyObject * getdns_runner ;
410
408
pthread_t runner_thread ;
411
409
pygetdns_async_args_blob * async_blob ;
410
+ char * u ;
412
411
413
412
if ((main_module = PyImport_AddModule ("__main__" )) == 0 ) {
414
413
PyErr_SetString (getdns_error , "No __main__" );
@@ -423,16 +422,18 @@ do_query(PyObject *context_capsule,
423
422
async_blob = (pygetdns_async_args_blob * )malloc (sizeof (pygetdns_async_args_blob ));
424
423
async_blob -> context_capsule = context_capsule ;
425
424
async_blob -> name = malloc (256 ); /* XXX magic number */
426
- strncpy (async_blob -> name , name , strlen (name ));
425
+ strncpy (async_blob -> name , name , strlen (name )+ 1 );
427
426
async_blob -> type = request_type ;
428
427
async_blob -> extensions = extensions_obj ;
429
- async_blob -> userarg = userarg ;
428
+ async_blob -> userarg = (pygetdns_libevent_callback_data * )malloc (sizeof (pygetdns_libevent_callback_data ));
429
+ u = malloc (1024 );
430
+ strncpy (u , userarg , strlen (userarg )+ 1 );
431
+ async_blob -> userarg -> userarg = u ;
430
432
async_blob -> tid = tid ;
431
433
async_blob -> callback = malloc (256 ); /* XXX magic number */
432
434
strncpy (async_blob -> callback , callback , strlen (callback ));
433
435
async_blob -> runner = getdns_runner ;
434
436
async_blob -> userarg -> callback_func = getdns_runner ;
435
-
436
437
Py_BEGIN_ALLOW_THREADS ;
437
438
pthread_create (& runner_thread , NULL , (void * )marshall_query , (void * )async_blob );
438
439
pthread_detach (runner_thread );
0 commit comments