Notes |
(0007584)
vda
05-09-08 04:51
|
The code:
/* wait for arp reply, and check it */
timeout_ms = 2000;
do {
int r;
unsigned prevTime = monotonic_us();
...
timeout_ms -= (monotonic_us() - prevTime) / 1000;
} while (timeout_ms > 0);
Can you explain in more details when overflow occurs? |
| |
(0007594)
vda
05-09-08 04:56
|
If this is a real bug, it is likely fixed in 21958. |
| |
(0007614)
Linkn
05-09-08 20:32
edited on: 05-09-08 20:36
|
This is embedded MIPS 4k OS and gcc is mipsel-linux-gcc (GCC) 3.3.6.
The test code :
/* wait for arp reply, and check it */
do {
int r;
//unsigned long long prevTime = monotonic_us();
unsigned prevTime = monotonic_us();
bb_error_msg("arpping -> timeout_ms:%d\n",timeout_ms);
pfd[0].events = POLLIN;
r = safe_poll(pfd, 1, timeout_ms);
if (r < 0) {
break;
} else if (r) {
if (read(s, &arp, sizeof(arp)) < 0)
break;
if (arp.operation == htons(ARPOP_REPLY)
&& memcmp(arp.tHaddr, from_mac, 6) == 0
&& *((uint32_t *) arp.sInaddr) == test_ip
) {
rv = 0;
break;
}
}
timeout_ms -= (monotonic_us() - prevTime) / 1000;
} while (timeout_ms > 0);
Where dhcpd receive discover, debug msg show :
udhcpd: arpping -> timeout_ms:2000
udhcpd: arpping -> timeout_ms:1662154294
At this time,safe_poll will delay long long time .
|
| |
(0007624)
vda
05-10-08 08:49
|
Please test whether it is fixed by adding (unsigned) cast:
timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000; |
| |
(0007634)
Linkn
05-11-08 20:43
edited on: 05-11-08 20:44
|
Yes ,it is fixed by this mode:
1: timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000;
2: unsigned long long prevTime = monotonic_us();
|
| |
(0007644)
vda
05-12-08 07:14
|
> Yes ,it is fixed by this mode:
> 1: timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000;
> 2: unsigned long long prevTime = monotonic_us();
I don't understand. I asked whether _only_ adding (unsigned) is enough.
I'd like to avoid using "long long" as it results in bigger code.
Can you test whether only adding (unsigned) works? |
| |
(0007654)
Linkn
05-12-08 07:55
|
Yes, I tested. only adding unsigned, it works ok. |
| |
(0007664)
vda
05-12-08 17:41
|
Fixed in rev 21958. |
| |