mirror of https://github.com/getdnsapi/getdns.git
Add a method to change unbound async mode (getdns_extra) between fork and thread
This commit is contained in:
parent
f149dedaaf
commit
b548cce9d8
|
@ -1791,4 +1791,19 @@ getdns_context_set_return_dnssec_status(getdns_context* context, int enabled) {
|
|||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
getdns_return_t
|
||||
getdns_context_set_use_threads(getdns_context* context, int use_threads) {
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
if (context->resolution_type_set != 0) {
|
||||
/* already setup */
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
int r = 0;
|
||||
if (use_threads)
|
||||
r = ub_ctx_async(context->unbound_ctx, 1);
|
||||
else
|
||||
r = ub_ctx_async(context->unbound_ctx, 0);
|
||||
return r == 0 ? GETDNS_RETURN_GOOD : GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
|
||||
/* context.c */
|
||||
|
|
|
@ -55,6 +55,8 @@ int getdns_context_fd(getdns_context* context);
|
|||
/* process async reqs */
|
||||
getdns_return_t getdns_context_process_async(getdns_context* context);
|
||||
|
||||
/* tells underlying unbound to use background threads or fork */
|
||||
getdns_return_t getdns_context_set_use_threads(getdns_context* context, int use_threads);
|
||||
|
||||
/* extensions */
|
||||
typedef void (*getdns_timeout_callback) (void* userarg);
|
||||
|
|
Loading…
Reference in New Issue