diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-08-30 21:42:10 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-08-30 21:42:10 +0000 |
commit | 4a9e2610bde0a3f3899ec3b114e712c81978e962 (patch) | |
tree | 62a2465d1a8838b9da785ebb85014515efd2287e /src/hostlist | |
parent | ffa0156860c584608db5bde1038e127c6e8fda21 (diff) | |
download | gnunet-4a9e2610bde0a3f3899ec3b114e712c81978e962.tar.gz gnunet-4a9e2610bde0a3f3899ec3b114e712c81978e962.zip |
nitpicks
Diffstat (limited to 'src/hostlist')
-rw-r--r-- | src/hostlist/test_gnunet_daemon_hostlist_learning.c | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index d1a04ffe8..4bbbdb4d0 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c | |||
@@ -288,8 +288,7 @@ static int ad_arrive_handler (void *cls, | |||
288 | uint32_t distance) | 288 | uint32_t distance) |
289 | { | 289 | { |
290 | char *hostname; | 290 | char *hostname; |
291 | char *expected_uri = GNUNET_malloc (MAX_URL_LEN); | 291 | char *expected_uri; |
292 | |||
293 | unsigned long long port; | 292 | unsigned long long port; |
294 | size_t size; | 293 | size_t size; |
295 | const struct GNUNET_MessageHeader * incoming; | 294 | const struct GNUNET_MessageHeader * incoming; |
@@ -299,10 +298,9 @@ static int ad_arrive_handler (void *cls, | |||
299 | "HTTPPORT", | 298 | "HTTPPORT", |
300 | &port)) | 299 | &port)) |
301 | { | 300 | { |
302 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 301 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
303 | "Could not read advertising server's configuration\n" ); | 302 | "Could not read advertising server's configuration\n" ); |
304 | if ( NULL != expected_uri ) GNUNET_free ( expected_uri ); | 303 | return GNUNET_SYSERR; |
305 | return GNUNET_SYSERR; | ||
306 | } | 304 | } |
307 | 305 | ||
308 | if ( GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, | 306 | if ( GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_string (adv_peer.cfg, |
@@ -311,35 +309,23 @@ static int ad_arrive_handler (void *cls, | |||
311 | &hostname)) | 309 | &hostname)) |
312 | hostname = GNUNET_RESOLVER_local_fqdn_get (); | 310 | hostname = GNUNET_RESOLVER_local_fqdn_get (); |
313 | 311 | ||
314 | if (NULL != hostname) | 312 | GNUNET_asprintf (&expected_uri, |
315 | { | 313 | "http://%s:%u/", |
316 | size = strlen (hostname); | 314 | hostname != NULL ? hostname : "localhost", |
317 | if (size + 15 > MAX_URL_LEN) | 315 | (unsigned int) port); |
318 | { | ||
319 | GNUNET_break (0); | ||
320 | } | ||
321 | else | ||
322 | { | ||
323 | GNUNET_asprintf (&expected_uri, | ||
324 | "http://%s:%u/", | ||
325 | hostname, | ||
326 | (unsigned int) port); | ||
327 | } | ||
328 | } | ||
329 | |||
330 | incoming = (const struct GNUNET_MessageHeader *) message; | 316 | incoming = (const struct GNUNET_MessageHeader *) message; |
331 | current_adv_uri = strdup ((char*) &incoming[1]); | 317 | current_adv_uri = strdup ((char*) &incoming[1]); |
332 | if ( 0 == strcmp( expected_uri, current_adv_uri ) ) | 318 | if ( 0 == strcmp( expected_uri, current_adv_uri ) ) |
333 | { | 319 | { |
334 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 320 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
335 | "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); | 321 | "Recieved hostlist advertisement with URI `%s' as expected\n", current_adv_uri); |
336 | adv_arrived = GNUNET_YES; | 322 | adv_arrived = GNUNET_YES; |
337 | adv_sent = GNUNET_YES; | 323 | adv_sent = GNUNET_YES; |
338 | } | 324 | } |
339 | else | 325 | else |
340 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 326 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
341 | "Expected URI `%s' and recieved URI `%s' differ\n", expected_uri, current_adv_uri); | 327 | "Expected URI `%s' and recieved URI `%s' differ\n", expected_uri, current_adv_uri); |
342 | GNUNET_free_non_null (expected_uri); | 328 | GNUNET_free (expected_uri); |
343 | GNUNET_free_non_null (hostname); | 329 | GNUNET_free_non_null (hostname); |
344 | return GNUNET_OK; | 330 | return GNUNET_OK; |
345 | } | 331 | } |