From 0a0cd1fb4eadefa934a12f303ed6e0fb3cec0bf5 Mon Sep 17 00:00:00 2001 From: jcmichelou Date: Thu, 22 Jun 2017 16:06:11 +0200 Subject: [PATCH] Make retransmit timeout relative in tinydtls. --- src/coap_tinydtls.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/coap_tinydtls.c b/src/coap_tinydtls.c index d252807e..33521d0d 100644 --- a/src/coap_tinydtls.c +++ b/src/coap_tinydtls.c @@ -303,11 +303,10 @@ int coap_dtls_get_context_timeout(void *dtls_context) { clock_time_t next = 0; dtls_check_retransmit((struct dtls_context_t *)dtls_context, &next); if (next > 0) { -#if DTLS_TICKS_PER_SECOND != 1000 - return (int)((next * 1000 + DTLS_TICKS_PER_SECOND - 1) / DTLS_TICKS_PER_SECOND); -#else - return (int)next; -#endif + clock_time_t now; + dtls_ticks(&now); + if (next >= now) + return (int)(((next - now) * 1000 + DTLS_TICKS_PER_SECOND - 1) / DTLS_TICKS_PER_SECOND); } return -1; }