aboutsummaryrefslogtreecommitdiff
path: root/src/set
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-12-16 20:13:31 +0000
committerChristian Grothoff <christian@grothoff.org>2014-12-16 20:13:31 +0000
commitf1c5398dc177d04abbc29572cad70fc5c5fa9eb7 (patch)
treea1987da3d27e4d1b4bf01ca6fd77f5aa057bc04b /src/set
parent6afa2333a24ae8b8bc31ce48faf73119f1b12719 (diff)
downloadgnunet-f1c5398dc177d04abbc29572cad70fc5c5fa9eb7.tar.gz
gnunet-f1c5398dc177d04abbc29572cad70fc5c5fa9eb7.zip
-fix bus error
Diffstat (limited to 'src/set')
-rw-r--r--src/set/gnunet-service-set_union.c9
-rw-r--r--src/set/test_set_api.c117
2 files changed, 75 insertions, 51 deletions
diff --git a/src/set/gnunet-service-set_union.c b/src/set/gnunet-service-set_union.c
index 0de2ed939..4b06fbcc5 100644
--- a/src/set/gnunet-service-set_union.c
+++ b/src/set/gnunet-service-set_union.c
@@ -874,10 +874,13 @@ decode_and_send (struct Operation *op)
874 874
875 /* It may be nice to merge multiple requests, but with cadet's corking it is not worth 875 /* It may be nice to merge multiple requests, but with cadet's corking it is not worth
876 * the effort additional complexity. */ 876 * the effort additional complexity. */
877 ev = GNUNET_MQ_msg_header_extra (msg, sizeof (struct IBF_Key), 877 ev = GNUNET_MQ_msg_header_extra (msg,
878 GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS); 878 sizeof (struct IBF_Key),
879 GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS);
879 880
880 *(struct IBF_Key *) &msg[1] = key; 881 memcpy (&msg[1],
882 &key,
883 sizeof (struct IBF_Key));
881 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 884 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
882 "sending element request\n"); 885 "sending element request\n");
883 GNUNET_MQ_send (op->mq, ev); 886 GNUNET_MQ_send (op->mq, ev);
diff --git a/src/set/test_set_api.c b/src/set/test_set_api.c
index 37645cbd8..54c7fd0a8 100644
--- a/src/set/test_set_api.c
+++ b/src/set/test_set_api.c
@@ -31,65 +31,79 @@
31static struct GNUNET_PeerIdentity local_id; 31static struct GNUNET_PeerIdentity local_id;
32 32
33static struct GNUNET_HashCode app_id; 33static struct GNUNET_HashCode app_id;
34
34static struct GNUNET_SET_Handle *set1; 35static struct GNUNET_SET_Handle *set1;
36
35static struct GNUNET_SET_Handle *set2; 37static struct GNUNET_SET_Handle *set2;
38
36static struct GNUNET_SET_ListenHandle *listen_handle; 39static struct GNUNET_SET_ListenHandle *listen_handle;
37const static struct GNUNET_CONFIGURATION_Handle *config;
38 40
39static int iter_count; 41static const struct GNUNET_CONFIGURATION_Handle *config;
42
43static unsigned int iter_count;
40 44
41static int ret; 45static int ret;
42 46
43 47
44static void 48static void
45result_cb_set1 (void *cls, const struct GNUNET_SET_Element *element, 49result_cb_set1 (void *cls,
50 const struct GNUNET_SET_Element *element,
46 enum GNUNET_SET_Status status) 51 enum GNUNET_SET_Status status)
47{ 52{
48 switch (status) 53 switch (status)
49 { 54 {
50 case GNUNET_SET_STATUS_OK: 55 case GNUNET_SET_STATUS_OK:
51 printf ("set 1: got element\n"); 56 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
52 break; 57 "set 1: got element\n");
53 case GNUNET_SET_STATUS_FAILURE: 58 break;
54 printf ("set 1: failure\n"); 59 case GNUNET_SET_STATUS_FAILURE:
55 ret = 1; 60 GNUNET_break (0);
61 fprintf (stderr,
62 "set 1: received failure status!\n");
63 ret = 1;
64 GNUNET_SCHEDULER_shutdown ();
65 break;
66 case GNUNET_SET_STATUS_DONE:
67 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
68 "set 1: done\n");
69 GNUNET_SET_destroy (set1);
70 set1 = NULL;
71 if (NULL == set2)
56 GNUNET_SCHEDULER_shutdown (); 72 GNUNET_SCHEDULER_shutdown ();
57 break; 73 break;
58 case GNUNET_SET_STATUS_DONE: 74 default:
59 printf ("set 1: done\n"); 75 GNUNET_assert (0);
60 GNUNET_SET_destroy (set1);
61 set1 = NULL;
62 if (NULL == set2)
63 GNUNET_SCHEDULER_shutdown ();
64 break;
65 default:
66 GNUNET_assert (0);
67 } 76 }
68} 77}
69 78
70 79
71static void 80static void
72result_cb_set2 (void *cls, const struct GNUNET_SET_Element *element, 81result_cb_set2 (void *cls,
73 enum GNUNET_SET_Status status) 82 const struct GNUNET_SET_Element *element,
83 enum GNUNET_SET_Status status)
74{ 84{
75 switch (status) 85 switch (status)
76 { 86 {
77 case GNUNET_SET_STATUS_OK: 87 case GNUNET_SET_STATUS_OK:
78 printf ("set 2: got element\n"); 88 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
79 break; 89 "set 2: got element\n");
80 case GNUNET_SET_STATUS_FAILURE: 90 break;
81 printf ("set 2: failure\n"); 91 case GNUNET_SET_STATUS_FAILURE:
82 ret = 1; 92 GNUNET_break (0);
83 break; 93 fprintf (stderr,
84 case GNUNET_SET_STATUS_DONE: 94 "set 2: received failure status\n");
85 printf ("set 2: done\n"); 95 ret = 1;
86 GNUNET_SET_destroy (set2); 96 break;
87 set2 = NULL; 97 case GNUNET_SET_STATUS_DONE:
88 if (NULL == set1) 98 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
89 GNUNET_SCHEDULER_shutdown (); 99 "set 2: done\n");
90 break; 100 GNUNET_SET_destroy (set2);
91 default: 101 set2 = NULL;
92 GNUNET_assert (0); 102 if (NULL == set1)
103 GNUNET_SCHEDULER_shutdown ();
104 break;
105 default:
106 GNUNET_assert (0);
93 } 107 }
94} 108}
95 109
@@ -106,10 +120,12 @@ listen_cb (void *cls,
106 120
107 GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_TEST); 121 GNUNET_assert (ntohs (context_msg->type) == GNUNET_MESSAGE_TYPE_TEST);
108 122
109 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "listen cb called\n"); 123 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
124 "listen cb called\n");
110 GNUNET_SET_listen_cancel (listen_handle); 125 GNUNET_SET_listen_cancel (listen_handle);
111 126 oh = GNUNET_SET_accept (request,
112 oh = GNUNET_SET_accept (request, GNUNET_SET_RESULT_ADDED, result_cb_set2, NULL); 127 GNUNET_SET_RESULT_ADDED,
128 &result_cb_set2, NULL);
113 GNUNET_SET_commit (oh, set2); 129 GNUNET_SET_commit (oh, set2);
114} 130}
115 131
@@ -190,12 +206,14 @@ iter_cb (void *cls,
190{ 206{
191 if (NULL == element) 207 if (NULL == element)
192 { 208 {
193 GNUNET_assert (iter_count == 3); 209 GNUNET_assert (3 == iter_count);
194 GNUNET_SET_destroy (cls); 210 GNUNET_SET_destroy (cls);
195 return GNUNET_YES; 211 return GNUNET_YES;
196 } 212 }
197 printf ("iter: got element\n");
198 iter_count++; 213 iter_count++;
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "iter: got element %u\n",
216 iter_count);
199 return GNUNET_YES; 217 return GNUNET_YES;
200} 218}
201 219
@@ -262,17 +280,19 @@ run (void *cls,
262 280
263 config = cfg; 281 config = cfg;
264 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id); 282 GNUNET_CRYPTO_get_peer_identity (cfg, &local_id);
265 printf ("my id (from CRYPTO): %s\n", GNUNET_i2s (&local_id)); 283 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
284 "my id (from CRYPTO): %s\n",
285 GNUNET_i2s (&local_id));
266 GNUNET_TESTING_peer_get_identity (peer, &local_id); 286 GNUNET_TESTING_peer_get_identity (peer, &local_id);
267 printf ("my id (from TESTING): %s\n", GNUNET_i2s (&local_id)); 287 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
268 288 "my id (from TESTING): %s\n",
289 GNUNET_i2s (&local_id));
269 test_iter (); 290 test_iter ();
270 291
271 set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); 292 set1 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION);
272 set2 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION); 293 set2 = GNUNET_SET_create (cfg, GNUNET_SET_OPERATION_UNION);
273 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, &app_id); 294 GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK,
274 295 &app_id);
275
276 296
277 ///* test if canceling an uncommited request works! */ 297 ///* test if canceling an uncommited request works! */
278 my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL, 298 my_oh = GNUNET_SET_prepare (&local_id, &app_id, NULL,
@@ -284,6 +304,7 @@ run (void *cls,
284 init_set1 (); 304 init_set1 ();
285} 305}
286 306
307
287int 308int
288main (int argc, char **argv) 309main (int argc, char **argv)
289{ 310{