diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-10-24 21:45:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-10-24 21:45:44 +0000 |
commit | 47d7779091557516cda70ab9038dc2d460b0b3bb (patch) | |
tree | 2c8a334a40268d8b3717332a9d7278909830fab7 /src/peerinfo/peerinfo_api.c | |
parent | 267b8b5e0e264627f334a18ae1bf3f3a88ff2e32 (diff) | |
download | gnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.tar.gz gnunet-47d7779091557516cda70ab9038dc2d460b0b3bb.zip |
giving client API option for auto-retry, making more often use of transmit_and_get_response API and removing auto-retry code where enhanced client API can be used for it
Diffstat (limited to 'src/peerinfo/peerinfo_api.c')
-rw-r--r-- | src/peerinfo/peerinfo_api.c | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 14efa1708..d02ec3f2d 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c | |||
@@ -106,7 +106,9 @@ GNUNET_PEERINFO_add_peer (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
106 | cc->msg = &pam->header; | 106 | cc->msg = &pam->header; |
107 | GNUNET_CLIENT_notify_transmit_ready (client, | 107 | GNUNET_CLIENT_notify_transmit_ready (client, |
108 | ntohs (pam->header.size), | 108 | ntohs (pam->header.size), |
109 | ADD_PEER_TIMEOUT, ©_and_free, cc); | 109 | ADD_PEER_TIMEOUT, |
110 | GNUNET_YES, | ||
111 | ©_and_free, cc); | ||
110 | } | 112 | } |
111 | 113 | ||
112 | 114 | ||
@@ -203,36 +205,6 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
203 | } | 205 | } |
204 | 206 | ||
205 | 207 | ||
206 | static size_t | ||
207 | copy_then_receive (void *cls, size_t size, void *buf) | ||
208 | { | ||
209 | struct InfoContext *ic = cls; | ||
210 | const struct GNUNET_MessageHeader *msg = | ||
211 | (const struct GNUNET_MessageHeader *) &ic[1]; | ||
212 | uint16_t msize; | ||
213 | |||
214 | if (buf == NULL) | ||
215 | { | ||
216 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
217 | _ | ||
218 | ("Failed to transmit message of type %u to `%s' service.\n"), | ||
219 | ntohs (msg->type), "peerinfo"); | ||
220 | ic->callback (ic->callback_cls, NULL, NULL, 1); | ||
221 | GNUNET_CLIENT_disconnect (ic->client); | ||
222 | GNUNET_free (ic); | ||
223 | return 0; | ||
224 | } | ||
225 | msize = ntohs (msg->size); | ||
226 | GNUNET_assert (size >= msize); | ||
227 | memcpy (buf, msg, msize); | ||
228 | GNUNET_CLIENT_receive (ic->client, | ||
229 | &info_handler, | ||
230 | ic, | ||
231 | GNUNET_TIME_absolute_get_remaining (ic->timeout)); | ||
232 | return msize; | ||
233 | } | ||
234 | |||
235 | |||
236 | /** | 208 | /** |
237 | * Call a method for each known matching host and change | 209 | * Call a method for each known matching host and change |
238 | * its trust value. The method will be invoked once for | 210 | * its trust value. The method will be invoked once for |
@@ -293,8 +265,20 @@ GNUNET_PEERINFO_for_all (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
293 | lpm->trust_change = htonl (trust_delta); | 265 | lpm->trust_change = htonl (trust_delta); |
294 | memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); | 266 | memcpy (&lpm->peer, peer, sizeof (struct GNUNET_PeerIdentity)); |
295 | } | 267 | } |
296 | GNUNET_CLIENT_notify_transmit_ready (client, | 268 | if (GNUNET_OK != |
297 | hs, timeout, ©_then_receive, ihc); | 269 | GNUNET_CLIENT_transmit_and_get_response (client, |
270 | (const struct GNUNET_MessageHeader*) &ihc[1], | ||
271 | timeout, | ||
272 | GNUNET_YES, | ||
273 | &info_handler, | ||
274 | ihc)) | ||
275 | { | ||
276 | GNUNET_break (0); | ||
277 | ihc->callback (ihc->callback_cls, NULL, NULL, 1); | ||
278 | GNUNET_CLIENT_disconnect (ihc->client); | ||
279 | GNUNET_free (ihc); | ||
280 | return; | ||
281 | } | ||
298 | } | 282 | } |
299 | 283 | ||
300 | /* end of peerinfo_api.c */ | 284 | /* end of peerinfo_api.c */ |