aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-service-fs_pe.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-23 18:12:22 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-23 18:12:22 +0000
commitb38b47339b7c806432f251a566c857eb64c6e8cf (patch)
tree026f34cd672fab22a8453c5f3aee979609f507de /src/fs/gnunet-service-fs_pe.c
parentcbaa6d6444ce82bea7761268ad61e9af477b2d42 (diff)
downloadgnunet-b38b47339b7c806432f251a566c857eb64c6e8cf.tar.gz
gnunet-b38b47339b7c806432f251a566c857eb64c6e8cf.zip
-introducing MDLL macros
Diffstat (limited to 'src/fs/gnunet-service-fs_pe.c')
-rw-r--r--src/fs/gnunet-service-fs_pe.c53
1 files changed, 34 insertions, 19 deletions
diff --git a/src/fs/gnunet-service-fs_pe.c b/src/fs/gnunet-service-fs_pe.c
index 6041a61f6..226137d73 100644
--- a/src/fs/gnunet-service-fs_pe.c
+++ b/src/fs/gnunet-service-fs_pe.c
@@ -48,7 +48,13 @@ struct PeerPlan;
48 48
49/** 49/**
50 * DLL of request plans a particular pending request is 50 * DLL of request plans a particular pending request is
51 * involved with. 51 * involved with. The corresponding head and tail are
52 * stored in a 'struct GSF_PendingRequest'. (We need
53 * to be able to lookup all 'plan' entries for a given
54 * request easily).
55 *
56 * There is always one 'struct PendingRequestList'
57 * for each 'struct GSF_RequestPlanReference'.
52 */ 58 */
53struct GSF_RequestPlanReference 59struct GSF_RequestPlanReference
54{ 60{
@@ -56,12 +62,12 @@ struct GSF_RequestPlanReference
56 /** 62 /**
57 * This is a doubly-linked list. 63 * This is a doubly-linked list.
58 */ 64 */
59 struct GSF_RequestPlanReference *next; 65 struct GSF_RequestPlanReference *next_PR;
60 66
61 /** 67 /**
62 * This is a doubly-linked list. 68 * This is a doubly-linked list.
63 */ 69 */
64 struct GSF_RequestPlanReference *prev; 70 struct GSF_RequestPlanReference *prev_PR;
65 71
66 /** 72 /**
67 * Associated request plan. 73 * Associated request plan.
@@ -77,7 +83,13 @@ struct GSF_RequestPlanReference
77 83
78/** 84/**
79 * List of GSF_PendingRequests this request plan 85 * List of GSF_PendingRequests this request plan
80 * participates with. 86 * participates with. The corresponding head and tail
87 * are stored in a 'struct GSF_RequestPlan'. (We need
88 * to be able to lookup all pending requests corresponding
89 * to a given plan entry.)
90 *
91 * There is always one 'struct PendingRequestList'
92 * for each 'struct GSF_RequestPlanReference'.
81 */ 93 */
82struct PendingRequestList 94struct PendingRequestList
83{ 95{
@@ -85,12 +97,12 @@ struct PendingRequestList
85 /** 97 /**
86 * This is a doubly-linked list. 98 * This is a doubly-linked list.
87 */ 99 */
88 struct PendingRequestList *next; 100 struct PendingRequestList *next_PE;
89 101
90 /** 102 /**
91 * This is a doubly-linked list. 103 * This is a doubly-linked list.
92 */ 104 */
93 struct PendingRequestList *prev; 105 struct PendingRequestList *prev_PE;
94 106
95 /** 107 /**
96 * Associated pending request. 108 * Associated pending request.
@@ -364,13 +376,13 @@ get_latest (const struct GSF_RequestPlan *rp)
364 376
365 prl = rp->prl_head; 377 prl = rp->prl_head;
366 ret = prl->pr; 378 ret = prl->pr;
367 prl = prl->next; 379 prl = prl->next_PE;
368 while (NULL != prl) 380 while (NULL != prl)
369 { 381 {
370 if (GSF_pending_request_get_data_ (prl->pr)->ttl.abs_value > 382 if (GSF_pending_request_get_data_ (prl->pr)->ttl.abs_value >
371 GSF_pending_request_get_data_ (ret)->ttl.abs_value) 383 GSF_pending_request_get_data_ (ret)->ttl.abs_value)
372 ret = prl->pr; 384 ret = prl->pr;
373 prl = prl->next; 385 prl = prl->next_PE;
374 } 386 }
375 return ret; 387 return ret;
376} 388}
@@ -544,8 +556,8 @@ merge_pr (void *cls, const struct GNUNET_HashCode * query, void *element)
544 prl->rpr = rpr; 556 prl->rpr = rpr;
545 prl->pr = mpr->pr; 557 prl->pr = mpr->pr;
546 prd = GSF_pending_request_get_data_ (mpr->pr); 558 prd = GSF_pending_request_get_data_ (mpr->pr);
547 GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); 559 GNUNET_CONTAINER_MDLL_insert (PR, prd->rpr_head, prd->rpr_tail, rpr);
548 GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); 560 GNUNET_CONTAINER_MDLL_insert (PE, rp->prl_head, rp->prl_tail, prl);
549 mpr->merged = GNUNET_YES; 561 mpr->merged = GNUNET_YES;
550#if INSANE_STATISTICS 562#if INSANE_STATISTICS
551 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1, 563 GNUNET_STATISTICS_update (GSF_stats, gettext_noop ("# requests merged"), 1,
@@ -624,8 +636,8 @@ GSF_plan_add_ (struct GSF_ConnectedPeer *cp, struct GSF_PendingRequest *pr)
624 rpr->prl = prl; 636 rpr->prl = prl;
625 prl->rpr = rpr; 637 prl->rpr = rpr;
626 prl->pr = pr; 638 prl->pr = pr;
627 GNUNET_CONTAINER_DLL_insert (prd->rpr_head, prd->rpr_tail, rpr); 639 GNUNET_CONTAINER_MDLL_insert (PR, prd->rpr_head, prd->rpr_tail, rpr);
628 GNUNET_CONTAINER_DLL_insert (rp->prl_head, rp->prl_tail, prl); 640 GNUNET_CONTAINER_MDLL_insert (PE, rp->prl_head, rp->prl_tail, prl);
629 rp->pp = pp; 641 rp->pp = pp;
630 GNUNET_assert (GNUNET_YES == 642 GNUNET_assert (GNUNET_YES ==
631 GNUNET_CONTAINER_multihashmap_put (pp->plan_map, 643 GNUNET_CONTAINER_multihashmap_put (pp->plan_map,
@@ -674,9 +686,9 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
674 get_rp_key (rp), rp)); 686 get_rp_key (rp), rp));
675 while (NULL != (prl = rp->prl_head)) 687 while (NULL != (prl = rp->prl_head))
676 { 688 {
677 GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); 689 GNUNET_CONTAINER_MDLL_remove (PE, rp->prl_head, rp->prl_tail, prl);
678 prd = GSF_pending_request_get_data_ (prl->pr); 690 prd = GSF_pending_request_get_data_ (prl->pr);
679 GNUNET_CONTAINER_DLL_remove (prd->rpr_head, prd->rpr_tail, prl->rpr); 691 GNUNET_CONTAINER_MDLL_remove (PR, prd->rpr_head, prd->rpr_tail, prl->rpr);
680 GNUNET_free (prl->rpr); 692 GNUNET_free (prl->rpr);
681 GNUNET_free (prl); 693 GNUNET_free (prl);
682 } 694 }
@@ -691,9 +703,9 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
691 get_rp_key (rp), rp)); 703 get_rp_key (rp), rp));
692 while (NULL != (prl = rp->prl_head)) 704 while (NULL != (prl = rp->prl_head))
693 { 705 {
694 GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, prl); 706 GNUNET_CONTAINER_MDLL_remove (PE, rp->prl_head, rp->prl_tail, prl);
695 prd = GSF_pending_request_get_data_ (prl->pr); 707 prd = GSF_pending_request_get_data_ (prl->pr);
696 GNUNET_CONTAINER_DLL_remove (prd->rpr_head, prd->rpr_tail, prl->rpr); 708 GNUNET_CONTAINER_MDLL_remove (PR, prd->rpr_head, prd->rpr_tail, prl->rpr);
697 GNUNET_free (prl->rpr); 709 GNUNET_free (prl->rpr);
698 GNUNET_free (prl); 710 GNUNET_free (prl);
699 } 711 }
@@ -707,6 +719,7 @@ GSF_plan_notify_peer_disconnect_ (const struct GSF_ConnectedPeer *cp)
707 GNUNET_free (pp); 719 GNUNET_free (pp);
708} 720}
709 721
722
710/** 723/**
711 * Get the last transmission attempt time for the request plan list 724 * Get the last transmission attempt time for the request plan list
712 * referenced by 'rpr_head', that was sent to 'sender' 725 * referenced by 'rpr_head', that was sent to 'sender'
@@ -722,7 +735,8 @@ GSF_request_plan_reference_get_last_transmission_ (
722 struct GNUNET_TIME_Absolute *result) 735 struct GNUNET_TIME_Absolute *result)
723{ 736{
724 struct GSF_RequestPlanReference *rpr; 737 struct GSF_RequestPlanReference *rpr;
725 for (rpr = rpr_head; rpr; rpr = rpr->next) 738
739 for (rpr = rpr_head; NULL != rpr; rpr = rpr->next_PR)
726 { 740 {
727 if (rpr->rp->pp->cp == sender) 741 if (rpr->rp->pp->cp == sender)
728 { 742 {
@@ -733,6 +747,7 @@ GSF_request_plan_reference_get_last_transmission_ (
733 return GNUNET_NO; 747 return GNUNET_NO;
734} 748}
735 749
750
736/** 751/**
737 * Notify the plan about a request being done; destroy all entries 752 * Notify the plan about a request being done; destroy all entries
738 * associated with this request. 753 * associated with this request.
@@ -749,9 +764,9 @@ GSF_plan_notify_request_done_ (struct GSF_PendingRequest *pr)
749 prd = GSF_pending_request_get_data_ (pr); 764 prd = GSF_pending_request_get_data_ (pr);
750 while (NULL != (rpr = prd->rpr_head)) 765 while (NULL != (rpr = prd->rpr_head))
751 { 766 {
752 GNUNET_CONTAINER_DLL_remove (prd->rpr_head, prd->rpr_tail, rpr); 767 GNUNET_CONTAINER_MDLL_remove (PR, prd->rpr_head, prd->rpr_tail, rpr);
753 rp = rpr->rp; 768 rp = rpr->rp;
754 GNUNET_CONTAINER_DLL_remove (rp->prl_head, rp->prl_tail, rpr->prl); 769 GNUNET_CONTAINER_MDLL_remove (PE, rp->prl_head, rp->prl_tail, rpr->prl);
755 if (NULL == rp->prl_head) 770 if (NULL == rp->prl_head)
756 { 771 {
757 GNUNET_CONTAINER_heap_remove_node (rp->hn); 772 GNUNET_CONTAINER_heap_remove_node (rp->hn);