aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-02-27 22:15:30 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-02-27 22:15:30 +0100
commitbcb5e8d91393d99ea26128f8d5e0261fe6adccc4 (patch)
tree3a1067c4a0f8cd7b54c084b02dcd5c744002a17c
parentd2395d4befccc42d2e2b45c5d49746aebf7ba3a5 (diff)
downloadgnunet-bcb5e8d91393d99ea26128f8d5e0261fe6adccc4.tar.gz
gnunet-bcb5e8d91393d99ea26128f8d5e0261fe6adccc4.zip
sanity checks
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index cd5093c46..1746fc509 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -1410,7 +1410,8 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
1410 * We always send if possible in this case. 1410 * We always send if possible in this case.
1411 * It is guaranteed that the queued MID < received MID 1411 * It is guaranteed that the queued MID < received MID
1412 **/ 1412 **/
1413 if (GNUNET_YES == ccc->client_ready) 1413 if ((NULL != ccc->head_recv) &&
1414 (GNUNET_YES == ccc->client_ready))
1414 { 1415 {
1415 next_msg = ccc->head_recv; 1416 next_msg = ccc->head_recv;
1416 LOG (GNUNET_ERROR_TYPE_DEBUG, 1417 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -1429,12 +1430,11 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
1429 next_msg); 1430 next_msg);
1430 ccc->num_recv--; 1431 ccc->num_recv--;
1431 /* Do not process duplicate MID */ 1432 /* Do not process duplicate MID */
1432 if ((msg->mid.mid == next_msg->mid.mid) || /* Duplicate */ 1433 if (msg->mid.mid == next_msg->mid.mid) /* Duplicate */
1433 (ntohl (msg->mid.mid) < ntohl (ch->mid_recv.mid))) /* Old */
1434 { 1434 {
1435 /* Duplicate within the queue, drop */ 1435 /* Duplicate within the queue, drop */
1436 LOG (GNUNET_ERROR_TYPE_DEBUG, 1436 LOG (GNUNET_ERROR_TYPE_DEBUG,
1437 "Message on %s (mid %u) dropped\n", 1437 "Message on %s (mid %u) dropped, duplicate\n",
1438 GCCH_2s (ch), 1438 GCCH_2s (ch),
1439 ntohl (msg->mid.mid)); 1439 ntohl (msg->mid.mid));
1440 GNUNET_free (next_msg); 1440 GNUNET_free (next_msg);
@@ -1444,6 +1444,17 @@ GCCH_handle_channel_plaintext_data (struct CadetChannel *ch,
1444 GNUNET_free (next_msg); 1444 GNUNET_free (next_msg);
1445 } 1445 }
1446 1446
1447 if (ntohl (msg->mid.mid) < ntohl (ch->mid_recv.mid)) /* Old */
1448 {
1449 /* Duplicate within the queue, drop */
1450 LOG (GNUNET_ERROR_TYPE_DEBUG,
1451 "Message on %s (mid %u) dropped, old.\n",
1452 GCCH_2s (ch),
1453 ntohl (msg->mid.mid));
1454 GNUNET_MQ_discard (env);
1455 return;
1456 }
1457
1447 /* Channel is unreliable, so we do not ACK. But we also cannot 1458 /* Channel is unreliable, so we do not ACK. But we also cannot
1448 allow buffering everything, so check if we have space... */ 1459 allow buffering everything, so check if we have space... */
1449 if (ccc->num_recv >= ch->max_pending_messages) 1460 if (ccc->num_recv >= ch->max_pending_messages)