Reverted the recent change from random_rand() to rand(). It turned out that
since libc rand() returns a signed int, there were frequently problems with timer values wrapping. By reverting to random_rand(), we can provide a random generator that returns an unsigned and the timer problems are solved.
This commit is contained in:
parent
b80d3cfdb9
commit
585620c102
10 changed files with 28 additions and 29 deletions
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: shell-rime.c,v 1.11 2009/02/09 20:54:49 adamdunkels Exp $
|
||||
* $Id: shell-rime.c,v 1.12 2009/02/11 11:08:53 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@
|
|||
#include "dev/leds.h"
|
||||
|
||||
#include "lib/crc16.h"
|
||||
#include "lib/rand.h"
|
||||
#include "lib/random.h"
|
||||
|
||||
#include "net/rime.h"
|
||||
#include "net/rime/neighbor.h"
|
||||
|
@ -461,7 +461,7 @@ recv_netflood(struct netflood_conn *c, rimeaddr_t *from,
|
|||
|
||||
msg = rimebuf_dataptr();
|
||||
if(msg->type == NETFLOOD_TYPE_NODES) {
|
||||
ctimer_set(&ctimer, rand() % (CLOCK_SECOND * 8),
|
||||
ctimer_set(&ctimer, random_rand() % (CLOCK_SECOND * 8),
|
||||
send_collect, NULL);
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue