aboutsummaryrefslogtreecommitdiff
path: root/src/transport/plugin_transport_http.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-02-13 15:10:02 +0000
committerChristian Grothoff <christian@grothoff.org>2012-02-13 15:10:02 +0000
commit5078bff0c109c309850995d764217af301597802 (patch)
tree12deba7cc2a714cf3e4b4b9e9f030408253251f9 /src/transport/plugin_transport_http.c
parent30bb20c41bda4a0221e6510495c3e5cac4bf1521 (diff)
downloadgnunet-5078bff0c109c309850995d764217af301597802.tar.gz
gnunet-5078bff0c109c309850995d764217af301597802.zip
-simplifying code
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r--src/transport/plugin_transport_http.c60
1 files changed, 14 insertions, 46 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index fb9376526..820d51ffc 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -390,15 +390,11 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar
390 struct Session *session, const void *addr, size_t addrlen, 390 struct Session *session, const void *addr, size_t addrlen,
391 int force_address) 391 int force_address)
392{ 392{
393 struct Session *s = NULL; 393 struct Session *t;
394 struct Session *t = NULL;
395 int e_peer; 394 int e_peer;
396 int e_addr; 395 int e_addr;
397 396
398 t = plugin->head; 397 for (t = plugin->head; NULL != t; t = t->next)
399 if (t == NULL)
400 return NULL;
401 while (t != NULL)
402 { 398 {
403#if 0 399#if 0
404 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, 400 GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
@@ -414,52 +410,24 @@ lookup_session_old (struct Plugin *plugin, const struct GNUNET_PeerIdentity *tar
414#endif 410#endif
415 e_peer = GNUNET_NO; 411 e_peer = GNUNET_NO;
416 e_addr = GNUNET_NO; 412 e_addr = GNUNET_NO;
417
418 if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity))) 413 if (0 == memcmp (target, &t->target, sizeof (struct GNUNET_PeerIdentity)))
419 { 414 {
420 e_peer = GNUNET_YES; 415 e_peer = GNUNET_YES;
421 if (addrlen == t->addrlen) 416 if ( (addrlen == t->addrlen) &&
422 { 417 (0 == memcmp (addr, t->addr, addrlen)) )
423 if (0 == memcmp (addr, t->addr, addrlen)) 418 e_addr = GNUNET_YES;
424 { 419 if ( (t == session) &&
425 e_addr = GNUNET_YES; 420 (t->addrlen == session->addrlen) &&
426 } 421 (0 == memcmp (session->addr, t->addr, t->addrlen)) )
427 } 422 e_addr = GNUNET_YES;
428 if ((t == session))
429 {
430 if (t->addrlen == session->addrlen)
431 {
432 if (0 == memcmp (session->addr, t->addr, t->addrlen))
433 {
434 e_addr = GNUNET_YES;
435 }
436 }
437 }
438 } 423 }
439 424
440 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO)) 425 if ( ((e_peer == GNUNET_YES) && (force_address == GNUNET_NO)) ||
441 { 426 ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) && (e_addr == GNUNET_YES)) ||
442 s = t; 427 ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR)) )
443 break; 428 return t;
444 }
445 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_YES) &&
446 (e_addr == GNUNET_YES))
447 {
448 s = t;
449 break;
450 }
451 if ((e_peer == GNUNET_YES) && (force_address == GNUNET_SYSERR))
452 {
453 s = t;
454 break;
455 }
456 if (s != NULL)
457 break;
458 t = t->next;
459 } 429 }
460 430 return NULL;
461
462 return s;
463} 431}
464 432
465struct Session * 433struct Session *