aboutsummaryrefslogtreecommitdiff
path: root/src/fragmentation/test_fragmentation.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-21 18:44:26 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-21 18:44:26 +0000
commit23066715ced62f6a813b130911f705566f2322fd (patch)
treeeb92a91f5a1a05052797d8a5cd97ac4e20674e2f /src/fragmentation/test_fragmentation.c
parentdb01713beb18dfa50deddac41f74004d13be8295 (diff)
downloadgnunet-23066715ced62f6a813b130911f705566f2322fd.tar.gz
gnunet-23066715ced62f6a813b130911f705566f2322fd.zip
fix segfault introduced by recent refactoring
Diffstat (limited to 'src/fragmentation/test_fragmentation.c')
-rw-r--r--src/fragmentation/test_fragmentation.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/fragmentation/test_fragmentation.c b/src/fragmentation/test_fragmentation.c
index 14901cf68..8f0be87a5 100644
--- a/src/fragmentation/test_fragmentation.c
+++ b/src/fragmentation/test_fragmentation.c
@@ -62,6 +62,28 @@ static struct GNUNET_BANDWIDTH_Tracker trackers[NUM_MSGS];
62 62
63static struct GNUNET_FRAGMENT_Context *frags[NUM_MSGS]; 63static struct GNUNET_FRAGMENT_Context *frags[NUM_MSGS];
64 64
65static GNUNET_SCHEDULER_TaskIdentifier shutdown_task;
66
67static void
68do_shutdown (void *cls,
69 const struct GNUNET_SCHEDULER_TaskContext *tc)
70{
71 unsigned int i;
72
73 ret = 0;
74 shutdown_task = GNUNET_SCHEDULER_NO_TASK;
75 GNUNET_DEFRAGMENT_context_destroy (defrag);
76 defrag = NULL;
77 for (i = 0; i < NUM_MSGS; i++)
78 {
79 if (frags[i] == NULL)
80 continue;
81 GNUNET_FRAGMENT_context_destroy (frags[i]);
82 frags[i] = NULL;
83 }
84}
85
86
65static void 87static void
66proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr) 88proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
67{ 89{
@@ -81,18 +103,11 @@ proc_msgs (void *cls, const struct GNUNET_MessageHeader *hdr)
81 fprintf (stderr, "."); 103 fprintf (stderr, ".");
82#endif 104#endif
83 /* tolerate 10% loss, i.e. due to duplicate fragment IDs */ 105 /* tolerate 10% loss, i.e. due to duplicate fragment IDs */
84 if (total >= NUM_MSGS - (NUM_MSGS / 10)) 106 if ( (total >= NUM_MSGS - (NUM_MSGS / 10)) &&
107 (ret != 0) )
85 { 108 {
86 ret = 0; 109 if (GNUNET_SCHEDULER_NO_TASK == shutdown_task)
87 GNUNET_DEFRAGMENT_context_destroy (defrag); 110 shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
88 defrag = NULL;
89 for (i = 0; i < NUM_MSGS; i++)
90 {
91 if (frags[i] == NULL)
92 continue;
93 GNUNET_FRAGMENT_context_destroy (frags[i]);
94 frags[i] = NULL;
95 }
96 } 111 }
97} 112}
98 113