diff options
Diffstat (limited to 'src/topology/gnunet-daemon-topology.c')
-rw-r--r-- | src/topology/gnunet-daemon-topology.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 3aa518fa1..3a2a421d4 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c | |||
@@ -1016,6 +1016,8 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
1016 | { | 1016 | { |
1017 | int have_address; | 1017 | int have_address; |
1018 | struct GNUNET_PeerIdentity pid; | 1018 | struct GNUNET_PeerIdentity pid; |
1019 | struct GNUNET_TIME_Absolute dt; | ||
1020 | struct GNUNET_HELLO_Message *nh; | ||
1019 | struct Peer *peer; | 1021 | struct Peer *peer; |
1020 | uint16_t size; | 1022 | uint16_t size; |
1021 | 1023 | ||
@@ -1034,17 +1036,36 @@ consider_for_advertising (const struct GNUNET_HELLO_Message *hello) | |||
1034 | peer = GNUNET_CONTAINER_multihashmap_get (peers, | 1036 | peer = GNUNET_CONTAINER_multihashmap_get (peers, |
1035 | &pid.hashPubKey); | 1037 | &pid.hashPubKey); |
1036 | if (peer == NULL) | 1038 | if (peer == NULL) |
1037 | peer = make_peer (&pid, hello, GNUNET_NO); | 1039 | { |
1040 | peer = make_peer (&pid, hello, GNUNET_NO); | ||
1041 | } | ||
1042 | else if (peer->hello != NULL) | ||
1043 | { | ||
1044 | dt = GNUNET_HELLO_equals (peer->hello, | ||
1045 | hello, | ||
1046 | GNUNET_TIME_absolute_get()); | ||
1047 | if (dt.value == GNUNET_TIME_UNIT_FOREVER_ABS.value) | ||
1048 | return; /* nothing new here */ | ||
1049 | } | ||
1038 | #if DEBUG_TOPOLOGY | 1050 | #if DEBUG_TOPOLOGY |
1039 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1040 | "Found `%s' from peer `%s' for advertising\n", | 1052 | "Found `%s' from peer `%s' for advertising\n", |
1041 | "HELLO", | 1053 | "HELLO", |
1042 | GNUNET_i2s (&pid)); | 1054 | GNUNET_i2s (&pid)); |
1043 | #endif | 1055 | #endif |
1044 | size = GNUNET_HELLO_size (hello); | 1056 | if (peer->hello != NULL) |
1045 | GNUNET_free_non_null (peer->hello); | 1057 | { |
1046 | peer->hello = GNUNET_malloc (size); | 1058 | nh = GNUNET_HELLO_merge (peer->hello, |
1047 | memcpy (peer->hello, hello, size); | 1059 | hello); |
1060 | GNUNET_free (peer->hello); | ||
1061 | peer->hello = nh; | ||
1062 | } | ||
1063 | else | ||
1064 | { | ||
1065 | size = GNUNET_HELLO_size (hello); | ||
1066 | peer->hello = GNUNET_malloc (size); | ||
1067 | memcpy (peer->hello, hello, size); | ||
1068 | } | ||
1048 | if (peer->filter != NULL) | 1069 | if (peer->filter != NULL) |
1049 | GNUNET_CONTAINER_bloomfilter_free (peer->filter); | 1070 | GNUNET_CONTAINER_bloomfilter_free (peer->filter); |
1050 | setup_filter (peer); | 1071 | setup_filter (peer); |