mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-18 13:39:05 +03:00
coap_io.c: Correct timeout values when entry has just timed out
If calculated timeout is 0 in coap_io_prepare_io_lkd(), then do not set overall timeout to 0 so that when passed back to caller it does not get reset to the caller's max defined timeout. Updated some timeout check functions to update remaining timeout in a new parameter and to return 1 if this parameter was updated, else 0. for simplicity. It was also unsafe to set the initial max timeout value to -1 as coap_tick_t can be int64_t.
This commit is contained in:
1 parent
04f789b3ce
commit
3afff2dba5
8 files changed
+163
-87
No files matched your search
@@ -74,11 +74,12 @@ coap_async_t *coap_register_async_lkd(coap_session_t *session,
|
||||
*
|
||||
* @param context The current context.
|
||||
* @param now The current time in ticks.
|
||||
* @param tim_rem Updated with the remaining timeout time if return is @c 1,
|
||||
* unless set to NULL.
|
||||
*
|
||||
* @return The tick time before the next Async needs to go, else 0 if
|
||||
* nothing to do.
|
||||
* @return @c 1 if @p tim_rem is set, else @c 0 if there is no timeout.
|
||||
*/
|
||||
coap_tick_t coap_check_async(coap_context_t *context, coap_tick_t now);
|
||||
int coap_check_async(coap_context_t *context, coap_tick_t now, coap_tick_t *tim_rem);
|
||||
|
||||
/**
|
||||
* Retrieves the object identified by @p token from the list of asynchronous
|
||||
|
||||
@@ -258,8 +258,17 @@ coap_mid_t coap_send_q_block1(coap_session_t *session,
|
||||
coap_pdu_t *request,
|
||||
coap_send_pdu_t send_request);
|
||||
|
||||
coap_tick_t coap_block_check_q_block1_xmit(coap_session_t *session,
|
||||
coap_tick_t now);
|
||||
/**
|
||||
* Check if the next Q-Block1 needs to be sent, else get the next timeout value.
|
||||
*
|
||||
* @param session The Session to check.
|
||||
* @param now The current time in ticks.
|
||||
* @param tim_rem Updated with the remaining timeout time if return is @c 1.
|
||||
*
|
||||
* @return @c 1 if @p tim_rem is set, else @c 0 if there is no timeout.
|
||||
*/
|
||||
int coap_block_check_q_block1_xmit(coap_session_t *session,
|
||||
coap_tick_t now, coap_tick_t *tim_rem);
|
||||
|
||||
coap_mid_t coap_block_test_q_block(coap_session_t *session, coap_pdu_t *actual);
|
||||
#endif /* COAP_Q_BLOCK_SUPPORT */
|
||||
@@ -283,8 +292,17 @@ int coap_block_check_lg_srcv_timeouts(coap_session_t *session,
|
||||
coap_tick_t *tim_rem);
|
||||
|
||||
#if COAP_Q_BLOCK_SUPPORT
|
||||
coap_tick_t coap_block_check_q_block2_xmit(coap_session_t *session,
|
||||
coap_tick_t now);
|
||||
/**
|
||||
* Check if the next Q-Block2 needs to be sent, else get the next timeout value.
|
||||
*
|
||||
* @param session The Session to check.
|
||||
* @param now The current time in ticks.
|
||||
* @param tim_rem Updated with the remaining timeout time if return is @c 1.
|
||||
*
|
||||
* @return @c 1 if @p tim_rem is set, else @c 0 if there is no timeout.
|
||||
*/
|
||||
int coap_block_check_q_block2_xmit(coap_session_t *session,
|
||||
coap_tick_t now, coap_tick_t *tim_rem);
|
||||
|
||||
coap_mid_t coap_send_q_block2(coap_session_t *session,
|
||||
coap_resource_t *resource,
|
||||
|
||||
@@ -217,6 +217,9 @@ coap_time_le(coap_tick_t a, coap_tick_t b) {
|
||||
return a == b || coap_time_lt(a,b);
|
||||
}
|
||||
|
||||
/* Can delay up to 24 hrs before next wakeup (coap_tick_t can be 4 bytes or int64 */
|
||||
#define COAP_MAX_DELAY_TICKS (24 * 60 * 60 * COAP_TICKS_PER_SECOND)
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* COAP_TIME_H_ */
|
||||
Reference in new issue
Block a user