diff options
Diffstat (limited to 'src/util/test_mq_client.c')
-rw-r--r-- | src/util/test_mq_client.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/util/test_mq_client.c b/src/util/test_mq_client.c index f894c3912..27458ec0a 100644 --- a/src/util/test_mq_client.c +++ b/src/util/test_mq_client.c | |||
@@ -32,8 +32,6 @@ | |||
32 | 32 | ||
33 | static struct GNUNET_SERVER_Handle *server; | 33 | static struct GNUNET_SERVER_Handle *server; |
34 | 34 | ||
35 | static struct GNUNET_CLIENT_Connection *client; | ||
36 | |||
37 | static struct GNUNET_CONFIGURATION_Handle *cfg; | 35 | static struct GNUNET_CONFIGURATION_Handle *cfg; |
38 | 36 | ||
39 | static int ok; | 37 | static int ok; |
@@ -44,13 +42,15 @@ static int received = 0; | |||
44 | 42 | ||
45 | 43 | ||
46 | static void | 44 | static void |
47 | recv_cb (void *cls, struct GNUNET_SERVER_Client *argclient, | 45 | recv_cb (void *cls, |
46 | struct GNUNET_SERVER_Client *argclient, | ||
48 | const struct GNUNET_MessageHeader *message) | 47 | const struct GNUNET_MessageHeader *message) |
49 | { | 48 | { |
50 | received++; | 49 | received++; |
51 | if (received == 2) | 50 | if (received == 2) |
52 | { | 51 | { |
53 | GNUNET_SERVER_receive_done (argclient, GNUNET_NO); | 52 | GNUNET_SERVER_receive_done (argclient, |
53 | GNUNET_NO); | ||
54 | return; | 54 | return; |
55 | } | 55 | } |
56 | 56 | ||
@@ -79,7 +79,8 @@ clean_up (void *cls) | |||
79 | * @param client identification of the client | 79 | * @param client identification of the client |
80 | */ | 80 | */ |
81 | static void | 81 | static void |
82 | notify_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | 82 | notify_disconnect (void *cls, |
83 | struct GNUNET_SERVER_Client *client) | ||
83 | { | 84 | { |
84 | if (client == NULL) | 85 | if (client == NULL) |
85 | return; | 86 | return; |
@@ -110,11 +111,15 @@ send_trap_cb (void *cls) | |||
110 | 111 | ||
111 | 112 | ||
112 | static void | 113 | static void |
113 | test_mq (struct GNUNET_CLIENT_Connection *client) | 114 | test_mq () |
114 | { | 115 | { |
116 | struct GNUNET_CLIENT_Connection *client; | ||
115 | struct GNUNET_MQ_Handle *mq; | 117 | struct GNUNET_MQ_Handle *mq; |
116 | struct GNUNET_MQ_Envelope *mqm; | 118 | struct GNUNET_MQ_Envelope *mqm; |
117 | 119 | ||
120 | client = GNUNET_CLIENT_connect ("test", cfg); | ||
121 | GNUNET_assert (client != NULL); | ||
122 | |||
118 | /* FIXME: test handling responses */ | 123 | /* FIXME: test handling responses */ |
119 | mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL, NULL); | 124 | mq = GNUNET_MQ_queue_for_connection_client (client, NULL, NULL, NULL); |
120 | 125 | ||
@@ -122,14 +127,13 @@ test_mq (struct GNUNET_CLIENT_Connection *client) | |||
122 | GNUNET_MQ_send (mq, mqm); | 127 | GNUNET_MQ_send (mq, mqm); |
123 | 128 | ||
124 | mqm = GNUNET_MQ_msg_header (MY_TYPE); | 129 | mqm = GNUNET_MQ_msg_header (MY_TYPE); |
125 | GNUNET_MQ_notify_sent (mqm, send_trap_cb, NULL); | 130 | GNUNET_MQ_notify_sent (mqm, &send_trap_cb, NULL); |
126 | GNUNET_MQ_send (mq, mqm); | 131 | GNUNET_MQ_send (mq, mqm); |
127 | GNUNET_MQ_send_cancel (mqm); | 132 | GNUNET_MQ_send_cancel (mqm); |
128 | 133 | ||
129 | mqm = GNUNET_MQ_msg_header (MY_TYPE); | 134 | mqm = GNUNET_MQ_msg_header (MY_TYPE); |
130 | GNUNET_MQ_notify_sent (mqm, send_cb, NULL); | 135 | GNUNET_MQ_notify_sent (mqm, &send_cb, NULL); |
131 | GNUNET_MQ_send (mq, mqm); | 136 | GNUNET_MQ_send (mq, mqm); |
132 | |||
133 | } | 137 | } |
134 | 138 | ||
135 | 139 | ||
@@ -163,10 +167,7 @@ task (void *cls) | |||
163 | GNUNET_CONFIGURATION_set_value_string (cfg, "test", "HOSTNAME", "localhost"); | 167 | GNUNET_CONFIGURATION_set_value_string (cfg, "test", "HOSTNAME", "localhost"); |
164 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", | 168 | GNUNET_CONFIGURATION_set_value_string (cfg, "resolver", "HOSTNAME", |
165 | "localhost"); | 169 | "localhost"); |
166 | client = GNUNET_CLIENT_connect ("test", cfg); | 170 | test_mq (); |
167 | GNUNET_assert (client != NULL); | ||
168 | |||
169 | test_mq (client); | ||
170 | } | 171 | } |
171 | 172 | ||
172 | 173 | ||