Add a method to change unbound async mode (getdns_extra) between fork and thread

This commit is contained in:
Neel Goyal 2014-02-28 19:24:09 -05:00
parent f149dedaaf
commit b548cce9d8
2 changed files with 17 additions and 0 deletions

View File

@ -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 */

View File

@ -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);