aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-06-17 09:29:06 +0000
committerBart Polot <bart@net.in.tum.de>2015-06-17 09:29:06 +0000
commit5e30cb01927f7f325f01dcafeccb3af043b270a1 (patch)
tree2525424664217ba733eba7b2f5f48b6bd97e3ac4 /src
parentfa09ef0c56c899026b85b98bcce196083d371ed3 (diff)
downloadgnunet-5e30cb01927f7f325f01dcafeccb3af043b270a1.tar.gz
gnunet-5e30cb01927f7f325f01dcafeccb3af043b270a1.zip
- roll back duplication of peer->connections
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c4
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c80
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h4
3 files changed, 29 insertions, 59 deletions
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 4843c276b..4791e6d03 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -1576,10 +1576,10 @@ unregister_neighbors (struct CadetConnection *c)
1576 1576
1577 peer = get_next_hop (c); 1577 peer = get_next_hop (c);
1578 GNUNET_assert (c->next_peer == peer); 1578 GNUNET_assert (c->next_peer == peer);
1579 GCP_remove_connection (peer, c, GNUNET_NO); 1579 GCP_remove_connection (peer, c);
1580 peer = get_prev_hop (c); 1580 peer = get_prev_hop (c);
1581 GNUNET_assert (c->prev_peer == peer); 1581 GNUNET_assert (c->prev_peer == peer);
1582 GCP_remove_connection (peer, c, GNUNET_YES); 1582 GCP_remove_connection (peer, c);
1583} 1583}
1584 1584
1585 1585
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 4abcd1a0b..e1dfb1a6a 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -156,17 +156,9 @@ struct CadetPeer
156 struct CadetTunnel *tunnel; 156 struct CadetTunnel *tunnel;
157 157
158 /** 158 /**
159 * Connections that go through this peer where we 159 * Connections that go through this peer; indexed by tid.
160 * are the predecessor; indexed by tid; do NOT
161 * try to combine with @e connections_succ (#3794).
162 */ 160 */
163 struct GNUNET_CONTAINER_MultiHashMap *connections_pred; 161 struct GNUNET_CONTAINER_MultiHashMap *connections;
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;
170 162
171 /** 163 /**
172 * Handle for queued transmissions 164 * Handle for queued transmissions
@@ -323,10 +315,8 @@ GCP_debug (const struct CadetPeer *p, enum GNUNET_ErrorType level)
323 LOG2 (level, "PPP core transmit handle %p\n", p->core_transmit); 315 LOG2 (level, "PPP core transmit handle %p\n", p->core_transmit);
324 LOG2 (level, "PPP DHT GET handle %p\n", p->search_h); 316 LOG2 (level, "PPP DHT GET handle %p\n", p->search_h);
325 conns = 0; 317 conns = 0;
326 if (NULL != p->connections_pred) 318 if (NULL != p->connections)
327 conns = GNUNET_CONTAINER_multihashmap_size (p->connections_pred); 319 conns += GNUNET_CONTAINER_multihashmap_size (p->connections);
328 if (NULL != p->connections_succ)
329 conns += GNUNET_CONTAINER_multihashmap_size (p->connections_succ);
330 LOG2 (level, "PPP # connections over link to peer: %u\n", conns); 320 LOG2 (level, "PPP # connections over link to peer: %u\n", conns);
331 queue_debug (p, level); 321 queue_debug (p, level);
332 LOG2 (level, "PPP DEBUG END\n"); 322 LOG2 (level, "PPP DEBUG END\n");
@@ -437,10 +427,8 @@ core_connect (void *cls,
437 "# peers", 427 "# peers",
438 1, 428 1,
439 GNUNET_NO); 429 GNUNET_NO);
440 GNUNET_assert (NULL == mp->connections_pred); 430 GNUNET_assert (NULL == mp->connections);
441 GNUNET_assert (NULL == mp->connections_succ); 431 mp->connections = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
442 mp->connections_pred = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
443 mp->connections_succ = GNUNET_CONTAINER_multihashmap_create (16, GNUNET_YES);
444 432
445 if ( (NULL != GCP_get_tunnel (mp)) && 433 if ( (NULL != GCP_get_tunnel (mp)) &&
446 (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) 434 (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) )
@@ -479,16 +467,11 @@ core_disconnect (void *cls,
479 "DISCONNECTED %s <= %s\n", 467 "DISCONNECTED %s <= %s\n",
480 own_id, GNUNET_i2s (peer)); 468 own_id, GNUNET_i2s (peer));
481 direct_path = pop_direct_path (p); 469 direct_path = pop_direct_path (p);
482 GNUNET_CONTAINER_multihashmap_iterate (p->connections_succ, 470 GNUNET_CONTAINER_multihashmap_iterate (p->connections,
483 &notify_broken,
484 p);
485 GNUNET_CONTAINER_multihashmap_iterate (p->connections_pred,
486 &notify_broken, 471 &notify_broken,
487 p); 472 p);
488 GNUNET_CONTAINER_multihashmap_destroy (p->connections_succ); 473 GNUNET_CONTAINER_multihashmap_destroy (p->connections);
489 p->connections_succ = NULL; 474 p->connections = NULL;
490 GNUNET_CONTAINER_multihashmap_destroy (p->connections_pred);
491 p->connections_pred = NULL;
492 if (NULL != p->core_transmit) 475 if (NULL != p->core_transmit)
493 { 476 {
494 GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit); 477 GNUNET_CORE_notify_transmit_ready_cancel (p->core_transmit);
@@ -1382,11 +1365,10 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1382 1365
1383 if (error_level == GNUNET_ERROR_TYPE_ERROR) 1366 if (error_level == GNUNET_ERROR_TYPE_ERROR)
1384 GNUNET_assert (0); 1367 GNUNET_assert (0);
1385 if ( (NULL == peer->connections_pred) || 1368 if (NULL == peer->connections)
1386 (NULL == peer->connections_succ) )
1387 { 1369 {
1388 /* We are not connected to this peer, ignore request. */ 1370 /* We are not connected to this peer, ignore request. */
1389 LOG (GNUNET_ERROR_TYPE_WARNING, "%s not a neighbor\n", GCP_2s (peer)); 1371 LOG (GNUNET_ERROR_TYPE_INFO, "%s not a neighbor\n", GCP_2s (peer));
1390 GNUNET_STATISTICS_update (stats, "# messages dropped due to wrong hop", 1, 1372 GNUNET_STATISTICS_update (stats, "# messages dropped due to wrong hop", 1,
1391 GNUNET_NO); 1373 GNUNET_NO);
1392 return NULL; 1374 return NULL;
@@ -1919,8 +1901,7 @@ GCP_is_neighbor (const struct CadetPeer *peer)
1919{ 1901{
1920 struct CadetPeerPath *path; 1902 struct CadetPeerPath *path;
1921 1903
1922 if ( (NULL == peer->connections_pred) || 1904 if (NULL == peer->connections)
1923 (NULL == peer->connections_succ) )
1924 return GNUNET_NO; 1905 return GNUNET_NO;
1925 1906
1926 for (path = peer->path_head; NULL != path; path = path->next) 1907 for (path = peer->path_head; NULL != path; path = path->next)
@@ -1973,20 +1954,16 @@ GCP_add_connection (struct CadetPeer *peer,
1973 LOG (GNUNET_ERROR_TYPE_DEBUG, 1954 LOG (GNUNET_ERROR_TYPE_DEBUG,
1974 "to peer %s\n", 1955 "to peer %s\n",
1975 GCP_2s (peer)); 1956 GCP_2s (peer));
1976 GNUNET_assert (NULL != peer->connections_pred); 1957 GNUNET_assert (NULL != peer->connections);
1977 GNUNET_assert (NULL != peer->connections_succ);
1978 GNUNET_assert (GNUNET_OK == 1958 GNUNET_assert (GNUNET_OK ==
1979 GNUNET_CONTAINER_multihashmap_put ((GNUNET_YES == pred) 1959 GNUNET_CONTAINER_multihashmap_put (peer->connections,
1980 ? peer->connections_pred
1981 : peer->connections_succ,
1982 GCC_get_h (c), 1960 GCC_get_h (c),
1983 c, 1961 c,
1984 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); 1962 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
1985 LOG (GNUNET_ERROR_TYPE_DEBUG, 1963 LOG (GNUNET_ERROR_TYPE_DEBUG,
1986 "Peer %s is now predecessor on %u connections and successor on %u connections.\n", 1964 "Peer %s has now %u connections.\n",
1987 GCP_2s (peer), 1965 GCP_2s (peer),
1988 GNUNET_CONTAINER_multihashmap_size (peer->connections_pred), 1966 GNUNET_CONTAINER_multihashmap_size (peer->connections));
1989 GNUNET_CONTAINER_multihashmap_size (peer->connections_succ));
1990} 1967}
1991 1968
1992 1969
@@ -2180,33 +2157,28 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path)
2180 * 2157 *
2181 * @param peer Peer to remove connection from. 2158 * @param peer Peer to remove connection from.
2182 * @param c Connection to remove. 2159 * @param c Connection to remove.
2183 * @param pred #GNUNET_YES if we were predecessor, #GNUNET_NO if we were successor
2184 */ 2160 */
2185void 2161void
2186GCP_remove_connection (struct CadetPeer *peer, 2162GCP_remove_connection (struct CadetPeer *peer,
2187 const struct CadetConnection *c, 2163 const struct CadetConnection *c)
2188 int pred)
2189{ 2164{
2190 LOG (GNUNET_ERROR_TYPE_DEBUG, 2165 LOG (GNUNET_ERROR_TYPE_DEBUG,
2191 "removing connection %s\n", 2166 "Removing connection %s\n",
2192 GCC_2s (c)); 2167 GCC_2s (c));
2193 LOG (GNUNET_ERROR_TYPE_DEBUG, 2168 LOG (GNUNET_ERROR_TYPE_DEBUG,
2194 "from peer %s\n", 2169 "from peer %s\n",
2195 GCP_2s (peer)); 2170 GCP_2s (peer));
2196 if ( (NULL == peer) || 2171 if ( (NULL == peer) ||
2197 (NULL == peer->connections_pred) || 2172 (NULL == peer->connections) )
2198 (NULL == peer->connections_succ) )
2199 return; 2173 return;
2200 (void) GNUNET_CONTAINER_multihashmap_remove ((GNUNET_YES == pred) 2174 GNUNET_assert (GNUNET_YES ==
2201 ? peer->connections_pred 2175 GNUNET_CONTAINER_multihashmap_remove (peer->connections,
2202 : peer->connections_succ, 2176 GCC_get_h (c),
2203 GCC_get_h (c), 2177 c));
2204 c);
2205 LOG (GNUNET_ERROR_TYPE_DEBUG, 2178 LOG (GNUNET_ERROR_TYPE_DEBUG,
2206 "Peer %s remains predecessor for %u and successor for %u connections.\n", 2179 "Peer %s reamins with %u connections.\n",
2207 GCP_2s (peer), 2180 GCP_2s (peer),
2208 GNUNET_CONTAINER_multihashmap_size (peer->connections_pred), 2181 GNUNET_CONTAINER_multihashmap_size (peer->connections));
2209 GNUNET_CONTAINER_multihashmap_size (peer->connections_succ));
2210} 2182}
2211 2183
2212 2184
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h
index eae7764c3..fb0879a4b 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -318,12 +318,10 @@ GCP_remove_path (struct CadetPeer *peer,
318 * 318 *
319 * @param peer Peer to remove connection from. 319 * @param peer Peer to remove connection from.
320 * @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
322 */ 321 */
323void 322void
324GCP_remove_connection (struct CadetPeer *peer, 323GCP_remove_connection (struct CadetPeer *peer,
325 const struct CadetConnection *c, 324 const struct CadetConnection *c);
326 int pred);
327 325
328 326
329/** 327/**