Commit d4eda66c authored by Pekka Pessi's avatar Pekka Pessi

Added sres_is_blocking() to sres_blocking.c.

Updated sres_resolver_get_async(), too.

darcs-hash:20060427160012-65a35-e9bfcc1abc87353845b8f68a9701d7a365f45272.gz
parent 68147935
......@@ -204,6 +204,9 @@ int sres_blocking_query_sockaddr(sres_resolver_t *res,
struct sockaddr const *addr,
sres_record_t ***return_records);
/** Return true (and set it in blocking mode) if resolver can block. */
int sres_is_blocking(sres_resolver_t *res);
/** Sort the list of records */
int sres_sort_answers(sres_resolver_t *res, sres_record_t **answers);
......
......@@ -738,8 +738,12 @@ sres_async_t *
sres_resolver_get_async(sres_resolver_t const *res,
sres_update_f *callback)
{
if (res == NULL || res->res_updcb != callback)
if (res == NULL)
return su_seterrno(EFAULT), (void *)NULL;
else if (callback == NULL)
return res->res_async ? (sres_async_t *)-1 : 0;
else if (res->res_updcb != callback)
return NULL;
else
return res->res_async;
}
......
......@@ -216,6 +216,10 @@ sres_blocking_t *sres_set_blocking(sres_resolver_t *res)
if (b)
return b;
/* Check if resolver is already in asynchronous mode */
if (sres_resolver_get_async(res, NULL))
return NULL;
/* Create a synchronous (blocking) interface towards resolver */
b = calloc(1, sizeof *b);
......@@ -229,6 +233,14 @@ sres_blocking_t *sres_set_blocking(sres_resolver_t *res)
return b;
}
/** Return true (and set it in blocking mode) if resolver can block. */
int sres_is_blocking(sres_resolver_t *res)
{
if (res == NULL)
return 0;
return sres_set_blocking(res) != NULL;
}
/** Send a DNS query, return results.
*
* @retval >0 if query was responded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment