mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'master' of https://github.com/getdnsapi/getdns
This commit is contained in:
commit
6d661193e7
|
@ -1213,6 +1213,18 @@ getdns_cancel_callback(struct getdns_context *context,
|
||||||
getdns_transaction_t transaction_id)
|
getdns_transaction_t transaction_id)
|
||||||
{
|
{
|
||||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
|
|
||||||
|
if (context->processing) {
|
||||||
|
/* When called from within a callback, do not execute pending
|
||||||
|
* context destroys.
|
||||||
|
* The (other) callback handler will handle it.
|
||||||
|
*
|
||||||
|
* ( because callbacks occur in getdns_context_cancel_request,
|
||||||
|
* and they may destroy the context )
|
||||||
|
*/
|
||||||
|
return getdns_context_cancel_request(context, transaction_id, 1);
|
||||||
|
}
|
||||||
|
|
||||||
context->processing = 1;
|
context->processing = 1;
|
||||||
getdns_return_t r = getdns_context_cancel_request(context, transaction_id, 1);
|
getdns_return_t r = getdns_context_cancel_request(context, transaction_id, 1);
|
||||||
if (context->extension) {
|
if (context->extension) {
|
||||||
|
@ -1635,15 +1647,34 @@ getdns_extension_detach_eventloop(struct getdns_context* context)
|
||||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||||
if (context->extension) {
|
if (context->extension) {
|
||||||
|
/* When called from within a callback, do not execute pending
|
||||||
|
* context destroys.
|
||||||
|
* The (other) callback handler will handle it.
|
||||||
|
*
|
||||||
|
* ( because callbacks occur in cancel_outstanding_requests,
|
||||||
|
* and they may destroy the context )
|
||||||
|
*/
|
||||||
|
int within_callback = context->processing;
|
||||||
|
if (! within_callback) {
|
||||||
|
context->processing = 1;
|
||||||
|
}
|
||||||
/* cancel all outstanding requests */
|
/* cancel all outstanding requests */
|
||||||
cancel_outstanding_requests(context, 1);
|
cancel_outstanding_requests(context, 1);
|
||||||
r = context->extension->cleanup_data(context, context->extension_data);
|
r = context->extension->cleanup_data(context,
|
||||||
if (r != GETDNS_RETURN_GOOD) {
|
context->extension_data);
|
||||||
return r;
|
if (r == GETDNS_RETURN_GOOD) {
|
||||||
}
|
|
||||||
context->extension = NULL;
|
context->extension = NULL;
|
||||||
context->extension_data = NULL;
|
context->extension_data = NULL;
|
||||||
}
|
}
|
||||||
|
if (! within_callback) {
|
||||||
|
if (context->processing > 1) {
|
||||||
|
context->processing = 0;
|
||||||
|
getdns_context_destroy(context);
|
||||||
|
return GETDNS_RETURN_BAD_CONTEXT;
|
||||||
|
}
|
||||||
|
context->processing = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue