]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Add debug message when dropping a packet because all SACK entries are used.
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index 95a82c428710ca91f5f2752045eea036bee40c79..1627be77cbce59467e7aae4936cd4a730ff73ce7 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -53,9 +53,9 @@
 } while (0)
 #endif
 
-#ifndef max
-#define max(a, b) ((a) > (b) ? (a) : (b))
-#endif
+static inline size_t max(size_t a, size_t b) {
+       return a > b ? a : b;
+}
 
 #ifdef UTCP_DEBUG
 #include <stdarg.h>
@@ -650,7 +650,7 @@ cleanup:
  * that are shifted to before the start of the receive buffer.
  *
  * There are three cases:
- * - the SACK entry is ahead of ^, in that case just change the offset.
+ * - the SACK entry is after ^, in that case just change the offset.
  * - the SACK entry starts before and ends after ^, so we have to
  *   change both its offset and size.
  * - the SACK entry is completely before ^, in that case delete it.
@@ -706,6 +706,8 @@ static void handle_out_of_order(struct utcp_connection *c, uint32_t offset, cons
                                        memmove(&c->sacks[i + 1], &c->sacks[i], (NSACKS - i - 1) * sizeof c->sacks[i]);
                                        c->sacks[i].offset = offset;
                                        c->sacks[i].len = rxd;
+                               } else {
+                                       debug("SACK entries full, dropping packet\n");
                                }
                                break;
                        } else { // merge