aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2017-11-02 18:15:13 +0100
committert3sserakt <t3ss@posteo.de>2017-11-02 18:15:13 +0100
commitbf2169967b3c5a4a553c133a00dd7d35289f7a9d (patch)
treec415df9e87ce7cc03cfe6dff3024dfe21d61ec8f /src/util
parentea5102e5ef870b7ed90aebfe44a4caa1148d57df (diff)
parent7c1ce9a71e362727509f013900a50ba5879ca8b2 (diff)
downloadgnunet-bf2169967b3c5a4a553c133a00dd7d35289f7a9d.tar.gz
gnunet-bf2169967b3c5a4a553c133a00dd7d35289f7a9d.zip
Merge branch 'fix_social' of gnunet.org:gnunet into fix_social
Diffstat (limited to 'src/util')
-rw-r--r--src/util/client.c8
-rw-r--r--src/util/mq.c15
-rw-r--r--src/util/mst.c27
-rw-r--r--src/util/scheduler.c18
-rw-r--r--src/util/service.c6
5 files changed, 52 insertions, 22 deletions
diff --git a/src/util/client.c b/src/util/client.c
index cf75dffbc..a5eae2a75 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -308,7 +308,9 @@ transmit_ready (void *cls)
308 * 308 *
309 * @param cls the `struct ClientState` 309 * @param cls the `struct ClientState`
310 * @param msg message we received. 310 * @param msg message we received.
311 * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing 311 * @return #GNUNET_OK on success,
312 * #GNUNET_NO to stop further processing due to disconnect (no error)
313 * #GNUNET_SYSERR to stop further processing due to error
312 */ 314 */
313static int 315static int
314recv_message (void *cls, 316recv_message (void *cls,
@@ -317,7 +319,7 @@ recv_message (void *cls,
317 struct ClientState *cstate = cls; 319 struct ClientState *cstate = cls;
318 320
319 if (GNUNET_YES == cstate->in_destroy) 321 if (GNUNET_YES == cstate->in_destroy)
320 return GNUNET_SYSERR; 322 return GNUNET_NO;
321 LOG (GNUNET_ERROR_TYPE_DEBUG, 323 LOG (GNUNET_ERROR_TYPE_DEBUG,
322 "Received message of type %u and size %u from %s\n", 324 "Received message of type %u and size %u from %s\n",
323 ntohs (msg->type), 325 ntohs (msg->type),
@@ -326,7 +328,7 @@ recv_message (void *cls,
326 GNUNET_MQ_inject_message (cstate->mq, 328 GNUNET_MQ_inject_message (cstate->mq,
327 msg); 329 msg);
328 if (GNUNET_YES == cstate->in_destroy) 330 if (GNUNET_YES == cstate->in_destroy)
329 return GNUNET_SYSERR; 331 return GNUNET_NO;
330 return GNUNET_OK; 332 return GNUNET_OK;
331} 333}
332 334
diff --git a/src/util/mq.c b/src/util/mq.c
index c7ed5330e..6ad6b82eb 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -221,8 +221,10 @@ GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq,
221 uint16_t mtype = ntohs (mh->type); 221 uint16_t mtype = ntohs (mh->type);
222 222
223 LOG (GNUNET_ERROR_TYPE_DEBUG, 223 LOG (GNUNET_ERROR_TYPE_DEBUG,
224 "Received message of type %u and size %u\n", 224 "Queue %p received message of type %u and size %u\n",
225 mtype, msize); 225 mq,
226 mtype,
227 msize);
226 228
227 if (NULL == mq->handlers) 229 if (NULL == mq->handlers)
228 goto done; 230 goto done;
@@ -359,7 +361,8 @@ GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
359 mq->current_envelope = ev; 361 mq->current_envelope = ev;
360 362
361 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 363 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
362 "mq: sending message of type %u, queue empty\n", ntohs(ev->mh->type)); 364 "mq: sending message of type %u, queue empty\n",
365 ntohs(ev->mh->type));
363 366
364 mq->send_impl (mq, 367 mq->send_impl (mq,
365 ev->mh, 368 ev->mh,
@@ -848,6 +851,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
848 ev); 851 ev);
849 GNUNET_assert (0 < mq->queue_length); 852 GNUNET_assert (0 < mq->queue_length);
850 mq->queue_length--; 853 mq->queue_length--;
854 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
855 "MQ destroy drops message of type %u\n",
856 ntohs (ev->mh->type));
851 GNUNET_MQ_discard (ev); 857 GNUNET_MQ_discard (ev);
852 } 858 }
853 if (NULL != mq->current_envelope) 859 if (NULL != mq->current_envelope)
@@ -855,6 +861,9 @@ GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq)
855 /* we can only discard envelopes that 861 /* we can only discard envelopes that
856 * are not queued! */ 862 * are not queued! */
857 mq->current_envelope->parent_queue = NULL; 863 mq->current_envelope->parent_queue = NULL;
864 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
865 "MQ destroy drops message of type %u\n",
866 ntohs (mq->current_envelope->mh->type));
858 GNUNET_MQ_discard (mq->current_envelope); 867 GNUNET_MQ_discard (mq->current_envelope);
859 mq->current_envelope = NULL; 868 mq->current_envelope = NULL;
860 GNUNET_assert (0 < mq->queue_length); 869 GNUNET_assert (0 < mq->queue_length);
diff --git a/src/util/mst.c b/src/util/mst.c
index 0d90c5d10..5e472965f 100644
--- a/src/util/mst.c
+++ b/src/util/mst.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2010, 2016 GNUnet e.V. 3 Copyright (C) 2010, 2016, 2017 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -126,6 +126,7 @@ GNUNET_MST_from_buffer (struct GNUNET_MessageStreamTokenizer *mst,
126 int need_align; 126 int need_align;
127 unsigned long offset; 127 unsigned long offset;
128 int ret; 128 int ret;
129 int cbret;
129 130
130 GNUNET_assert (mst->off <= mst->pos); 131 GNUNET_assert (mst->off <= mst->pos);
131 GNUNET_assert (mst->pos <= mst->curr_buf); 132 GNUNET_assert (mst->pos <= mst->curr_buf);
@@ -229,9 +230,17 @@ do_align:
229 if (one_shot == GNUNET_YES) 230 if (one_shot == GNUNET_YES)
230 one_shot = GNUNET_SYSERR; 231 one_shot = GNUNET_SYSERR;
231 mst->off += want; 232 mst->off += want;
232 if (GNUNET_SYSERR == mst->cb (mst->cb_cls, 233 if (GNUNET_OK !=
233 hdr)) 234 (cbret = mst->cb (mst->cb_cls,
235 hdr)))
236 {
237 if (GNUNET_SYSERR == cbret)
238 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
239 "Failure processing message of type %u and size %u\n",
240 ntohs (hdr->type),
241 ntohs (hdr->size));
234 return GNUNET_SYSERR; 242 return GNUNET_SYSERR;
243 }
235 if (mst->off == mst->pos) 244 if (mst->off == mst->pos)
236 { 245 {
237 /* reset to beginning of buffer, it's free right now! */ 246 /* reset to beginning of buffer, it's free right now! */
@@ -271,9 +280,17 @@ do_align:
271 } 280 }
272 if (one_shot == GNUNET_YES) 281 if (one_shot == GNUNET_YES)
273 one_shot = GNUNET_SYSERR; 282 one_shot = GNUNET_SYSERR;
274 if (GNUNET_SYSERR == mst->cb (mst->cb_cls, 283 if (GNUNET_OK !=
275 hdr)) 284 (cbret = mst->cb (mst->cb_cls,
285 hdr)))
286 {
287 if (GNUNET_SYSERR == cbret)
288 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
289 "Failure processing message of type %u and size %u\n",
290 ntohs (hdr->type),
291 ntohs (hdr->size));
276 return GNUNET_SYSERR; 292 return GNUNET_SYSERR;
293 }
277 buf += want; 294 buf += want;
278 size -= want; 295 size -= want;
279 } 296 }
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index a7b1d8e2a..b07c51811 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -73,7 +73,7 @@
73 * Argument to be passed from the driver to 73 * Argument to be passed from the driver to
74 * #GNUNET_SCHEDULER_run_from_driver(). Contains the 74 * #GNUNET_SCHEDULER_run_from_driver(). Contains the
75 * scheduler's internal state. 75 * scheduler's internal state.
76 */ 76 */
77struct GNUNET_SCHEDULER_Handle 77struct GNUNET_SCHEDULER_Handle
78{ 78{
79 /** 79 /**
@@ -94,7 +94,7 @@ struct GNUNET_SCHEDULER_Handle
94 * Driver we used for the event loop. 94 * Driver we used for the event loop.
95 */ 95 */
96 const struct GNUNET_SCHEDULER_Driver *driver; 96 const struct GNUNET_SCHEDULER_Driver *driver;
97 97
98}; 98};
99 99
100 100
@@ -127,7 +127,7 @@ struct GNUNET_SCHEDULER_Task
127 * Handle to the scheduler's state. 127 * Handle to the scheduler's state.
128 */ 128 */
129 const struct GNUNET_SCHEDULER_Handle *sh; 129 const struct GNUNET_SCHEDULER_Handle *sh;
130 130
131 /** 131 /**
132 * Set of file descriptors this task is waiting 132 * Set of file descriptors this task is waiting
133 * for for reading. Once ready, this is updated 133 * for for reading. Once ready, this is updated
@@ -172,7 +172,7 @@ struct GNUNET_SCHEDULER_Task
172 * Size of the @e fds array. 172 * Size of the @e fds array.
173 */ 173 */
174 unsigned int fds_len; 174 unsigned int fds_len;
175 175
176 /** 176 /**
177 * Why is the task ready? Set after task is added to ready queue. 177 * Why is the task ready? Set after task is added to ready queue.
178 * Initially set to zero. All reasons that have already been 178 * Initially set to zero. All reasons that have already been
@@ -589,9 +589,7 @@ static void
589dump_backtrace (struct GNUNET_SCHEDULER_Task *t) 589dump_backtrace (struct GNUNET_SCHEDULER_Task *t)
590{ 590{
591#if EXECINFO 591#if EXECINFO
592 unsigned int i; 592 for (unsigned int i = 0; i < t->num_backtrace_strings; i++)
593
594 for (i = 0; i < t->num_backtrace_strings; i++)
595 LOG (GNUNET_ERROR_TYPE_DEBUG, 593 LOG (GNUNET_ERROR_TYPE_DEBUG,
596 "Task %p trace %u: %s\n", 594 "Task %p trace %u: %s\n",
597 t, 595 t,
@@ -1849,7 +1847,7 @@ GNUNET_SCHEDULER_task_ready (struct GNUNET_SCHEDULER_Task *task,
1849 * 1847 *
1850 * @param sh scheduler handle that was given to the `loop` 1848 * @param sh scheduler handle that was given to the `loop`
1851 * @return #GNUNET_OK if there are more tasks that are ready, 1849 * @return #GNUNET_OK if there are more tasks that are ready,
1852 * and thus we would like to run more (yield to avoid 1850 * and thus we would like to run more (yield to avoid
1853 * blocking other activities for too long) 1851 * blocking other activities for too long)
1854 * #GNUNET_NO if we are done running tasks (yield to block) 1852 * #GNUNET_NO if we are done running tasks (yield to block)
1855 * #GNUNET_SYSERR on error 1853 * #GNUNET_SYSERR on error
@@ -1876,11 +1874,11 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh)
1876 pending_timeout_last = NULL; 1874 pending_timeout_last = NULL;
1877 queue_ready_task (pos); 1875 queue_ready_task (pos);
1878 } 1876 }
1879 1877
1880 if (0 == ready_count) 1878 if (0 == ready_count)
1881 return GNUNET_NO; 1879 return GNUNET_NO;
1882 1880
1883 /* find out which task priority level we are going to 1881 /* find out which task priority level we are going to
1884 process this time */ 1882 process this time */
1885 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP; 1883 max_priority_added = GNUNET_SCHEDULER_PRIORITY_KEEP;
1886 GNUNET_assert (NULL == ready_head[GNUNET_SCHEDULER_PRIORITY_KEEP]); 1884 GNUNET_assert (NULL == ready_head[GNUNET_SCHEDULER_PRIORITY_KEEP]);
diff --git a/src/util/service.c b/src/util/service.c
index 10dc93faf..782adf5c5 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -2402,7 +2402,7 @@ resume_client_receive (void *cls)
2402 GNUNET_YES); 2402 GNUNET_YES);
2403 if (GNUNET_SYSERR == ret) 2403 if (GNUNET_SYSERR == ret)
2404 { 2404 {
2405 if (NULL != c->drop_task) 2405 if (NULL == c->drop_task)
2406 GNUNET_SERVICE_client_drop (c); 2406 GNUNET_SERVICE_client_drop (c);
2407 return; 2407 return;
2408 } 2408 }
@@ -2514,6 +2514,10 @@ GNUNET_SERVICE_client_drop (struct GNUNET_SERVICE_Client *c)
2514{ 2514{
2515 struct GNUNET_SERVICE_Handle *sh = c->sh; 2515 struct GNUNET_SERVICE_Handle *sh = c->sh;
2516 2516
2517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2518 "Client dropped: %p (MQ: %p)\n",
2519 c,
2520 c->mq);
2517 if (NULL != c->drop_task) 2521 if (NULL != c->drop_task)
2518 { 2522 {
2519 /* asked to drop twice! */ 2523 /* asked to drop twice! */