diff options
Diffstat (limited to 'src/util/mq.c')
-rw-r--r-- | src/util/mq.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/src/util/mq.c b/src/util/mq.c index 95bcd71cb..a8216d964 100644 --- a/src/util/mq.c +++ b/src/util/mq.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | 28 | ||
29 | #define LOG(kind,...) GNUNET_log_from (kind, "mq",__VA_ARGS__) | 29 | #define LOG(kind,...) GNUNET_log_from (kind, "util-mq",__VA_ARGS__) |
30 | 30 | ||
31 | 31 | ||
32 | struct GNUNET_MQ_Envelope | 32 | struct GNUNET_MQ_Envelope |
@@ -235,24 +235,29 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, | |||
235 | { | 235 | { |
236 | const struct GNUNET_MQ_MessageHandler *handler; | 236 | const struct GNUNET_MQ_MessageHandler *handler; |
237 | int handled = GNUNET_NO; | 237 | int handled = GNUNET_NO; |
238 | uint16_t ms = ntohs (mh->size); | 238 | uint16_t msize = ntohs (mh->size); |
239 | uint16_t mtype = ntohs (mh->type); | ||
240 | |||
241 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
242 | "Received message of type %u and size %u\n", | ||
243 | mtype, msize); | ||
239 | 244 | ||
240 | if (NULL == mq->handlers) | 245 | if (NULL == mq->handlers) |
241 | goto done; | 246 | goto done; |
242 | for (handler = mq->handlers; NULL != handler->cb; handler++) | 247 | for (handler = mq->handlers; NULL != handler->cb; handler++) |
243 | { | 248 | { |
244 | if (handler->type == ntohs (mh->type)) | 249 | if (handler->type == mtype) |
245 | { | 250 | { |
246 | handled = GNUNET_YES; | 251 | handled = GNUNET_YES; |
247 | if ( (handler->expected_size > ms) || | 252 | if ( (handler->expected_size > msize) || |
248 | ( (handler->expected_size != ms) && | 253 | ( (handler->expected_size != msize) && |
249 | (NULL == handler->mv) ) ) | 254 | (NULL == handler->mv) ) ) |
250 | { | 255 | { |
251 | /* Too small, or not an exact size and | 256 | /* Too small, or not an exact size and |
252 | no 'mv' handler to check rest */ | 257 | no 'mv' handler to check rest */ |
253 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 258 | LOG (GNUNET_ERROR_TYPE_ERROR, |
254 | "Received malformed message of type %u\n", | 259 | "Received malformed message of type %u\n", |
255 | (unsigned int) handler->type); | 260 | (unsigned int) handler->type); |
256 | GNUNET_MQ_inject_error (mq, | 261 | GNUNET_MQ_inject_error (mq, |
257 | GNUNET_MQ_ERROR_MALFORMED); | 262 | GNUNET_MQ_ERROR_MALFORMED); |
258 | break; | 263 | break; |
@@ -267,9 +272,9 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, | |||
267 | else | 272 | else |
268 | { | 273 | { |
269 | /* Message rejected by check routine */ | 274 | /* Message rejected by check routine */ |
270 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 275 | LOG (GNUNET_ERROR_TYPE_ERROR, |
271 | "Received malformed message of type %u\n", | 276 | "Received malformed message of type %u\n", |
272 | (unsigned int) handler->type); | 277 | (unsigned int) handler->type); |
273 | GNUNET_MQ_inject_error (mq, | 278 | GNUNET_MQ_inject_error (mq, |
274 | GNUNET_MQ_ERROR_MALFORMED); | 279 | GNUNET_MQ_ERROR_MALFORMED); |
275 | } | 280 | } |
@@ -279,9 +284,8 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq, | |||
279 | done: | 284 | done: |
280 | if (GNUNET_NO == handled) | 285 | if (GNUNET_NO == handled) |
281 | LOG (GNUNET_ERROR_TYPE_INFO, | 286 | LOG (GNUNET_ERROR_TYPE_INFO, |
282 | "No handler for message of type %d and size %d\n", | 287 | "No handler for message of type %u and size %u\n", |
283 | ntohs (mh->type), | 288 | mtype, msize); |
284 | ntohs (mh->size)); | ||
285 | } | 289 | } |
286 | 290 | ||
287 | 291 | ||
@@ -756,9 +760,13 @@ server_client_send_impl (struct GNUNET_MQ_Handle *mq, | |||
756 | const struct GNUNET_MessageHeader *msg, | 760 | const struct GNUNET_MessageHeader *msg, |
757 | void *impl_state) | 761 | void *impl_state) |
758 | { | 762 | { |
759 | struct ServerClientSocketState *state = impl_state; | ||
760 | |||
761 | GNUNET_assert (NULL != mq); | 763 | GNUNET_assert (NULL != mq); |
764 | |||
765 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
766 | "Transmitting message of type %u and size %u\n", | ||
767 | ntohs (msg->type), ntohs (msg->size)); | ||
768 | |||
769 | struct ServerClientSocketState *state = impl_state; | ||
762 | state->th = GNUNET_SERVER_notify_transmit_ready (state->client, | 770 | state->th = GNUNET_SERVER_notify_transmit_ready (state->client, |
763 | ntohs (msg->size), | 771 | ntohs (msg->size), |
764 | GNUNET_TIME_UNIT_FOREVER_REL, | 772 | GNUNET_TIME_UNIT_FOREVER_REL, |