diff options
-rw-r--r-- | configure.ac | 115 | ||||
-rw-r--r-- | po/POTFILES.in | 2 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_connection.c | 11 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.c | 93 | ||||
-rw-r--r-- | src/cadet/gnunet-service-cadet_peer.h | 8 |
5 files changed, 136 insertions, 93 deletions
diff --git a/configure.ac b/configure.ac index 3072684fc..67633b107 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -491,26 +491,6 @@ else | |||
491 | fi | 491 | fi |
492 | 492 | ||
493 | 493 | ||
494 | # libidn | ||
495 | AC_MSG_CHECKING([if Libidn can be used]) | ||
496 | AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]], | ||
497 | [Support IDN (needs GNU Libidn)]), | ||
498 | libidn=$withval, libidn=yes) | ||
499 | if test "$libidn" != "no"; then | ||
500 | if test "$libidn" != "yes"; then | ||
501 | LDFLAGS="${LDFLAGS} -L$libidn/lib" | ||
502 | CPPFLAGS="${CPPFLAGS} -I$libidn/include" | ||
503 | fi | ||
504 | fi | ||
505 | libidn=no | ||
506 | AC_CHECK_HEADER(idna.h, | ||
507 | AC_CHECK_LIB(idn, stringprep_check_version, | ||
508 | [libidn=yes LIBS="${LIBS} -lidn"], []), []) | ||
509 | if test "$libidn" != "yes"; then | ||
510 | AC_MSG_FAILURE([GNUnet requires libidn. | ||
511 | libidn-1.13 should be sufficient, newer versions work too.]) | ||
512 | fi | ||
513 | AC_MSG_RESULT($libidn) | ||
514 | 494 | ||
515 | # restore LIBS | 495 | # restore LIBS |
516 | LIBS=$SAVE_LIBS | 496 | LIBS=$SAVE_LIBS |
@@ -639,7 +619,69 @@ fi | |||
639 | # restore LIBS | 619 | # restore LIBS |
640 | LIBS=$SAVE_LIBS | 620 | LIBS=$SAVE_LIBS |
641 | 621 | ||
622 | |||
623 | # libidn | ||
624 | AC_MSG_CHECKING([if Libidn can be used]) | ||
625 | AC_ARG_WITH(libidn, AC_HELP_STRING([--with-libidn=[DIR]], | ||
626 | [Support IDN (needs GNU Libidn)]), | ||
627 | libidn=$withval, libidn=yes) | ||
628 | if test "$libidn" != "no"; then | ||
629 | if test "$libidn" != "yes"; then | ||
630 | LDFLAGS="${LDFLAGS} -L$libidn/lib" | ||
631 | CPPFLAGS="${CPPFLAGS} -I$libidn/include" | ||
632 | fi | ||
642 | fi | 633 | fi |
634 | libidn=no | ||
635 | AC_CHECK_HEADER(idna.h, | ||
636 | AC_CHECK_LIB(idn, stringprep_check_version, | ||
637 | [libidn=yes LIBS="${LIBS} -lidn"], []), []) | ||
638 | if test "$libidn" != "yes"; then | ||
639 | AC_MSG_FAILURE([GNUnet requires libidn. | ||
640 | libidn-1.13 should be sufficient, newer versions work too.]) | ||
641 | fi | ||
642 | AC_MSG_RESULT($libidn) | ||
643 | |||
644 | |||
645 | # test for zlib | ||
646 | SAVE_LDFLAGS=$LDFLAGS | ||
647 | SAVE_CPPFLAGS=$CPPFLAGS | ||
648 | AC_ARG_WITH(zlib, | ||
649 | [ --with-zlib[[=DIR]] use libz in DIR], | ||
650 | [AS_IF([test "$withval" = "no"], | ||
651 | [AC_MSG_ERROR([GNUnet requires zlib])], | ||
652 | [test "$withval" != "yes"], | ||
653 | [ | ||
654 | Z_DIR=$withval | ||
655 | CPPFLAGS="${CPPFLAGS} -I$withval/include" | ||
656 | LDFLAGS="${LDFLAGS} -L$withval/lib" | ||
657 | ]) | ||
658 | ]) | ||
659 | AC_CHECK_HEADER(zlib.h, | ||
660 | [], | ||
661 | [AC_MSG_ERROR([GNUnet requires zlib])]) | ||
662 | AC_CHECK_LIB(z, compress2, | ||
663 | [ | ||
664 | AC_DEFINE([HAVE_ZLIB], [], [Have compression library]) | ||
665 | if test "x${Z_DIR}" != "x"; then | ||
666 | Z_CFLAGS="-I${Z_DIR}/include" | ||
667 | Z_LIBS="-L${Z_DIR}/lib -lz" | ||
668 | else | ||
669 | Z_LIBS="-lz" | ||
670 | fi], | ||
671 | [AC_MSG_ERROR([GNUnet requires zlib])]) | ||
672 | AC_SUBST(Z_CFLAGS) | ||
673 | AC_SUBST(Z_LIBS) | ||
674 | |||
675 | |||
676 | |||
677 | # restore LIBS | ||
678 | LIBS=$SAVE_LIBS | ||
679 | |||
680 | |||
681 | fi | ||
682 | |||
683 | # check for iconv | ||
684 | AM_ICONV | ||
643 | 685 | ||
644 | # test for libunistring | 686 | # test for libunistring |
645 | gl_LIBUNISTRING | 687 | gl_LIBUNISTRING |
@@ -722,36 +764,6 @@ if test "$found_postgresql" = "yes"; then | |||
722 | fi | 764 | fi |
723 | AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) | 765 | AM_CONDITIONAL(HAVE_POSTGRESQL, test x$postgres = xtrue) |
724 | 766 | ||
725 | # test for zlib | ||
726 | SAVE_LDFLAGS=$LDFLAGS | ||
727 | SAVE_CPPFLAGS=$CPPFLAGS | ||
728 | AC_ARG_WITH(zlib, | ||
729 | [ --with-zlib[[=DIR]] use libz in DIR], | ||
730 | [AS_IF([test "$withval" = "no"], | ||
731 | [AC_MSG_ERROR([GNUnet requires zlib])], | ||
732 | [test "$withval" != "yes"], | ||
733 | [ | ||
734 | Z_DIR=$withval | ||
735 | CPPFLAGS="${CPPFLAGS} -I$withval/include" | ||
736 | LDFLAGS="${LDFLAGS} -L$withval/lib" | ||
737 | ]) | ||
738 | ]) | ||
739 | AC_CHECK_HEADER(zlib.h, | ||
740 | [], | ||
741 | [AC_MSG_ERROR([GNUnet requires zlib])]) | ||
742 | AC_CHECK_LIB(z, compress2, | ||
743 | [ | ||
744 | AC_DEFINE([HAVE_ZLIB], [], [Have compression library]) | ||
745 | if test "x${Z_DIR}" != "x"; then | ||
746 | Z_CFLAGS="-I${Z_DIR}/include" | ||
747 | Z_LIBS="-L${Z_DIR}/lib -lz" | ||
748 | else | ||
749 | Z_LIBS="-lz" | ||
750 | fi], | ||
751 | [AC_MSG_ERROR([GNUnet requires zlib])]) | ||
752 | AC_SUBST(Z_CFLAGS) | ||
753 | AC_SUBST(Z_LIBS) | ||
754 | |||
755 | LDFLAGS=$SAVE_LDFLAGS | 767 | LDFLAGS=$SAVE_LDFLAGS |
756 | CPPFLAGS=$SAVE_CPPFLAGS | 768 | CPPFLAGS=$SAVE_CPPFLAGS |
757 | 769 | ||
@@ -930,9 +942,6 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :]) | |||
930 | AM_GNU_GETTEXT([external]) | 942 | AM_GNU_GETTEXT([external]) |
931 | AM_GNU_GETTEXT_VERSION([0.19.3]) | 943 | AM_GNU_GETTEXT_VERSION([0.19.3]) |
932 | 944 | ||
933 | # check for iconv | ||
934 | AM_ICONV | ||
935 | |||
936 | # Checks for standard typedefs, structures, and compiler characteristics. | 945 | # Checks for standard typedefs, structures, and compiler characteristics. |
937 | AC_TYPE_PID_T | 946 | AC_TYPE_PID_T |
938 | AC_TYPE_SIZE_T | 947 | AC_TYPE_SIZE_T |
diff --git a/po/POTFILES.in b/po/POTFILES.in index 34bdaedd8..dd166adcc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in | |||
@@ -274,6 +274,7 @@ src/rps/gnunet-rps.c | |||
274 | src/rps/gnunet-service-rps.c | 274 | src/rps/gnunet-service-rps.c |
275 | src/rps/gnunet-service-rps_sampler.c | 275 | src/rps/gnunet-service-rps_sampler.c |
276 | src/rps/rps_api.c | 276 | src/rps/rps_api.c |
277 | src/rps/rps-test_util.c | ||
277 | src/scalarproduct/gnunet-scalarproduct.c | 278 | src/scalarproduct/gnunet-scalarproduct.c |
278 | src/scalarproduct/gnunet-service-scalarproduct_alice.c | 279 | src/scalarproduct/gnunet-service-scalarproduct_alice.c |
279 | src/scalarproduct/gnunet-service-scalarproduct_bob.c | 280 | src/scalarproduct/gnunet-service-scalarproduct_bob.c |
@@ -457,6 +458,7 @@ src/include/gnunet_common.h | |||
457 | src/include/gnunet_mq_lib.h | 458 | src/include/gnunet_mq_lib.h |
458 | src/include/gnunet_postgres_lib.h | 459 | src/include/gnunet_postgres_lib.h |
459 | src/include/gnunet_time_lib.h | 460 | src/include/gnunet_time_lib.h |
461 | src/rps/rps-test_util.h | ||
460 | src/scalarproduct/scalarproduct.h | 462 | src/scalarproduct/scalarproduct.h |
461 | src/testbed/testbed_api.h | 463 | src/testbed/testbed_api.h |
462 | src/testbed/testbed_api_operations.h | 464 | src/testbed/testbed_api_operations.h |
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index dd4577447..47b4f3955 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c | |||
@@ -1547,8 +1547,8 @@ register_neighbors (struct CadetConnection *c) | |||
1547 | GCP_is_neighbor (c->next_peer)); | 1547 | GCP_is_neighbor (c->next_peer)); |
1548 | return GNUNET_SYSERR; | 1548 | return GNUNET_SYSERR; |
1549 | } | 1549 | } |
1550 | GCP_add_connection (c->next_peer, c); | 1550 | GCP_add_connection (c->next_peer, c, GNUNET_NO); |
1551 | GCP_add_connection (c->prev_peer, c); | 1551 | GCP_add_connection (c->prev_peer, c, GNUNET_YES); |
1552 | 1552 | ||
1553 | return GNUNET_OK; | 1553 | return GNUNET_OK; |
1554 | } | 1554 | } |
@@ -1566,10 +1566,10 @@ unregister_neighbors (struct CadetConnection *c) | |||
1566 | 1566 | ||
1567 | peer = get_next_hop (c); | 1567 | peer = get_next_hop (c); |
1568 | GNUNET_assert (c->next_peer == peer); | 1568 | GNUNET_assert (c->next_peer == peer); |
1569 | GCP_remove_connection (peer, c); | 1569 | GCP_remove_connection (peer, c, GNUNET_NO); |
1570 | peer = get_prev_hop (c); | 1570 | peer = get_prev_hop (c); |
1571 | GNUNET_assert (c->prev_peer == peer); | 1571 | GNUNET_assert (c->prev_peer == peer); |
1572 | GCP_remove_connection (peer, c); | 1572 | GCP_remove_connection (peer, c, GNUNET_YES); |
1573 | } | 1573 | } |
1574 | 1574 | ||
1575 | 1575 | ||
@@ -1583,7 +1583,8 @@ unregister_neighbors (struct CadetConnection *c) | |||
1583 | * @param peer Peer. | 1583 | * @param peer Peer. |
1584 | */ | 1584 | */ |
1585 | static void | 1585 | static void |
1586 | add_to_peer (struct CadetConnection *c, struct CadetPeer *peer) | 1586 | add_to_peer (struct CadetConnection *c, |
1587 | struct CadetPeer *peer) | ||
1587 | { | 1588 | { |
1588 | GCP_add_tunnel (peer); | 1589 | GCP_add_tunnel (peer); |
1589 | c->t = GCP_get_tunnel (peer); | 1590 | c->t = GCP_get_tunnel (peer); |
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 705165c51..4abcd1a0b 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c | |||
@@ -156,9 +156,17 @@ struct CadetPeer | |||
156 | struct CadetTunnel *tunnel; | 156 | struct CadetTunnel *tunnel; |
157 | 157 | ||
158 | /** | 158 | /** |
159 | * Connections that go through this peer, indexed by tid; | 159 | * Connections that go through this peer where we |
160 | * are the predecessor; indexed by tid; do NOT | ||
161 | * try to combine with @e connections_succ (#3794). | ||
160 | */ | 162 | */ |
161 | struct GNUNET_CONTAINER_MultiHashMap *connections; | 163 | struct GNUNET_CONTAINER_MultiHashMap *connections_pred; |
164 | |||
165 | /** | ||
166 | * Connections that go through this peer where we are | ||
167 | * the successor; indexed by tid; | ||
168 | */ | ||
169 | struct GNUNET_CONTAINER_MultiHashMap *connections_succ; | ||
162 | 170 | ||
163 | /** | 171 | /** |
164 | * Handle for queued transmissions | 172 | * Handle for queued transmissions |
@@ -314,10 +322,11 @@ GCP_debug (const struct CadetPeer *p, enum GNUNET_ErrorType level) | |||
314 | 322 | ||
315 | LOG2 (level, "PPP core transmit handle %p\n", p->core_transmit); | 323 | LOG2 (level, "PPP core transmit handle %p\n", p->core_transmit); |
316 | LOG2 (level, "PPP DHT GET handle %p\n", p->search_h); | 324 | LOG2 (level, "PPP DHT GET handle %p\n", p->search_h); |
317 | if (NULL != p->connections) | 325 | conns = 0; |
318 | conns = GNUNET_CONTAINER_multihashmap_size (p->connections); | 326 | if (NULL != p->connections_pred) |
319 | else | 327 | conns = GNUNET_CONTAINER_multihashmap_size (p->connections_pred); |
320 | conns = 0; | 328 | if (NULL != p->connections_succ) |
329 | conns += GNUNET_CONTAINER_multihashmap_size (p->connections_succ); | ||
321 | LOG2 (level, "PPP # connections over link to peer: %u\n", conns); | 330 | LOG2 (level, "PPP # connections over link to peer: %u\n", conns); |
322 | queue_debug (p, level); | 331 | queue_debug (p, level); |
323 | LOG2 (level, "PPP DEBUG END\n"); | 332 | LOG2 (level, "PPP DEBUG END\n"); |
@@ -428,8 +437,10 @@ core_connect (void *cls, | |||
428 | "# peers", | 437 | "# peers", |
429 | 1, | 438 | 1, |
430 | GNUNET_NO); | 439 | GNUNET_NO); |
431 | GNUNET_assert (NULL == mp->connections); | 440 | GNUNET_assert (NULL == mp->connections_pred); |
432 | mp->connections = GNUNET_CONTAINER_multihashmap_create (32, GNUNET_YES); | 441 | GNUNET_assert (NULL == mp->connections_succ); |
442 | mp->connections_pred = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES); | ||
443 | mp->connections_succ = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES); | ||
433 | 444 | ||
434 | if ( (NULL != GCP_get_tunnel (mp)) && | 445 | if ( (NULL != GCP_get_tunnel (mp)) && |
435 | (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) | 446 | (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) |
@@ -468,11 +479,16 @@ core_disconnect (void *cls, | |||
468 | "DISCONNECTED %s <= %s\n", | 479 | "DISCONNECTED %s <= %s\n", |
469 | own_id, GNUNET_i2s (peer)); | 480 | own_id, GNUNET_i2s (peer)); |
470 | direct_path = pop_direct_path (p); | 481 | direct_path = pop_direct_path (p); |
471 | GNUNET_CONTAINER_multihashmap_iterate (p->connections, | 482 | GNUNET_CONTAINER_multihashmap_iterate (p->connections_succ, |
483 | ¬ify_broken, | ||
484 | p); | ||
485 | GNUNET_CONTAINER_multihashmap_iterate (p->connections_pred, | ||
472 | ¬ify_broken, | 486 | ¬ify_broken, |
473 | p); | 487 | p); |
474 | GNUNET_CONTAINER_multihashmap_destroy (p->connections); | 488 | GNUNET_CONTAINER_multihashmap_destroy (p->connections_succ); |
475 | p->connections = NULL; | 489 | p->connections_succ = NULL; |
490 | GNUNET_CONTAINER_multihashmap_destroy (p->connections_pred); | ||
491 | p->connections_pred = NULL; | ||
476 | if (NULL != p->core_transmit) | 492 | if (NULL != p->core_transmit) |
477 | { | 493 | { |
478 | GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit); | 494 | GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit); |
@@ -1366,7 +1382,8 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, | |||
1366 | 1382 | ||
1367 | if (error_level == GNUNET_ERROR_TYPE_ERROR) | 1383 | if (error_level == GNUNET_ERROR_TYPE_ERROR) |
1368 | GNUNET_assert (0); | 1384 | GNUNET_assert (0); |
1369 | if (NULL == peer->connections) | 1385 | if ( (NULL == peer->connections_pred) || |
1386 | (NULL == peer->connections_succ) ) | ||
1370 | { | 1387 | { |
1371 | /* We are not connected to this peer, ignore request. */ | 1388 | /* We are not connected to this peer, ignore request. */ |
1372 | LOG (GNUNET_ERROR_TYPE_WARNING, "%s not a neighbor\n", GCP_2s (peer)); | 1389 | LOG (GNUNET_ERROR_TYPE_WARNING, "%s not a neighbor\n", GCP_2s (peer)); |
@@ -1849,11 +1866,11 @@ GCP_connect (struct CadetPeer *peer) | |||
1849 | * not yet known to be connected. | 1866 | * not yet known to be connected. |
1850 | * | 1867 | * |
1851 | * This happens quite often during testing when running cadet | 1868 | * This happens quite often during testing when running cadet |
1852 | * under valgrind: core connect notifications come very late and the | 1869 | * under valgrind: core connect notifications come very late |
1853 | * DHT result has already come and created a valid path. | 1870 | * and the DHT result has already come and created a valid |
1854 | * In this case, the peer->connections hashmap will be NULL and | 1871 | * path. In this case, the peer->connections_{pred,succ} |
1855 | * tunnel_use_path will not be able to create a connection from that | 1872 | * hashmaps will be NULL and tunnel_use_path will not be able |
1856 | * path. | 1873 | * to create a connection from that path. |
1857 | * | 1874 | * |
1858 | * Re-running the DHT GET should give core time to callback. | 1875 | * Re-running the DHT GET should give core time to callback. |
1859 | * | 1876 | * |
@@ -1902,7 +1919,8 @@ GCP_is_neighbor (const struct CadetPeer *peer) | |||
1902 | { | 1919 | { |
1903 | struct CadetPeerPath *path; | 1920 | struct CadetPeerPath *path; |
1904 | 1921 | ||
1905 | if (NULL == peer->connections) | 1922 | if ( (NULL == peer->connections_pred) || |
1923 | (NULL == peer->connections_succ) ) | ||
1906 | return GNUNET_NO; | 1924 | return GNUNET_NO; |
1907 | 1925 | ||
1908 | for (path = peer->path_head; NULL != path; path = path->next) | 1926 | for (path = peer->path_head; NULL != path; path = path->next) |
@@ -1942,10 +1960,12 @@ GCP_add_tunnel (struct CadetPeer *peer) | |||
1942 | * | 1960 | * |
1943 | * @param peer Peer to add connection to. | 1961 | * @param peer Peer to add connection to. |
1944 | * @param c Connection to add. | 1962 | * @param c Connection to add. |
1963 | * @param pred #GNUNET_YES if we are predecessor, #GNUNET_NO if we are successor | ||
1945 | */ | 1964 | */ |
1946 | void | 1965 | void |
1947 | GCP_add_connection (struct CadetPeer *peer, | 1966 | GCP_add_connection (struct CadetPeer *peer, |
1948 | struct CadetConnection *c) | 1967 | struct CadetConnection *c, |
1968 | int pred) | ||
1949 | { | 1969 | { |
1950 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1970 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1951 | "adding connection %s\n", | 1971 | "adding connection %s\n", |
@@ -1953,19 +1973,20 @@ GCP_add_connection (struct CadetPeer *peer, | |||
1953 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1973 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1954 | "to peer %s\n", | 1974 | "to peer %s\n", |
1955 | GCP_2s (peer)); | 1975 | GCP_2s (peer)); |
1956 | GNUNET_assert (NULL != peer->connections); | 1976 | GNUNET_assert (NULL != peer->connections_pred); |
1957 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1977 | GNUNET_assert (NULL != peer->connections_succ); |
1958 | "peer %s has %u connections.\n", | ||
1959 | GCP_2s (peer), | ||
1960 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | ||
1961 | GNUNET_assert (GNUNET_OK == | 1978 | GNUNET_assert (GNUNET_OK == |
1962 | GNUNET_CONTAINER_multihashmap_put (peer->connections, | 1979 | GNUNET_CONTAINER_multihashmap_put ((GNUNET_YES == pred) |
1980 | ? peer->connections_pred | ||
1981 | : peer->connections_succ, | ||
1963 | GCC_get_h (c), | 1982 | GCC_get_h (c), |
1964 | c, | 1983 | c, |
1965 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 1984 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
1966 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1985 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1967 | " now has %u connections.\n", | 1986 | "Peer %s is now predecessor on %u connections and successor on %u connections.\n", |
1968 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 1987 | GCP_2s (peer), |
1988 | GNUNET_CONTAINER_multihashmap_size (peer->connections_pred), | ||
1989 | GNUNET_CONTAINER_multihashmap_size (peer->connections_succ)); | ||
1969 | } | 1990 | } |
1970 | 1991 | ||
1971 | 1992 | ||
@@ -2159,10 +2180,12 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) | |||
2159 | * | 2180 | * |
2160 | * @param peer Peer to remove connection from. | 2181 | * @param peer Peer to remove connection from. |
2161 | * @param c Connection to remove. | 2182 | * @param c Connection to remove. |
2183 | * @param pred #GNUNET_YES if we were predecessor, #GNUNET_NO if we were successor | ||
2162 | */ | 2184 | */ |
2163 | void | 2185 | void |
2164 | GCP_remove_connection (struct CadetPeer *peer, | 2186 | GCP_remove_connection (struct CadetPeer *peer, |
2165 | const struct CadetConnection *c) | 2187 | const struct CadetConnection *c, |
2188 | int pred) | ||
2166 | { | 2189 | { |
2167 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2190 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2168 | "removing connection %s\n", | 2191 | "removing connection %s\n", |
@@ -2170,19 +2193,23 @@ GCP_remove_connection (struct CadetPeer *peer, | |||
2170 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2193 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2171 | "from peer %s\n", | 2194 | "from peer %s\n", |
2172 | GCP_2s (peer)); | 2195 | GCP_2s (peer)); |
2173 | |||
2174 | if ( (NULL == peer) || | 2196 | if ( (NULL == peer) || |
2175 | (NULL == peer->connections) ) | 2197 | (NULL == peer->connections_pred) || |
2198 | (NULL == peer->connections_succ) ) | ||
2176 | return; | 2199 | return; |
2177 | (void) GNUNET_CONTAINER_multihashmap_remove (peer->connections, | 2200 | (void) GNUNET_CONTAINER_multihashmap_remove ((GNUNET_YES == pred) |
2201 | ? peer->connections_pred | ||
2202 | : peer->connections_succ, | ||
2178 | GCC_get_h (c), | 2203 | GCC_get_h (c), |
2179 | c); | 2204 | c); |
2180 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2205 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2181 | "peer %s ok, has %u connections left.\n", | 2206 | "Peer %s remains predecessor for %u and successor for %u connections.\n", |
2182 | GCP_2s (peer), | 2207 | GCP_2s (peer), |
2183 | GNUNET_CONTAINER_multihashmap_size (peer->connections)); | 2208 | GNUNET_CONTAINER_multihashmap_size (peer->connections_pred), |
2209 | GNUNET_CONTAINER_multihashmap_size (peer->connections_succ)); | ||
2184 | } | 2210 | } |
2185 | 2211 | ||
2212 | |||
2186 | /** | 2213 | /** |
2187 | * Start the DHT search for new paths towards the peer: we don't have | 2214 | * Start the DHT search for new paths towards the peer: we don't have |
2188 | * enough good connections. | 2215 | * enough good connections. |
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index af937007a..eae7764c3 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h | |||
@@ -247,10 +247,12 @@ GCP_add_tunnel (struct CadetPeer *peer); | |||
247 | * | 247 | * |
248 | * @param peer Peer to add connection to. | 248 | * @param peer Peer to add connection to. |
249 | * @param c Connection to add. | 249 | * @param c Connection to add. |
250 | * @param pred #GNUNET_YES if we are predecessor, #GNUNET_NO if we are successor | ||
250 | */ | 251 | */ |
251 | void | 252 | void |
252 | GCP_add_connection (struct CadetPeer *peer, | 253 | GCP_add_connection (struct CadetPeer *peer, |
253 | struct CadetConnection *c); | 254 | struct CadetConnection *c, |
255 | int pred); | ||
254 | 256 | ||
255 | 257 | ||
256 | /** | 258 | /** |
@@ -316,10 +318,12 @@ GCP_remove_path (struct CadetPeer *peer, | |||
316 | * | 318 | * |
317 | * @param peer Peer to remove connection from. | 319 | * @param peer Peer to remove connection from. |
318 | * @param c Connection to remove. | 320 | * @param c Connection to remove. |
321 | * @param pred #GNUNET_YES if we were predecessor, #GNUNET_NO if we were successor | ||
319 | */ | 322 | */ |
320 | void | 323 | void |
321 | GCP_remove_connection (struct CadetPeer *peer, | 324 | GCP_remove_connection (struct CadetPeer *peer, |
322 | const struct CadetConnection *c); | 325 | const struct CadetConnection *c, |
326 | int pred); | ||
323 | 327 | ||
324 | 328 | ||
325 | /** | 329 | /** |