Merge pull request #177 from mrdeep1/traffic-restart

coap main loop may wait un-necessarily in select() call when in fact there is work to do
This commit is contained in:
obgm authored and GitHub committed 2018-05-18 13:31:12 +02:00
commit 06d3a44e98
1 file changed
+13 -3
+13 -3
View File
@@ -1071,7 +1071,7 @@ coap_write(coap_context_t *ctx,
coap_session_free(s);
} else {
if (s->type == COAP_SESSION_TYPE_SERVER && s->ref == 0 && s->sendqueue == NULL) {
coap_tick_t s_timeout = now - (s->last_rx_tx + session_timeout);
coap_tick_t s_timeout = (s->last_rx_tx + session_timeout) - now;
if (timeout == 0 || s_timeout < timeout)
timeout = s_timeout;
}
@@ -1119,7 +1119,12 @@ coap_write(coap_context_t *ctx,
while (tls_timeout > 0 && tls_timeout <= now) {
coap_log(LOG_DEBUG, "** %s: DTLS retransmit timeout\n", coap_session_str(s));
coap_dtls_handle_timeout(s);
tls_timeout = s->tls ? coap_dtls_get_timeout(s) : 0;
if (s->tls)
tls_timeout = coap_dtls_get_timeout(s);
else {
tls_timeout = 0;
timeout = 1;
}
}
if (tls_timeout > 0 && (timeout == 0 || tls_timeout - now < timeout))
timeout = tls_timeout - now;
@@ -1133,7 +1138,12 @@ coap_write(coap_context_t *ctx,
while (tls_timeout > 0 && tls_timeout <= now) {
coap_log(LOG_DEBUG, "** %s: DTLS retransmit timeout\n", coap_session_str(s));
coap_dtls_handle_timeout(s);
tls_timeout = s->tls ? coap_dtls_get_timeout(s) : 0;
if (s->tls)
tls_timeout = coap_dtls_get_timeout(s);
else {
tls_timeout = 0;
timeout = 1;
}
}
if (tls_timeout > 0 && (timeout == 0 || tls_timeout - now < timeout))
timeout = tls_timeout - now;