mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-03 16:36:20 +03:00
fixed bug #3526909 (Wrong unit conversion) pointed out by jsucaet
Applied patch provided by jsucaet.
This commit is contained in:
1 parent
28a6d45cde
commit
abf33c87f9
5 files changed
+7
-7
No files matched your search
+1
-1
@@ -77,7 +77,7 @@ coap_ticks_impl(coap_tick_t *t) {
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
*t = (tv.tv_sec - clock_offset) * COAP_TICKS_PER_SECOND
|
||||
+ (tv.tv_usec >> 10) % COAP_TICKS_PER_SECOND;
|
||||
+ (tv.tv_usec * COAP_TICKS_PER_SECOND / 1000000);
|
||||
#else
|
||||
#error "clock not implemented"
|
||||
#endif
|
||||
|
||||
+3
-3
@@ -1095,15 +1095,15 @@ main(int argc, char **argv) {
|
||||
|
||||
if (nextpdu && nextpdu->t < min(obs_wait ? obs_wait : max_wait, max_wait)) {
|
||||
/* set timeout if there is a pdu to send */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) << 10;
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
} else {
|
||||
/* check if obs_wait fires before max_wait */
|
||||
if (obs_wait && obs_wait < max_wait) {
|
||||
tv.tv_usec = ((obs_wait - now) % COAP_TICKS_PER_SECOND) << 10;;
|
||||
tv.tv_usec = ((obs_wait - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (obs_wait - now) / COAP_TICKS_PER_SECOND;
|
||||
} else {
|
||||
tv.tv_usec = ((max_wait - now) % COAP_TICKS_PER_SECOND) << 10;;
|
||||
tv.tv_usec = ((max_wait - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (max_wait - now) / COAP_TICKS_PER_SECOND;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ main(int argc, char **argv) {
|
||||
|
||||
if ( nextpdu && nextpdu->t <= now + COAP_RESOURCE_CHECK_TIME_SEC ) {
|
||||
/* set timeout if there is a pdu to send before our automatic timeout occurs */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) << 10;
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
timeout = &tv;
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -685,7 +685,7 @@ main(int argc, char **argv) {
|
||||
|
||||
if ( nextpdu && nextpdu->t <= now + COAP_RESOURCE_CHECK_TIME ) {
|
||||
/* set timeout if there is a pdu to send before our automatic timeout occurs */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) << 10;
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
timeout = &tv;
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -394,7 +394,7 @@ main(int argc, char **argv) {
|
||||
|
||||
if ( nextpdu && nextpdu->t <= now + COAP_RESOURCE_CHECK_TIME ) {
|
||||
/* set timeout if there is a pdu to send before our automatic timeout occurs */
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) << 10;
|
||||
tv.tv_usec = ((nextpdu->t - now) % COAP_TICKS_PER_SECOND) * 1000000 / COAP_TICKS_PER_SECOND;
|
||||
tv.tv_sec = (nextpdu->t - now) / COAP_TICKS_PER_SECOND;
|
||||
timeout = &tv;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user