fixed bug #3526909 (Wrong unit conversion) pointed out by jsucaet

Applied patch provided by jsucaet.
This commit is contained in:
Olaf Bergmann committed 2012-05-29 19:54:36 +02:00
1 parent 28a6d45cde
commit abf33c87f9
5 files changed
+7 -7

No files matched your search

+1 -1
View File
@@ -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
View File
@@ -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;
}
}
+1 -1
View File
@@ -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
View File
@@ -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
View File
@@ -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 {