aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-06 22:37:44 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-06 22:37:44 +0000
commitc684a9606f7bd89ca2dc876567b74fb4cfe9b118 (patch)
tree659015badbbfe6cf81c1151034588a9c3414b308 /src
parent00239344e5b07d76ab19b842c69eaf9fef881127 (diff)
downloadgnunet-c684a9606f7bd89ca2dc876567b74fb4cfe9b118.tar.gz
gnunet-c684a9606f7bd89ca2dc876567b74fb4cfe9b118.zip
X-Vine:Fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c64
-rw-r--r--src/dht/gnunet_dht_profiler.c16
2 files changed, 52 insertions, 28 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 77389d1b3..3f280134e 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -4358,12 +4358,13 @@ get_shortest_trail (struct FingerInfo *finger,
4358/** 4358/**
4359 * Check if trail_1 and trail_2 have any common element. If yes then join 4359 * Check if trail_1 and trail_2 have any common element. If yes then join
4360 * them at common element. trail_1 always preceeds trail_2 in joined trail. 4360 * them at common element. trail_1 always preceeds trail_2 in joined trail.
4361 * @param trail_1 4361 * @param trail_1 Trail from source to me, NOT including endpoints.
4362 * @param trail_1_len 4362 * @param trail_1_len Total number of peers @a trail_1
4363 * @param trail_2 4363 * @param trail_2 Trail from me to current predecessor, NOT including endpoints.
4364 * @param trail_2_len 4364 * @param trail_2_len Total number of peers @a trail_2
4365 * @param joined_trail_len 4365 * @param joined_trail_len Total number of peers in combined trail of trail_1
4366 * @return 4366 * trail_2.
4367 * @return Joined trail.
4367 */ 4368 */
4368static struct GNUNET_PeerIdentity * 4369static struct GNUNET_PeerIdentity *
4369check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1, 4370check_for_duplicate_entries (const struct GNUNET_PeerIdentity *trail_1,
@@ -4458,13 +4459,14 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4458 trail_me_to_curr_pred = get_shortest_trail (current_predecessor, 4459 trail_me_to_curr_pred = get_shortest_trail (current_predecessor,
4459 &trail_me_to_curr_pred_length); 4460 &trail_me_to_curr_pred_length);
4460 4461
4462 /* If there is only on element in the trail, and that element is source.*/
4461 if ((trail_me_to_curr_pred_length == 1) && 4463 if ((trail_me_to_curr_pred_length == 1) &&
4462 (0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer, 4464 (0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer,
4463 &trail_me_to_curr_pred[0]))) 4465 &trail_me_to_curr_pred[0])))
4464 { 4466 {
4465 *trail_src_to_curr_pred_length = 0; 4467 *trail_src_to_curr_pred_length = 0;
4466 GNUNET_free_non_null(trail_me_to_curr_pred); 4468 GNUNET_free_non_null(trail_me_to_curr_pred);
4467 return NULL; 4469 return NULL;
4468 } 4470 }
4469 4471
4470 /* Check if trail_me_to_curr_pred contains source. */ 4472 /* Check if trail_me_to_curr_pred contains source. */
@@ -4476,6 +4478,7 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4476 &trail_me_to_curr_pred[i])) 4478 &trail_me_to_curr_pred[i]))
4477 continue; 4479 continue;
4478 4480
4481 /* Source is NOT part of trail. */
4479 i = i+1; 4482 i = i+1;
4480 4483
4481 /* Source is the last element in the trail to reach to my pred. 4484 /* Source is the last element in the trail to reach to my pred.
@@ -4486,7 +4489,6 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4486 return NULL; 4489 return NULL;
4487 } 4490 }
4488 4491
4489
4490 *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i; 4492 *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - i;
4491 trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)* 4493 trail_src_to_curr_pred = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)*
4492 *trail_src_to_curr_pred_length); 4494 *trail_src_to_curr_pred_length);
@@ -4497,6 +4499,21 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4497 GNUNET_free_non_null(trail_me_to_curr_pred); 4499 GNUNET_free_non_null(trail_me_to_curr_pred);
4498 return trail_src_to_curr_pred; 4500 return trail_src_to_curr_pred;
4499 } 4501 }
4502 /* Is first element source? Then exclude first element and copy rest of the
4503 trail. */
4504 if(0 == GNUNET_CRYPTO_cmp_peer_identity (&source_peer,
4505 &trail_me_to_curr_pred[0]))
4506 {
4507 *trail_src_to_curr_pred_length = trail_me_to_curr_pred_length - 1;
4508 trail_src_to_curr_pred = GNUNET_malloc(sizeof(struct GNUNET_PeerIdentity)*
4509 *trail_src_to_curr_pred_length);
4510 unsigned int j;
4511 for(j=0; j < *trail_src_to_curr_pred_length;j++)
4512 {
4513 trail_src_to_curr_pred[j] = trail_me_to_curr_pred[j+1];
4514 }
4515 return trail_src_to_curr_pred;
4516 }
4500 } 4517 }
4501 4518
4502 unsigned int len; 4519 unsigned int len;
@@ -4504,7 +4521,7 @@ get_trail_src_to_curr_pred (struct GNUNET_PeerIdentity source_peer,
4504 trail_src_to_me_len, 4521 trail_src_to_me_len,
4505 trail_me_to_curr_pred, 4522 trail_me_to_curr_pred,
4506 trail_me_to_curr_pred_length, 4523 trail_me_to_curr_pred_length,
4507 &len); 4524 &len);
4508 *trail_src_to_curr_pred_length = len; 4525 *trail_src_to_curr_pred_length = len;
4509 GNUNET_free_non_null(trail_me_to_curr_pred); 4526 GNUNET_free_non_null(trail_me_to_curr_pred);
4510 return trail_src_to_curr_pred; 4527 return trail_src_to_curr_pred;
@@ -4547,6 +4564,9 @@ update_predecessor (struct GNUNET_PeerIdentity finger,
4547 { 4564 {
4548 /* Invert the trail to get the trail from me to finger, NOT including the 4565 /* Invert the trail to get the trail from me to finger, NOT including the
4549 endpoints.*/ 4566 endpoints.*/
4567 GNUNET_assert(NULL != GNUNET_CONTAINER_multipeermap_get(friend_peermap,
4568 &trail[trail_length-1]));
4569
4550 trail_to_new_predecessor = invert_trail (trail, trail_length); 4570 trail_to_new_predecessor = invert_trail (trail, trail_length);
4551 4571
4552 /* Add an entry in your routing table. */ 4572 /* Add an entry in your routing table. */
@@ -4607,9 +4627,7 @@ compare_and_update_predecessor (struct GNUNET_PeerIdentity finger,
4607 update_predecessor (finger, trail, trail_length); 4627 update_predecessor (finger, trail, trail_length);
4608 return; 4628 return;
4609 } 4629 }
4610 /* FIXME: Here we should first call find_successor and get a locally known 4630
4611 predecessor. If locally known predecessor is closest then current or finger,
4612 add that as predecessor. */
4613 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity, 4631 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor->finger_identity,
4614 &finger)) 4632 &finger))
4615 { 4633 {
@@ -4713,6 +4731,7 @@ handle_dht_p2p_verify_successor(void *cls,
4713 compare_and_update_predecessor (source_peer, trail, trail_length); 4731 compare_and_update_predecessor (source_peer, trail, trail_length);
4714 current_predecessor = finger_table[PREDECESSOR_FINGER_ID]; 4732 current_predecessor = finger_table[PREDECESSOR_FINGER_ID];
4715 unsigned int flag = 0; 4733 unsigned int flag = 0;
4734
4716 /* Is source of this message NOT my predecessor. */ 4735 /* Is source of this message NOT my predecessor. */
4717 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor.finger_identity, 4736 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&current_predecessor.finger_identity,
4718 &source_peer))) 4737 &source_peer)))
@@ -4736,28 +4755,30 @@ handle_dht_p2p_verify_successor(void *cls,
4736 trail_src_to_curr_pred[k] = trail[k]; 4755 trail_src_to_curr_pred[k] = trail[k];
4737 k++; 4756 k++;
4738 } 4757 }
4758 break;
4739 } 4759 }
4740 4760
4741 if(0 == flag) 4761 if(0 == flag)
4742 { 4762 {
4743 trail_src_to_curr_pred = get_trail_src_to_curr_pred (source_peer, 4763 trail_src_to_curr_pred =
4744 trail, 4764 get_trail_src_to_curr_pred (source_peer,
4745 trail_length, 4765 trail,
4746 &trail_src_to_curr_pred_len); 4766 trail_length,
4767 &trail_src_to_curr_pred_len);
4747 } 4768 }
4748 } 4769 }
4749 else 4770 else
4750 { 4771 {
4751 trail_src_to_curr_pred_len = trail_length; 4772 trail_src_to_curr_pred_len = trail_length;
4752 int i; 4773 unsigned int i;
4753 4774
4754 trail_src_to_curr_pred = GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity) 4775 trail_src_to_curr_pred =
4755 *trail_src_to_curr_pred_len); 4776 GNUNET_malloc (sizeof(struct GNUNET_PeerIdentity)
4777 *trail_src_to_curr_pred_len);
4756 for(i = 0; i < trail_src_to_curr_pred_len; i++) 4778 for(i = 0; i < trail_src_to_curr_pred_len; i++)
4757 { 4779 {
4758 trail_src_to_curr_pred[i] = trail[i]; 4780 trail_src_to_curr_pred[i] = trail[i];
4759 } 4781 }
4760
4761 } 4782 }
4762 4783
4763 GNUNET_assert (NULL != 4784 GNUNET_assert (NULL !=
@@ -4942,7 +4963,7 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ,
4942 GNUNET_assert (NULL != 4963 GNUNET_assert (NULL !=
4943 (target_friend = 4964 (target_friend =
4944 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 4965 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
4945 &probable_successor))); 4966 &probable_successor)));
4946 } 4967 }
4947 4968
4948 add_new_finger (probable_successor, trail_me_to_probable_succ, 4969 add_new_finger (probable_successor, trail_me_to_probable_succ,
@@ -5093,6 +5114,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
5093 peer)); 5114 peer));
5094 else 5115 else
5095 GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&source, peer)); 5116 GNUNET_assert(0 == GNUNET_CRYPTO_cmp_peer_identity(&source, peer));
5117
5096 compare_and_update_predecessor (source, trail, trail_length); 5118 compare_and_update_predecessor (source, trail, trail_length);
5097 return GNUNET_OK; 5119 return GNUNET_OK;
5098 } 5120 }
diff --git a/src/dht/gnunet_dht_profiler.c b/src/dht/gnunet_dht_profiler.c
index 0bfe609d8..f88749524 100644
--- a/src/dht/gnunet_dht_profiler.c
+++ b/src/dht/gnunet_dht_profiler.c
@@ -205,6 +205,7 @@ static unsigned int n_gets_fail;
205 */ 205 */
206static unsigned int replication; 206static unsigned int replication;
207 207
208#if 0
208/** 209/**
209 * Testbed Operation (to get stats). 210 * Testbed Operation (to get stats).
210 */ 211 */
@@ -214,7 +215,7 @@ static struct GNUNET_TESTBED_Operation *stats_op;
214 * Testbed peer handles. 215 * Testbed peer handles.
215 */ 216 */
216static struct GNUNET_TESTBED_Peer **testbed_handles; 217static struct GNUNET_TESTBED_Peer **testbed_handles;
217 218#endif
218/** 219/**
219 * Shutdown task. Cleanup all resources and operations. 220 * Shutdown task. Cleanup all resources and operations.
220 * 221 *
@@ -253,7 +254,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
253 GNUNET_free_non_null (a_ac); 254 GNUNET_free_non_null (a_ac);
254} 255}
255 256
256 257#if 0
257/** 258/**
258 * Stats callback. Finish the stats testbed operation and when all stats have 259 * Stats callback. Finish the stats testbed operation and when all stats have
259 * been iterated, shutdown the test. 260 * been iterated, shutdown the test.
@@ -310,7 +311,7 @@ collect_bandwidth_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *t
310 bandwidth_stats_iterator, 311 bandwidth_stats_iterator,
311 bandwidth_stats_cont, NULL); 312 bandwidth_stats_cont, NULL);
312} 313}
313 314#endif
314 315
315static void 316static void
316summarize () 317summarize ()
@@ -322,7 +323,7 @@ summarize ()
322 INFO ("# GETS succeeded: %u\n", n_gets_ok); 323 INFO ("# GETS succeeded: %u\n", n_gets_ok);
323 INFO ("# GETS failed: %u\n", n_gets_fail); 324 INFO ("# GETS failed: %u\n", n_gets_fail);
324 //FIXME: is this the right place to call b/w stats? 325 //FIXME: is this the right place to call b/w stats?
325 GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL); 326 //GNUNET_SCHEDULER_add_now (&collect_bandwidth_stats, NULL);
326 GNUNET_SCHEDULER_shutdown (); 327 GNUNET_SCHEDULER_shutdown ();
327} 328}
328 329
@@ -467,6 +468,7 @@ put_cont (void *cls, int success)
467 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac); 468 ac->delay_task = GNUNET_SCHEDULER_add_delayed (delay, &delayed_get, ac);
468} 469}
469 470
471#if 0
470/** 472/**
471 * Stats callback. Finish the stats testbed operation and when all stats have 473 * Stats callback. Finish the stats testbed operation and when all stats have
472 * been iterated, shutdown the test. 474 * been iterated, shutdown the test.
@@ -530,7 +532,7 @@ collect_finger_stats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
530 finger_stats_iterator, 532 finger_stats_iterator,
531 finger_stats_cont, NULL); 533 finger_stats_cont, NULL);
532} 534}
533 535#endif
534 536
535/** 537/**
536 * Task to do DHT PUTS 538 * Task to do DHT PUTS
@@ -547,7 +549,7 @@ delayed_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
547 DHT and check if circle is formed. If yes then go ahead with more puts, 549 DHT and check if circle is formed. If yes then go ahead with more puts,
548 else wait for 'delay' time. This function does not return anything, so we 550 else wait for 'delay' time. This function does not return anything, so we
549 should have some way to notify that circle is done or we need to wait.*/ 551 should have some way to notify that circle is done or we need to wait.*/
550 GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL); 552 //GNUNET_SCHEDULER_add_now(collect_finger_stats,NULL);
551 553
552 ac->delay_task = GNUNET_SCHEDULER_NO_TASK; 554 ac->delay_task = GNUNET_SCHEDULER_NO_TASK;
553 /* Generate and DHT PUT some random data */ 555 /* Generate and DHT PUT some random data */
@@ -800,7 +802,7 @@ main (int argc, char *const *argv)
800 802
801 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) 803 if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
802 return 2; 804 return 2;
803 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1); /* default delay */ 805 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5); /* default delay */
804 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* default timeout */ 806 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); /* default timeout */
805 replication = 1; /* default replication */ 807 replication = 1; /* default replication */
806 rc = 0; 808 rc = 0;