aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-10-29 12:32:57 +0100
committerChristian Grothoff <christian@grothoff.org>2017-10-29 12:32:57 +0100
commit17f5db6f7c8d60930367738b3d872fbf891486ee (patch)
tree52e6362a319a417c813876f36733b4bdc567593a /src/util
parentd10108c802b56535b03597e9fbb7603b0eeef9c0 (diff)
downloadgnunet-17f5db6f7c8d60930367738b3d872fbf891486ee.tar.gz
gnunet-17f5db6f7c8d60930367738b3d872fbf891486ee.zip
allow MST callback to distinguish between disconnect and parse error situations, and only log for the hard errors
Diffstat (limited to 'src/util')
-rw-r--r--src/util/client.c8
-rw-r--r--src/util/mst.c29
2 files changed, 22 insertions, 15 deletions
diff --git a/src/util/client.c b/src/util/client.c
index 90bc837d7..138b1cfdd 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -306,7 +306,9 @@ transmit_ready (void *cls)
306 * 306 *
307 * @param cls the `struct ClientState` 307 * @param cls the `struct ClientState`
308 * @param msg message we received. 308 * @param msg message we received.
309 * @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing 309 * @return #GNUNET_OK on success,
310 * #GNUNET_NO to stop further processing due to disconnect (no error)
311 * #GNUNET_SYSERR to stop further processing due to error
310 */ 312 */
311static int 313static int
312recv_message (void *cls, 314recv_message (void *cls,
@@ -315,7 +317,7 @@ recv_message (void *cls,
315 struct ClientState *cstate = cls; 317 struct ClientState *cstate = cls;
316 318
317 if (GNUNET_YES == cstate->in_destroy) 319 if (GNUNET_YES == cstate->in_destroy)
318 return GNUNET_SYSERR; 320 return GNUNET_NO;
319 LOG (GNUNET_ERROR_TYPE_DEBUG, 321 LOG (GNUNET_ERROR_TYPE_DEBUG,
320 "Received message of type %u and size %u from %s\n", 322 "Received message of type %u and size %u from %s\n",
321 ntohs (msg->type), 323 ntohs (msg->type),
@@ -324,7 +326,7 @@ recv_message (void *cls,
324 GNUNET_MQ_inject_message (cstate->mq, 326 GNUNET_MQ_inject_message (cstate->mq,
325 msg); 327 msg);
326 if (GNUNET_YES == cstate->in_destroy) 328 if (GNUNET_YES == cstate->in_destroy)
327 return GNUNET_SYSERR; 329 return GNUNET_NO;
328 return GNUNET_OK; 330 return GNUNET_OK;
329} 331}
330 332
diff --git a/src/util/mst.c b/src/util/mst.c
index 4c2a74212..5e472965f 100644
--- a/src/util/mst.c
+++ b/src/util/mst.c
@@ -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,13 +230,15 @@ 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)))
234 { 236 {
235 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 237 if (GNUNET_SYSERR == cbret)
236 "Failure processing message of type %u and size %u\n", 238 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
237 ntohs (hdr->type), 239 "Failure processing message of type %u and size %u\n",
238 ntohs (hdr->size)); 240 ntohs (hdr->type),
241 ntohs (hdr->size));
239 return GNUNET_SYSERR; 242 return GNUNET_SYSERR;
240 } 243 }
241 if (mst->off == mst->pos) 244 if (mst->off == mst->pos)
@@ -277,13 +280,15 @@ do_align:
277 } 280 }
278 if (one_shot == GNUNET_YES) 281 if (one_shot == GNUNET_YES)
279 one_shot = GNUNET_SYSERR; 282 one_shot = GNUNET_SYSERR;
280 if (GNUNET_SYSERR == mst->cb (mst->cb_cls, 283 if (GNUNET_OK !=
281 hdr)) 284 (cbret = mst->cb (mst->cb_cls,
285 hdr)))
282 { 286 {
283 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 287 if (GNUNET_SYSERR == cbret)
284 "Failure processing message of type %u and size %u\n", 288 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
285 ntohs (hdr->type), 289 "Failure processing message of type %u and size %u\n",
286 ntohs (hdr->size)); 290 ntohs (hdr->type),
291 ntohs (hdr->size));
287 return GNUNET_SYSERR; 292 return GNUNET_SYSERR;
288 } 293 }
289 buf += want; 294 buf += want;