aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-22 16:01:19 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-22 16:01:19 +0100
commitb5a1e1405a9d294e4b06b13da7b1cf6a3638f6ab (patch)
tree5b378ee24a31f5ef00845c0681a0f95a28173273 /src
parent2b6c2c7dbae7977f3a28f19a9b4cc9e136b90ba5 (diff)
downloadgnunet-b5a1e1405a9d294e4b06b13da7b1cf6a3638f6ab.tar.gz
gnunet-b5a1e1405a9d294e4b06b13da7b1cf6a3638f6ab.zip
fix bug introduced with BLOCK change where we would eval a local reply twice and discard it as duplicate in the end
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-dht_neighbours.c82
-rw-r--r--src/dht/gnunet-service-dht_routing.c6
-rw-r--r--src/dht/gnunet-service-dht_routing.h4
3 files changed, 54 insertions, 38 deletions
diff --git a/src/dht/gnunet-service-dht_neighbours.c b/src/dht/gnunet-service-dht_neighbours.c
index eed82dad5..e7586ad24 100644
--- a/src/dht/gnunet-service-dht_neighbours.c
+++ b/src/dht/gnunet-service-dht_neighbours.c
@@ -1023,10 +1023,10 @@ select_peer (const struct GNUNET_HashCode *key,
1023 count = 0; 1023 count = 0;
1024 while ((pos != NULL) && (count < bucket_size)) 1024 while ((pos != NULL) && (count < bucket_size))
1025 { 1025 {
1026 if ((bloom == NULL) || 1026 if ( (NULL == bloom) ||
1027 (GNUNET_NO == 1027 (GNUNET_NO ==
1028 GNUNET_CONTAINER_bloomfilter_test (bloom, 1028 GNUNET_CONTAINER_bloomfilter_test (bloom,
1029 &pos->phash))) 1029 &pos->phash)))
1030 { 1030 {
1031 dist = get_distance (key, 1031 dist = get_distance (key,
1032 &pos->phash); 1032 &pos->phash);
@@ -1060,8 +1060,14 @@ select_peer (const struct GNUNET_HashCode *key,
1060 } 1060 }
1061 if (NULL == chosen) 1061 if (NULL == chosen)
1062 GNUNET_STATISTICS_update (GDS_stats, 1062 GNUNET_STATISTICS_update (GDS_stats,
1063 gettext_noop ("# Peer selection failed"), 1, 1063 gettext_noop ("# Peer selection failed"),
1064 1,
1064 GNUNET_NO); 1065 GNUNET_NO);
1066 else
1067 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1068 "Selected peer `%s' in greedy routing for %s\n",
1069 GNUNET_i2s (chosen->id),
1070 GNUNET_h2s (key));
1065 return chosen; 1071 return chosen;
1066 } 1072 }
1067 1073
@@ -1071,12 +1077,12 @@ select_peer (const struct GNUNET_HashCode *key,
1071 for (bc = 0; bc <= closest_bucket; bc++) 1077 for (bc = 0; bc <= closest_bucket; bc++)
1072 { 1078 {
1073 pos = k_buckets[bc].head; 1079 pos = k_buckets[bc].head;
1074 while ((pos != NULL) && (count < bucket_size)) 1080 while ( (NULL != pos) && (count < bucket_size) )
1075 { 1081 {
1076 if ((bloom != NULL) && 1082 if ( (NULL != bloom) &&
1077 (GNUNET_YES == 1083 (GNUNET_YES ==
1078 GNUNET_CONTAINER_bloomfilter_test (bloom, 1084 GNUNET_CONTAINER_bloomfilter_test (bloom,
1079 &pos->phash))) 1085 &pos->phash)) )
1080 { 1086 {
1081 GNUNET_STATISTICS_update (GDS_stats, 1087 GNUNET_STATISTICS_update (GDS_stats,
1082 gettext_noop 1088 gettext_noop
@@ -1116,7 +1122,13 @@ select_peer (const struct GNUNET_HashCode *key,
1116 continue; /* Ignore bloomfiltered peers */ 1122 continue; /* Ignore bloomfiltered peers */
1117 } 1123 }
1118 if (0 == selected--) 1124 if (0 == selected--)
1125 {
1126 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1127 "Selected peer `%s' in random routing for %s\n",
1128 GNUNET_i2s (pos->id),
1129 GNUNET_h2s (key));
1119 return pos; 1130 return pos;
1131 }
1120 } 1132 }
1121 } 1133 }
1122 GNUNET_break (0); 1134 GNUNET_break (0);
@@ -1161,7 +1173,9 @@ get_target_peers (const struct GNUNET_HashCode *key,
1161 struct PeerInfo *); 1173 struct PeerInfo *);
1162 for (off = 0; off < ret; off++) 1174 for (off = 0; off < ret; off++)
1163 { 1175 {
1164 nxt = select_peer (key, bloom, hop_count); 1176 nxt = select_peer (key,
1177 bloom,
1178 hop_count);
1165 if (NULL == nxt) 1179 if (NULL == nxt)
1166 break; 1180 break;
1167 rtargets[off] = nxt; 1181 rtargets[off] = nxt;
@@ -1242,7 +1256,8 @@ GDS_NEIGHBOURS_handle_put (enum GNUNET_BLOCK_Type type,
1242 "Adding myself (%s) to PUT bloomfilter for %s\n", 1256 "Adding myself (%s) to PUT bloomfilter for %s\n",
1243 GNUNET_i2s (&my_identity), 1257 GNUNET_i2s (&my_identity),
1244 GNUNET_h2s (key)); 1258 GNUNET_h2s (key));
1245 GNUNET_CONTAINER_bloomfilter_add (bf, &my_identity_hash); 1259 GNUNET_CONTAINER_bloomfilter_add (bf,
1260 &my_identity_hash);
1246 GNUNET_STATISTICS_update (GDS_stats, 1261 GNUNET_STATISTICS_update (GDS_stats,
1247 gettext_noop ("# PUT requests routed"), 1262 gettext_noop ("# PUT requests routed"),
1248 1, 1263 1,
@@ -1946,7 +1961,7 @@ handle_find_peer (const struct GNUNET_PeerIdentity *sender,
1946/** 1961/**
1947 * Handle a result from local datacache for a GET operation. 1962 * Handle a result from local datacache for a GET operation.
1948 * 1963 *
1949 * @param cls the `struct ClientHandle` of the client doing the query 1964 * @param cls the `struct PeerInfo` for which this is a reply
1950 * @param type type of the block 1965 * @param type type of the block
1951 * @param expiration_time when does the content expire 1966 * @param expiration_time when does the content expire
1952 * @param key key for the content 1967 * @param key key for the content
@@ -1969,6 +1984,7 @@ handle_local_result (void *cls,
1969 const void *data, 1984 const void *data,
1970 size_t data_size) 1985 size_t data_size)
1971{ 1986{
1987 struct PeerInfo *peer = cls;
1972 char *pp; 1988 char *pp;
1973 1989
1974 pp = GNUNET_STRINGS_pp2s (put_path, 1990 pp = GNUNET_STRINGS_pp2s (put_path,
@@ -1978,15 +1994,13 @@ handle_local_result (void *cls,
1978 GNUNET_h2s (key), 1994 GNUNET_h2s (key),
1979 pp); 1995 pp);
1980 GNUNET_free (pp); 1996 GNUNET_free (pp);
1981 // FIXME: we can probably do better here by 1997 GDS_NEIGHBOURS_handle_reply (peer->id,
1982 // passing the peer that did the query in the closure... 1998 type,
1983 GDS_ROUTING_process (NULL, 1999 expiration_time,
1984 type, 2000 key,
1985 expiration_time, 2001 put_path_length, put_path,
1986 key, 2002 get_path_length, get_path,
1987 put_path_length, put_path, 2003 data, data_size);
1988 0, NULL,
1989 data, data_size);
1990} 2004}
1991 2005
1992 2006
@@ -2037,11 +2051,6 @@ handle_dht_p2p_get (void *cls,
2037 const char *xquery; 2051 const char *xquery;
2038 int forwarded; 2052 int forwarded;
2039 2053
2040 if (NULL == peer)
2041 {
2042 GNUNET_break (0);
2043 return;
2044 }
2045 /* parse and validate message */ 2054 /* parse and validate message */
2046 msize = ntohs (get->header.size); 2055 msize = ntohs (get->header.size);
2047 xquery_size = ntohl (get->xquery_size); 2056 xquery_size = ntohl (get->xquery_size);
@@ -2106,14 +2115,6 @@ handle_dht_p2p_get (void *cls,
2106 "filter-size", 2115 "filter-size",
2107 reply_bf_size, 2116 reply_bf_size,
2108 NULL); 2117 NULL);
2109 /* remember request for routing replies */
2110 GDS_ROUTING_add (peer->id,
2111 type,
2112 bg, /* bg now owned by routing, but valid at least until end of this function! */
2113 options,
2114 &get->key,
2115 xquery,
2116 xquery_size);
2117 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2118 "GET for %s at %s after %u hops\n", 2119 "GET for %s at %s after %u hops\n",
2119 GNUNET_h2s (&get->key), 2120 GNUNET_h2s (&get->key),
@@ -2142,7 +2143,7 @@ handle_dht_p2p_get (void *cls,
2142 xquery_size, 2143 xquery_size,
2143 bg, 2144 bg,
2144 &handle_local_result, 2145 &handle_local_result,
2145 NULL); 2146 peer);
2146 } 2147 }
2147 } 2148 }
2148 else 2149 else
@@ -2153,6 +2154,15 @@ handle_dht_p2p_get (void *cls,
2153 GNUNET_NO); 2154 GNUNET_NO);
2154 } 2155 }
2155 2156
2157 /* remember request for routing replies */
2158 GDS_ROUTING_add (peer->id,
2159 type,
2160 bg, /* bg now owned by routing, but valid at least until end of this function! */
2161 options,
2162 &get->key,
2163 xquery,
2164 xquery_size);
2165
2156 /* P2P forwarding */ 2166 /* P2P forwarding */
2157 forwarded = GNUNET_NO; 2167 forwarded = GNUNET_NO;
2158 if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST) 2168 if (eval != GNUNET_BLOCK_EVALUATION_OK_LAST)
diff --git a/src/dht/gnunet-service-dht_routing.c b/src/dht/gnunet-service-dht_routing.c
index 252995737..eebeedc22 100644
--- a/src/dht/gnunet-service-dht_routing.c
+++ b/src/dht/gnunet-service-dht_routing.c
@@ -209,6 +209,11 @@ process (void *cls,
209 rr->xquery_size, 209 rr->xquery_size,
210 pc->data, 210 pc->data,
211 pc->data_size); 211 pc->data_size);
212 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
213 "Result for %s of type %d was evaluated as %d\n",
214 GNUNET_h2s (key),
215 pc->type,
216 eval);
212 switch (eval) 217 switch (eval)
213 { 218 {
214 case GNUNET_BLOCK_EVALUATION_OK_MORE: 219 case GNUNET_BLOCK_EVALUATION_OK_MORE:
@@ -271,6 +276,7 @@ process (void *cls,
271 * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching 276 * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching
272 * request recently. 277 * request recently.
273 * 278 *
279 * @param cls NULL (why have it?)
274 * @param type type of the block 280 * @param type type of the block
275 * @param expiration_time when does the content expire 281 * @param expiration_time when does the content expire
276 * @param key key for the content 282 * @param key key for the content
diff --git a/src/dht/gnunet-service-dht_routing.h b/src/dht/gnunet-service-dht_routing.h
index 1d9284164..39f877ad8 100644
--- a/src/dht/gnunet-service-dht_routing.h
+++ b/src/dht/gnunet-service-dht_routing.h
@@ -38,7 +38,7 @@
38 * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching 38 * GDS_NEIGHBOURS_handle_reply for all peers that sent us a matching
39 * request recently. 39 * request recently.
40 * 40 *
41 * @param cls closure 41 * @param cls NULL (why have it?)
42 * @param type type of the block 42 * @param type type of the block
43 * @param expiration_time when does the content expire 43 * @param expiration_time when does the content expire
44 * @param key key for the content 44 * @param key key for the content
@@ -72,7 +72,7 @@ GDS_ROUTING_process (void *cls,
72 * @param key key for the content 72 * @param key key for the content
73 * @param xquery extended query 73 * @param xquery extended query
74 * @param xquery_size number of bytes in @a xquery 74 * @param xquery_size number of bytes in @a xquery
75*/ 75 */
76void 76void
77GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender, 77GDS_ROUTING_add (const struct GNUNET_PeerIdentity *sender,
78 enum GNUNET_BLOCK_Type type, 78 enum GNUNET_BLOCK_Type type,