diff options
author | Vsevolod Novikov <novikov@doroga.tv> | 2011-01-29 20:12:10 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2011-04-25 19:47:16 +0200 |
commit | ca015f1a45c68aa1d641678cfc13ce0df0c58fe0 (patch) | |
tree | 7e74d24a9eec1aeb541c84359257326b5f938ff4 /lib/hostthre.c | |
parent | 722f286f801e456c790cec0ea10306220d4969e2 (diff) |
asynch resolvers: unified
Introducing an internal API for handling of different async resolver
backends.
Diffstat (limited to 'lib/hostthre.c')
-rw-r--r-- | lib/hostthre.c | 75 |
1 files changed, 69 insertions, 6 deletions
diff --git a/lib/hostthre.c b/lib/hostthre.c index dc8e4af74..d91a5d77c 100644 --- a/lib/hostthre.c +++ b/lib/hostthre.c @@ -88,6 +88,70 @@ **********************************************************************/ #ifdef CURLRES_THREADED +/* + * Curl_resolver_global_init() - the generic low-level name resolve API. + * Called from curl_global_init() to initialize global resolver environment. + * Does nothing here. + */ +int Curl_resolver_global_init() +{ + return CURLE_OK; +} + +/* + * Curl_resolver_global_cleanup() - the generic low-level name resolve API. + * Called from curl_global_cleanup() to destroy global resolver environment. + * Does nothing here. + */ +void Curl_resolver_global_cleanup() +{ +} + +/* + * Curl_resolver_init() - the generic low-level name resolve API. + * Called from curl_easy_init() -> Curl_open() to initialize resolver URL-state specific environment + * ('resolver' member of the UrlState structure). + * Does nothing here. + */ +int Curl_resolver_init(void **resolver) +{ + (void)resolver; + return CURLE_OK; +} + +/* + * Curl_resolver_cleanup() - the generic low-level name resolve API. + * Called from curl_easy_cleanup() -> Curl_close() to cleanup resolver URL-state specific environment + * ('resolver' member of the UrlState structure). + * Does nothing here. + */ +void Curl_resolver_cleanup(void *resolver) +{ + (void)resolver; +} + +/* + * Curl_resolver_duphandle() - the generic low-level name resolve API. + * Called from curl_easy_duphandle() to duplicate resolver URL state-specific environment + * ('resolver' member of the UrlState structure). + * Does nothing here. + */ +int Curl_resolver_duphandle(void **to, void *from) +{ + (void)to; + (void)from; + return CURLE_OK; +} + +static void destroy_async_data(struct Curl_async *); +/* + * Cancel all possibly still on-going resolves for this connection. + */ +void Curl_async_cancel(struct connectdata *conn) +{ + destroy_async_data(&conn->async); +} + /* This function is used to init a threaded resolve */ static bool init_resolve_thread(struct connectdata *conn, const char *hostname, int port, @@ -253,10 +317,9 @@ static unsigned int CURL_STDCALL gethostbyname_thread (void *arg) #endif /* HAVE_GETADDRINFO */ /* - * Curl_destroy_thread_data() cleans up async resolver data and thread handle. - * Complementary of ares_destroy. + * destroy_async_data() cleans up async resolver data and thread handle. */ -void Curl_destroy_thread_data (struct Curl_async *async) +static void destroy_async_data (struct Curl_async *async) { if(async->hostname) free(async->hostname); @@ -336,7 +399,7 @@ static bool init_resolve_thread (struct connectdata *conn, return TRUE; err_exit: - Curl_destroy_thread_data(&conn->async); + destroy_async_data(&conn->async); SET_ERRNO(err); @@ -386,7 +449,7 @@ CURLcode Curl_wait_for_resolv(struct connectdata *conn, } } - Curl_destroy_thread_data(&conn->async); + destroy_async_data(&conn->async); if(!conn->async.dns) conn->bits.close = TRUE; @@ -419,7 +482,7 @@ CURLcode Curl_is_resolved(struct connectdata *conn, if (done) { getaddrinfo_complete(conn); - Curl_destroy_thread_data(&conn->async); + destroy_async_data(&conn->async); if(!conn->async.dns) { failf(data, "Could not resolve host: %s; %s", |