aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-19 14:09:50 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-19 14:09:50 +0000
commite79f6019ce2f082bd247e1d4fca950d0c7cb7b57 (patch)
tree73aeea23d0369416c746a69065c695d7ed023b9f /src
parent24bd0eabe9599e8c3da2f86aeed49ba53d52816a (diff)
downloadgnunet-e79f6019ce2f082bd247e1d4fca950d0c7cb7b57.tar.gz
gnunet-e79f6019ce2f082bd247e1d4fca950d0c7cb7b57.zip
prevent loopback routing, add some statistics, faster re-transmit
Diffstat (limited to 'src')
-rw-r--r--src/fs/gnunet-service-fs.c14
-rw-r--r--src/fs/gnunet-service-fs_cp.c4
-rw-r--r--src/fs/gnunet-service-fs_lc.c2
-rw-r--r--src/fs/gnunet-service-fs_pe.c21
-rw-r--r--src/fs/gnunet-service-fs_pr.c25
-rw-r--r--src/fs/gnunet-service-fs_pr.h2
6 files changed, 51 insertions, 17 deletions
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c
index bf6984dd6..6ea47c2e2 100644
--- a/src/fs/gnunet-service-fs.c
+++ b/src/fs/gnunet-service-fs.c
@@ -258,6 +258,15 @@ consider_request_for_forwarding (void *cls,
258{ 258{
259 struct GSF_PendingRequest *pr = cls; 259 struct GSF_PendingRequest *pr = cls;
260 260
261 if (GNUNET_YES !=
262 GSF_pending_request_test_target_ (pr,
263 peer))
264 {
265 GNUNET_STATISTICS_update (GSF_stats,
266 gettext_noop ("# Loopback routes suppressed"), 1,
267 GNUNET_NO);
268 return;
269 }
261 GSF_plan_add_ (cp, pr); 270 GSF_plan_add_ (cp, pr);
262} 271}
263 272
@@ -430,7 +439,12 @@ consider_peer_for_forwarding (void *cls, const GNUNET_HashCode * key,
430 if (GNUNET_YES != 439 if (GNUNET_YES !=
431 GSF_pending_request_test_target_ (pr, 440 GSF_pending_request_test_target_ (pr,
432 &pid)) 441 &pid))
442 {
443 GNUNET_STATISTICS_update (GSF_stats,
444 gettext_noop ("# Loopback routes suppressed"), 1,
445 GNUNET_NO);
433 return GNUNET_YES; 446 return GNUNET_YES;
447 }
434 GSF_plan_add_ (cp, pr); 448 GSF_plan_add_ (cp, pr);
435 return GNUNET_YES; 449 return GNUNET_YES;
436} 450}
diff --git a/src/fs/gnunet-service-fs_cp.c b/src/fs/gnunet-service-fs_cp.c
index 35a21f07a..1e535d089 100644
--- a/src/fs/gnunet-service-fs_cp.c
+++ b/src/fs/gnunet-service-fs_cp.c
@@ -1322,7 +1322,9 @@ GSF_handle_p2p_query_ (const struct GNUNET_PeerIdentity *other,
1322 0) ? (const char *) &opt[bits] : NULL, 1322 0) ? (const char *) &opt[bits] : NULL,
1323 bfsize, ntohl (gm->filter_mutator), 1323 bfsize, ntohl (gm->filter_mutator),
1324 1 /* anonymity */ , 1324 1 /* anonymity */ ,
1325 (uint32_t) priority, ttl, spid, NULL, 0, /* replies_seen */ 1325 (uint32_t) priority, ttl, spid,
1326 GNUNET_PEER_intern (other),
1327 NULL, 0, /* replies_seen */
1326 &handle_p2p_reply, peerreq); 1328 &handle_p2p_reply, peerreq);
1327 GNUNET_assert (NULL != pr); 1329 GNUNET_assert (NULL != pr);
1328 peerreq->pr = pr; 1330 peerreq->pr = pr;
diff --git a/src/fs/gnunet-service-fs_lc.c b/src/fs/gnunet-service-fs_lc.c
index a7e78a6ed..9f284ed8f 100644
--- a/src/fs/gnunet-service-fs_lc.c
+++ b/src/fs/gnunet-service-fs_lc.c
@@ -375,7 +375,7 @@ GSF_local_client_start_search_handler_ (struct GNUNET_SERVER_Client *client,
375 ntohl (sm->anonymity_level), 375 ntohl (sm->anonymity_level),
376 0 /* priority */ , 376 0 /* priority */ ,
377 0 /* ttl */ , 377 0 /* ttl */ ,
378 0 /* sender PID */ , 378 0 /* sender PID */ , 0 /* origin PID */,
379 (const GNUNET_HashCode *) &sm[1], sc, 379 (const GNUNET_HashCode *) &sm[1], sc,
380 &client_response_handler, cr); 380 &client_response_handler, cr);
381 return cr->pr; 381 return cr->pr;
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c
index dc83c9960..6bf85df92 100644
--- a/src/fs/gnunet-service-fs_pe.c
+++ b/src/fs/gnunet-service-fs_pe.c
@@ -229,12 +229,25 @@ plan (struct PeerPlan *pp, struct GSF_RequestPlan *rp)
229 total_delay * 1000LL / plan_count, GNUNET_NO); 229 total_delay * 1000LL / plan_count, GNUNET_NO);
230 prd = GSF_pending_request_get_data_ (rp->prl_head->pr); 230 prd = GSF_pending_request_get_data_ (rp->prl_head->pr);
231 // FIXME: calculate 'rp->priority'! 231 // FIXME: calculate 'rp->priority'!
232#if 0
232 if (rp->transmission_counter < 32) 233 if (rp->transmission_counter < 32)
233 delay = 234 delay =
234 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 235 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
235 1LL << rp->transmission_counter); 236 1LL << rp->transmission_counter);
236 else 237 else
237 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX); 238 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX);
239#else
240 if (rp->transmission_counter < 32)
241 delay =
242 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
243 rp->transmission_counter);
244 else if (rp->transmission_counter < 32)
245 delay =
246 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
247 32 + (1LL << rp->transmission_counter));
248 else
249 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, UINT_MAX);
250#endif
238 rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay); 251 rp->earliest_transmission = GNUNET_TIME_relative_to_absolute (delay);
239#if DEBUG_FS 252#if DEBUG_FS
240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -361,14 +374,6 @@ schedule_peer_transmission (void *cls,
361 GSF_peer_transmit_cancel_ (pp->pth); 374 GSF_peer_transmit_cancel_ (pp->pth);
362 pp->pth = NULL; 375 pp->pth = NULL;
363 } 376 }
364 GNUNET_STATISTICS_set (GSF_stats,
365 gettext_noop ("# query delay heap size"),
366 GNUNET_CONTAINER_heap_get_size (pp->delay_heap),
367 GNUNET_NO);
368 GNUNET_STATISTICS_set (GSF_stats,
369 gettext_noop ("# query priority heap size"),
370 GNUNET_CONTAINER_heap_get_size (pp->priority_heap),
371 GNUNET_NO);
372 /* move ready requests to priority queue */ 377 /* move ready requests to priority queue */
373 while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) && 378 while ((NULL != (rp = GNUNET_CONTAINER_heap_peek (pp->delay_heap))) &&
374 (GNUNET_TIME_absolute_get_remaining 379 (GNUNET_TIME_absolute_get_remaining
diff --git a/src/fs/gnunet-service-fs_pr.c b/src/fs/gnunet-service-fs_pr.c
index 9a8a3f23a..7d205fef9 100644
--- a/src/fs/gnunet-service-fs_pr.c
+++ b/src/fs/gnunet-service-fs_pr.c
@@ -104,6 +104,12 @@ struct GSF_PendingRequest
104 GNUNET_PEER_Id sender_pid; 104 GNUNET_PEER_Id sender_pid;
105 105
106 /** 106 /**
107 * Identity of the peer that we should never forward this query
108 * to since it originated this query (0 for none).
109 */
110 GNUNET_PEER_Id origin_pid;
111
112 /**
107 * Time we started the last datastore lookup. 113 * Time we started the last datastore lookup.
108 */ 114 */
109 struct GNUNET_TIME_Absolute qe_start; 115 struct GNUNET_TIME_Absolute qe_start;
@@ -226,6 +232,7 @@ refresh_bloomfilter (struct GSF_PendingRequest *pr)
226 * @param priority maximum outgoing cummulative request priority to use 232 * @param priority maximum outgoing cummulative request priority to use
227 * @param ttl current time-to-live for the request 233 * @param ttl current time-to-live for the request
228 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none 234 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none
235 * @param origin_pid peer ID of origin of query (do not loop back)
229 * @param replies_seen hash codes of known local replies 236 * @param replies_seen hash codes of known local replies
230 * @param replies_seen_count size of the 'replies_seen' array 237 * @param replies_seen_count size of the 'replies_seen' array
231 * @param rh handle to call when we get a reply 238 * @param rh handle to call when we get a reply
@@ -242,6 +249,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
242 uint32_t mingle, uint32_t anonymity_level, 249 uint32_t mingle, uint32_t anonymity_level,
243 uint32_t priority, int32_t ttl, 250 uint32_t priority, int32_t ttl,
244 GNUNET_PEER_Id sender_pid, 251 GNUNET_PEER_Id sender_pid,
252 GNUNET_PEER_Id origin_pid,
245 const GNUNET_HashCode * replies_seen, 253 const GNUNET_HashCode * replies_seen,
246 unsigned int replies_seen_count, 254 unsigned int replies_seen_count,
247 GSF_PendingRequestReplyHandler rh, void *rh_cls) 255 GSF_PendingRequestReplyHandler rh, void *rh_cls)
@@ -278,6 +286,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
278 pr->public_data.type = type; 286 pr->public_data.type = type;
279 pr->public_data.start_time = GNUNET_TIME_absolute_get (); 287 pr->public_data.start_time = GNUNET_TIME_absolute_get ();
280 pr->sender_pid = sender_pid; 288 pr->sender_pid = sender_pid;
289 pr->origin_pid = origin_pid;
281 pr->rh = rh; 290 pr->rh = rh;
282 pr->rh_cls = rh_cls; 291 pr->rh_cls = rh_cls;
283 GNUNET_assert ((sender_pid != 0) || (0 == (options & GSF_PRO_FORWARD_ONLY))); 292 GNUNET_assert ((sender_pid != 0) || (0 == (options & GSF_PRO_FORWARD_ONLY)));
@@ -562,6 +571,8 @@ clean_request (void *cls, const GNUNET_HashCode * key, void *value)
562 } 571 }
563 GNUNET_PEER_change_rc (pr->sender_pid, -1); 572 GNUNET_PEER_change_rc (pr->sender_pid, -1);
564 pr->sender_pid = 0; 573 pr->sender_pid = 0;
574 GNUNET_PEER_change_rc (pr->origin_pid, -1);
575 pr->origin_pid = 0;
565 if (NULL != pr->hnode) 576 if (NULL != pr->hnode)
566 { 577 {
567 GNUNET_CONTAINER_heap_remove_node (pr->hnode); 578 GNUNET_CONTAINER_heap_remove_node (pr->hnode);
@@ -1214,7 +1225,7 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1214 /* queue priority */ , 1225 /* queue priority */ ,
1215 (0 != 1226 (0 !=
1216 (GSF_PRO_PRIORITY_UNLIMITED & 1227 (GSF_PRO_PRIORITY_UNLIMITED &
1217 pr->public_data.options)) ? UINT_MAX : 1 1228 pr->public_data.options)) ? UINT_MAX : 16
1218 /* max queue size */ , 1229 /* max queue size */ ,
1219 GNUNET_TIME_UNIT_FOREVER_REL, 1230 GNUNET_TIME_UNIT_FOREVER_REL,
1220 &process_local_reply, pr); 1231 &process_local_reply, pr);
@@ -1253,7 +1264,7 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1253 /* queue priority */ , 1264 /* queue priority */ ,
1254 (0 != 1265 (0 !=
1255 (GSF_PRO_PRIORITY_UNLIMITED & 1266 (GSF_PRO_PRIORITY_UNLIMITED &
1256 pr->public_data.options)) ? UINT_MAX : 1 1267 pr->public_data.options)) ? UINT_MAX : 16
1257 /* max queue size */ , 1268 /* max queue size */ ,
1258 GNUNET_TIME_UNIT_FOREVER_REL, 1269 GNUNET_TIME_UNIT_FOREVER_REL,
1259 &process_local_reply, pr); 1270 &process_local_reply, pr);
@@ -1279,7 +1290,7 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1279 { 1290 {
1280 GNUNET_STATISTICS_update (GSF_stats, 1291 GNUNET_STATISTICS_update (GSF_stats,
1281 gettext_noop 1292 gettext_noop
1282 ("# Datastore lookups concluded (found ultimate result)"), 1293 ("# Datastore lookups concluded (found last result)"),
1283 1, GNUNET_NO); 1294 1, GNUNET_NO);
1284 goto check_error_and_continue; 1295 goto check_error_and_continue;
1285 } 1296 }
@@ -1312,7 +1323,7 @@ process_local_reply (void *cls, const GNUNET_HashCode * key, size_t size,
1312 /* queue priority */ , 1323 /* queue priority */ ,
1313 (0 != 1324 (0 !=
1314 (GSF_PRO_PRIORITY_UNLIMITED & pr-> 1325 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1315 public_data.options)) ? UINT_MAX : 1 1326 public_data.options)) ? UINT_MAX : 16
1316 /* max queue size */ , 1327 /* max queue size */ ,
1317 GNUNET_TIME_UNIT_FOREVER_REL, 1328 GNUNET_TIME_UNIT_FOREVER_REL,
1318 &process_local_reply, pr); 1329 &process_local_reply, pr);
@@ -1347,9 +1358,9 @@ GSF_pending_request_test_target_ (struct GSF_PendingRequest *pr,
1347{ 1358{
1348 struct GNUNET_PeerIdentity pi; 1359 struct GNUNET_PeerIdentity pi;
1349 1360
1350 if (0 == pr->sender_pid) 1361 if (0 == pr->origin_pid)
1351 return GNUNET_YES; 1362 return GNUNET_YES;
1352 GNUNET_PEER_resolve (pr->sender_pid, &pi); 1363 GNUNET_PEER_resolve (pr->origin_pid, &pi);
1353 return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES; 1364 return (0 == memcmp (&pi, target, sizeof (struct GNUNET_PeerIdentity))) ? GNUNET_NO :GNUNET_YES;
1354} 1365}
1355 1366
@@ -1388,7 +1399,7 @@ GSF_local_lookup_ (struct GSF_PendingRequest *pr,
1388 /* queue priority */ , 1399 /* queue priority */ ,
1389 (0 != 1400 (0 !=
1390 (GSF_PRO_PRIORITY_UNLIMITED & pr-> 1401 (GSF_PRO_PRIORITY_UNLIMITED & pr->
1391 public_data.options)) ? UINT_MAX : 1 1402 public_data.options)) ? UINT_MAX : 16
1392 /* max queue size */ , 1403 /* max queue size */ ,
1393 GNUNET_TIME_UNIT_FOREVER_REL, 1404 GNUNET_TIME_UNIT_FOREVER_REL,
1394 &process_local_reply, pr); 1405 &process_local_reply, pr);
diff --git a/src/fs/gnunet-service-fs_pr.h b/src/fs/gnunet-service-fs_pr.h
index c8b52398e..538a38248 100644
--- a/src/fs/gnunet-service-fs_pr.h
+++ b/src/fs/gnunet-service-fs_pr.h
@@ -195,6 +195,7 @@ typedef void (*GSF_PendingRequestReplyHandler) (void *cls,
195 * @param ttl current time-to-live for the request 195 * @param ttl current time-to-live for the request
196 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none; 196 * @param sender_pid peer ID to use for the sender when forwarding, 0 for none;
197 * reference counter is taken over by this function 197 * reference counter is taken over by this function
198 * @param origin_pid peer ID of origin of query (do not loop back)
198 * @param replies_seen hash codes of known local replies 199 * @param replies_seen hash codes of known local replies
199 * @param replies_seen_count size of the 'replies_seen' array 200 * @param replies_seen_count size of the 'replies_seen' array
200 * @param rh handle to call when we get a reply 201 * @param rh handle to call when we get a reply
@@ -211,6 +212,7 @@ GSF_pending_request_create_ (enum GSF_PendingRequestOptions options,
211 uint32_t mingle, uint32_t anonymity_level, 212 uint32_t mingle, uint32_t anonymity_level,
212 uint32_t priority, int32_t ttl, 213 uint32_t priority, int32_t ttl,
213 GNUNET_PEER_Id sender_pid, 214 GNUNET_PEER_Id sender_pid,
215 GNUNET_PEER_Id origin_pid,
214 const GNUNET_HashCode * replies_seen, 216 const GNUNET_HashCode * replies_seen,
215 unsigned int replies_seen_count, 217 unsigned int replies_seen_count,
216 GSF_PendingRequestReplyHandler rh, void *rh_cls); 218 GSF_PendingRequestReplyHandler rh, void *rh_cls);