diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-27 22:27:11 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-27 22:27:11 +0000 |
commit | b3443c6ab7b18ee57866ac531bf9f40aa3eb5261 (patch) | |
tree | 272b88c59422b9954acb6c7ee08e4a2e9e520a70 /src/include | |
parent | 64d39ac5f14b54eecc2c7cd99b04d05ff04a894f (diff) | |
download | gnunet-b3443c6ab7b18ee57866ac531bf9f40aa3eb5261.tar.gz gnunet-b3443c6ab7b18ee57866ac531bf9f40aa3eb5261.zip |
allowing cancellation of resolver requests
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_client_lib.h | 13 | ||||
-rw-r--r-- | src/include/gnunet_resolver_service.h | 46 |
2 files changed, 44 insertions, 15 deletions
diff --git a/src/include/gnunet_client_lib.h b/src/include/gnunet_client_lib.h index c78df41c7..2ba9e135f 100644 --- a/src/include/gnunet_client_lib.h +++ b/src/include/gnunet_client_lib.h | |||
@@ -64,10 +64,15 @@ struct GNUNET_CLIENT_Connection *GNUNET_CLIENT_connect (struct | |||
64 | *cfg); | 64 | *cfg); |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * Destroy connection with the service. This will | 67 | * Destroy connection with the service. This will automatically |
68 | * automatically cancel any pending "receive" request | 68 | * cancel any pending "receive" request (however, the handler will |
69 | * (however, the handler will *NOT* be called, not | 69 | * *NOT* be called, not even with a NULL message). Any pending |
70 | * even with a NULL message). | 70 | * transmission request will also be cancelled UNLESS the callback for |
71 | * the transmission request has already been called, in which case the | ||
72 | * transmission is guaranteed to complete before the socket is fully | ||
73 | * destroyed. | ||
74 | * | ||
75 | * @param sock handle to the service connection | ||
71 | */ | 76 | */ |
72 | void GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock); | 77 | void GNUNET_CLIENT_disconnect (struct GNUNET_CLIENT_Connection *sock); |
73 | 78 | ||
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h index b7fb1532a..f8b1e79c7 100644 --- a/src/include/gnunet_resolver_service.h +++ b/src/include/gnunet_resolver_service.h | |||
@@ -53,6 +53,13 @@ typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls, | |||
53 | 53 | ||
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Handle to a request given to the resolver. Can be used to cancel | ||
57 | * the request prior to the timeout or successful execution. | ||
58 | */ | ||
59 | struct GNUNET_RESOLVER_RequestHandle; | ||
60 | |||
61 | |||
62 | /** | ||
56 | * Convert a string to one or more IP addresses. | 63 | * Convert a string to one or more IP addresses. |
57 | * | 64 | * |
58 | * @param sched scheduler to use | 65 | * @param sched scheduler to use |
@@ -62,8 +69,9 @@ typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls, | |||
62 | * @param callback function to call with addresses | 69 | * @param callback function to call with addresses |
63 | * @param callback_cls closure for callback | 70 | * @param callback_cls closure for callback |
64 | * @param timeout how long to try resolving | 71 | * @param timeout how long to try resolving |
72 | * @return handle that can be used to cancel the request, NULL on error | ||
65 | */ | 73 | */ |
66 | void | 74 | struct GNUNET_RESOLVER_RequestHandle * |
67 | GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | 75 | GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, |
68 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 76 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
69 | const char *hostname, | 77 | const char *hostname, |
@@ -82,8 +90,9 @@ GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
82 | * @param callback function to call with addresses | 90 | * @param callback function to call with addresses |
83 | * @param cls closure for callback | 91 | * @param cls closure for callback |
84 | * @param timeout how long to try resolving | 92 | * @param timeout how long to try resolving |
93 | * @return handle that can be used to cancel the request, NULL on error | ||
85 | */ | 94 | */ |
86 | void | 95 | struct GNUNET_RESOLVER_RequestHandle * |
87 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | 96 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, |
88 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 97 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
89 | int domain, | 98 | int domain, |
@@ -104,7 +113,7 @@ typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls, | |||
104 | 113 | ||
105 | 114 | ||
106 | /** | 115 | /** |
107 | * Get an IP address as a string. | 116 | * Perform a reverse DNS lookup. |
108 | * | 117 | * |
109 | * @param sched scheduler to use | 118 | * @param sched scheduler to use |
110 | * @param cfg configuration to use | 119 | * @param cfg configuration to use |
@@ -114,15 +123,30 @@ typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls, | |||
114 | * @param timeout how long to try resolving | 123 | * @param timeout how long to try resolving |
115 | * @param callback function to call with hostnames | 124 | * @param callback function to call with hostnames |
116 | * @param cls closure for callback | 125 | * @param cls closure for callback |
126 | * @return handle that can be used to cancel the request, NULL on error | ||
117 | */ | 127 | */ |
118 | void GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | 128 | struct GNUNET_RESOLVER_RequestHandle * |
119 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 129 | GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, |
120 | const struct sockaddr *sa, | 130 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
121 | socklen_t salen, | 131 | const struct sockaddr *sa, |
122 | int do_resolve, | 132 | socklen_t salen, |
123 | struct GNUNET_TIME_Relative timeout, | 133 | int do_resolve, |
124 | GNUNET_RESOLVER_HostnameCallback callback, | 134 | struct GNUNET_TIME_Relative timeout, |
125 | void *cls); | 135 | GNUNET_RESOLVER_HostnameCallback callback, |
136 | void *cls); | ||
137 | |||
138 | |||
139 | /** | ||
140 | * Cancel a request that is still pending with the resolver. | ||
141 | * Note that a client MUST NOT cancel a request that has | ||
142 | * been completed (i.e, the callback has been called to | ||
143 | * signal timeout or the final result). | ||
144 | * | ||
145 | * @param h handle of request to cancel | ||
146 | */ | ||
147 | void | ||
148 | GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h); | ||
149 | |||
126 | 150 | ||
127 | #if 0 /* keep Emacsens' auto-indent happy */ | 151 | #if 0 /* keep Emacsens' auto-indent happy */ |
128 | { | 152 | { |