diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-09 19:07:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-09 19:07:13 +0000 |
commit | 073c4a9ae448041fdc9a0683fed49d55ae61803e (patch) | |
tree | 9bf2bacde4723ea25f70a0cdb324a1d76be763de /src/fs/gnunet-service-fs_cp.c | |
parent | fafacaa77732d1dadcfcb10e4901dda76840a76d (diff) | |
download | gnunet-073c4a9ae448041fdc9a0683fed49d55ae61803e.tar.gz gnunet-073c4a9ae448041fdc9a0683fed49d55ae61803e.zip |
hxing
Diffstat (limited to 'src/fs/gnunet-service-fs_cp.c')
-rw-r--r-- | src/fs/gnunet-service-fs_cp.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c index 80ca8de9c..407c9f7fe 100644 --- a/src/fs/gnunet-service-fs_cp.c +++ b/src/fs/gnunet-service-fs_cp.c | |||
@@ -452,6 +452,19 @@ revive_migration (void *cls, | |||
452 | 452 | ||
453 | 453 | ||
454 | /** | 454 | /** |
455 | * Get a handle for a connected peer. | ||
456 | * | ||
457 | * @param peer peer's identity | ||
458 | */ | ||
459 | struct GSF_ConnectedPeer * | ||
460 | GSF_peer_get_ (const struct GNUNET_PeerIdentity *peer) | ||
461 | { | ||
462 | return GNUNET_CONTAINER_multihashmap_get (cp_map, | ||
463 | &peer->hashPubKey); | ||
464 | } | ||
465 | |||
466 | |||
467 | /** | ||
455 | * Handle P2P "MIGRATION_STOP" message. | 468 | * Handle P2P "MIGRATION_STOP" message. |
456 | * | 469 | * |
457 | * @param cls closure, always NULL | 470 | * @param cls closure, always NULL |
@@ -793,7 +806,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
793 | int32_t priority; | 806 | int32_t priority; |
794 | int32_t ttl; | 807 | int32_t ttl; |
795 | enum GNUNET_BLOCK_Type type; | 808 | enum GNUNET_BLOCK_Type type; |
796 | 809 | GNUNET_PEER_Id spid; | |
797 | 810 | ||
798 | msize = ntohs(message->size); | 811 | msize = ntohs(message->size); |
799 | if (msize < sizeof (struct GetMessage)) | 812 | if (msize < sizeof (struct GetMessage)) |
@@ -891,6 +904,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
891 | namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; | 904 | namespace = (0 != (bm & GET_MESSAGE_BIT_SKS_NAMESPACE)) ? &opt[bits++] : NULL; |
892 | target = (0 != (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity*) &opt[bits++]) : NULL; | 905 | target = (0 != (bm & GET_MESSAGE_BIT_TRANSMIT_TO)) ? ((const struct GNUNET_PeerIdentity*) &opt[bits++]) : NULL; |
893 | options = 0; | 906 | options = 0; |
907 | spid = 0; | ||
894 | if ( (GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority)) || | 908 | if ( (GNUNET_LOAD_get_load (cp->ppd.transmission_delay) > 3 * (1 + priority)) || |
895 | (GNUNET_LOAD_get_average (cp->ppd.transmission_delay) > | 909 | (GNUNET_LOAD_get_average (cp->ppd.transmission_delay) > |
896 | GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value * 2 + GNUNET_LOAD_get_average (GSF_rt_entry_lifetime)) ) | 910 | GNUNET_CONSTANTS_MAX_CORK_DELAY.rel_value * 2 + GNUNET_LOAD_get_average (GSF_rt_entry_lifetime)) ) |
@@ -899,6 +913,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
899 | so at best indirect the query */ | 913 | so at best indirect the query */ |
900 | priority = 0; | 914 | priority = 0; |
901 | options |= GSF_PRO_FORWARD_ONLY; | 915 | options |= GSF_PRO_FORWARD_ONLY; |
916 | spid = GNUNET_PEER_intern (other); | ||
902 | } | 917 | } |
903 | ttl = bound_ttl (ntohl (gm->ttl), priority); | 918 | ttl = bound_ttl (ntohl (gm->ttl), priority); |
904 | /* decrement ttl (always) */ | 919 | /* decrement ttl (always) */ |
@@ -972,6 +987,7 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other, | |||
972 | 1 /* anonymity */, | 987 | 1 /* anonymity */, |
973 | (uint32_t) priority, | 988 | (uint32_t) priority, |
974 | ttl, | 989 | ttl, |
990 | spid, | ||
975 | NULL, 0, /* replies_seen */ | 991 | NULL, 0, /* replies_seen */ |
976 | &handle_p2p_reply, | 992 | &handle_p2p_reply, |
977 | cp); | 993 | cp); |
@@ -1290,7 +1306,9 @@ GSF_peer_disconnect_handler_ (void *cls, | |||
1290 | 1306 | ||
1291 | cp = GNUNET_CONTAINER_multihashmap_get (cp_map, | 1307 | cp = GNUNET_CONTAINER_multihashmap_get (cp_map, |
1292 | &peer->hashPubKey); | 1308 | &peer->hashPubKey); |
1293 | GNUNET_assert (NULL != cp); | 1309 | if (NULL == cp) |
1310 | return; /* must have been disconnect from core with | ||
1311 | 'peer' == my_id, ignore */ | ||
1294 | GNUNET_CONTAINER_multihashmap_remove (cp_map, | 1312 | GNUNET_CONTAINER_multihashmap_remove (cp_map, |
1295 | &peer->hashPubKey, | 1313 | &peer->hashPubKey, |
1296 | cp); | 1314 | cp); |
@@ -1553,15 +1571,13 @@ cron_flush_trust (void *cls, | |||
1553 | 1571 | ||
1554 | /** | 1572 | /** |
1555 | * Initialize peer management subsystem. | 1573 | * Initialize peer management subsystem. |
1556 | * | ||
1557 | * @param cfg configuration to use | ||
1558 | */ | 1574 | */ |
1559 | void | 1575 | void |
1560 | GSF_connected_peer_init_ (struct GNUNET_CONFIGURATION_Handle *cfg) | 1576 | GSF_connected_peer_init_ () |
1561 | { | 1577 | { |
1562 | cp_map = GNUNET_CONTAINER_multihashmap_create (128); | 1578 | cp_map = GNUNET_CONTAINER_multihashmap_create (128); |
1563 | GNUNET_assert (GNUNET_OK == | 1579 | GNUNET_assert (GNUNET_OK == |
1564 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 1580 | GNUNET_CONFIGURATION_get_value_filename (GSF_cfg, |
1565 | "fs", | 1581 | "fs", |
1566 | "TRUST", | 1582 | "TRUST", |
1567 | &trustDirectory)); | 1583 | &trustDirectory)); |