aboutsummaryrefslogtreecommitdiff
path: root/src/core/test_core_api_mq.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/test_core_api_mq.c')
-rw-r--r--src/core/test_core_api_mq.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/core/test_core_api_mq.c b/src/core/test_core_api_mq.c
index a82465e74..8ece78e58 100644
--- a/src/core/test_core_api_mq.c
+++ b/src/core/test_core_api_mq.c
@@ -29,15 +29,15 @@
29/** 29/**
30 * Has the test been successful? 30 * Has the test been successful?
31 */ 31 */
32int result; 32static int result;
33 33
34unsigned int num_received; 34static unsigned int num_received;
35 35
36struct GNUNET_CORE_Handle *core; 36static struct GNUNET_CORE_Handle *core;
37 37
38struct GNUNET_MQ_Handle *mq; 38static struct GNUNET_MQ_Handle *mq;
39 39
40struct GNUNET_PeerIdentity myself; 40static struct GNUNET_PeerIdentity myself;
41 41
42 42
43static void 43static void
@@ -55,15 +55,19 @@ init_cb (void *cls,
55 55
56 56
57static void 57static void
58connect_cb (void *cls, const struct GNUNET_PeerIdentity *peer) 58connect_cb (void *cls,
59 const struct GNUNET_PeerIdentity *peer)
59{ 60{
60 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected to peer %s.\n", 61 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
62 "Connected to peer %s.\n",
61 GNUNET_i2s (peer)); 63 GNUNET_i2s (peer));
62 if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity))) 64 if (0 == memcmp (peer, &myself, sizeof (struct GNUNET_PeerIdentity)))
63 { 65 {
64 unsigned int i; 66 unsigned int i;
65 struct GNUNET_MQ_Envelope *ev; 67 struct GNUNET_MQ_Envelope *ev;
66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Queueing messages.\n"); 68
69 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
70 "Queueing messages.\n");
67 for (i = 0; i < NUM_MSG; i++) 71 for (i = 0; i < NUM_MSG; i++)
68 { 72 {
69 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST); 73 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_TEST);
@@ -78,7 +82,9 @@ handle_test (void *cls,
78 const struct GNUNET_PeerIdentity *other, 82 const struct GNUNET_PeerIdentity *other,
79 const struct GNUNET_MessageHeader *message) 83 const struct GNUNET_MessageHeader *message)
80{ 84{
81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got test message %d\n", num_received); 85 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
86 "Got test message %d\n",
87 num_received);
82 num_received++; 88 num_received++;
83 if (NUM_MSG == num_received) 89 if (NUM_MSG == num_received)
84 { 90 {
@@ -98,7 +104,8 @@ handle_test (void *cls,
98static void 104static void
99shutdown_task (void *cls) 105shutdown_task (void *cls)
100{ 106{
101 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down\n"); 107 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
108 "Shutting down\n");
102 GNUNET_MQ_destroy (mq); 109 GNUNET_MQ_destroy (mq);
103 GNUNET_CORE_disconnect (core); 110 GNUNET_CORE_disconnect (core);
104} 111}
@@ -129,9 +136,10 @@ run (void *cls,
129 GNUNET_assert (0); 136 GNUNET_assert (0);
130 return; 137 return;
131 } 138 }
132 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); 139 GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL);
133} 140}
134 141
142
135int 143int
136main (int argc, char *argv1[]) 144main (int argc, char *argv1[])
137{ 145{