[Olsr-dev] olsr strange behaving / nearly no outgoing packets [partly solved]
Lars Kruse
(spam-protected)
Mon Aug 13 17:17:03 CEST 2012
Hi,
> > Besides this approach I don't see any other options for further
> > investigations. Or what would you say?
>
> Maybe we could just add a new variable and calculate the return value in
> two steps. Most compilers should optimize the variable away anyways.
>
> uint32_t ms;
>
> ....
>
> t = (tv.tv_sec - first_tv.tv_sec) * 1000;
> ms = (tv.tv_usec - first_tv.tv_usec) / 1000;
>
> return t + ms;
> }
>
> Does this help ?
Almost - but thanks for the hint!
The following patch fixes it:
--- olsrd-0.6.2.orig/src/scheduler.c 2012-08-13 14:59:43.000000000 +0200
+++ olsrd-0.6.2/src/scheduler.c 2012-08-13 15:00:46.000000000 +0200
@@ -87,7 +87,7 @@ static uint32_t
olsr_times(void)
{
struct timeval tv;
- uint32_t t;
+ volatile uint32_t t, ms;
if (gettimeofday(&tv, NULL) != 0) {
olsr_exit("OS clock is not working, have to shut down OLSR", 1);
@@ -114,7 +114,9 @@ olsr_times(void)
return t;
}
last_tv = tv;
- return (tv.tv_sec - first_tv.tv_sec) * 1000 + (tv.tv_usec -
first_tv.tv_usec) / 1000;
+ t = (tv.tv_sec - first_tv.tv_sec) * 1000;
+ ms = (tv.tv_usec - first_tv.tv_usec) / 1000;
+ return t + ms;
}
/**
It seems that the "volatile" keyword prevents the compiler from doing evil
things. This is ugly! :(
cheers,
Lars
More information about the Olsr-dev
mailing list