]> git.meshlink.io Git - utcp/blobdiff - utcp.c
Define USEC_PER_SEC, use "sec" and "usec" in comments.
[utcp] / utcp.c
diff --git a/utcp.c b/utcp.c
index 95a82c428710ca91f5f2752045eea036bee40c79..f2354b1b8d181fd103edcfff3b7b4c7bbf44b9ec 100644 (file)
--- a/utcp.c
+++ b/utcp.c
        (r)->tv_sec = (a)->tv_sec - (b)->tv_sec;\
        (r)->tv_usec = (a)->tv_usec - (b)->tv_usec;\
        if((r)->tv_usec < 0)\
-               (r)->tv_sec--, (r)->tv_usec += 1000000;\
+               (r)->tv_sec--, (r)->tv_usec += USEC_PER_SEC;\
 } 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
@@ -1432,8 +1434,8 @@ struct utcp *utcp_init(utcp_accept_t accept, utcp_pre_accept_t pre_accept, utcp_
        utcp->send = send;
        utcp->priv = priv;
        utcp->mtu = DEFAULT_MTU;
-       utcp->timeout = DEFAULT_USER_TIMEOUT; // s
-       utcp->rto = START_RTO; // us
+       utcp->timeout = DEFAULT_USER_TIMEOUT; // sec
+       utcp->rto = START_RTO; // usec
 
        return utcp;
 }