<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 24, 2013 at 10:03 PM, Ben Pfaff <span dir="ltr"><<a href="mailto:blp@nicira.com" target="_blank">blp@nicira.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Mon, Jun 24, 2013 at 03:50:45PM -0700, Ansis Atteka wrote:<br>
> On Wed, Jun 19, 2013 at 1:17 PM, Ben Pfaff <<a href="mailto:blp@nicira.com">blp@nicira.com</a>> wrote:<br>
><br>
> > Signed-off-by: Ben Pfaff <<a href="mailto:blp@nicira.com">blp@nicira.com</a>><br>
> > ---<br>
> > lib/random.c | 26 +++++++++++++++++---------<br>
> > 1 files changed, 17 insertions(+), 9 deletions(-)<br>
> ><br>
> > diff --git a/lib/random.c b/lib/random.c<br>
> > index 45d428c..2572c1e 100644<br>
> > --- a/lib/random.c<br>
> > +++ b/lib/random.c<br>
> > @@ -1,5 +1,5 @@<br>
> > /*<br>
> > - * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.<br>
> > + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.<br>
> > *<br>
> > * Licensed under the Apache License, Version 2.0 (the "License");<br>
> > * you may not use this file except in compliance with the License.<br>
> > @@ -22,6 +22,8 @@<br>
> > #include <sys/time.h><br>
> ><br>
> > #include "entropy.h"<br>
> > +#include "hash.h"<br>
> > +#include "ovs-thread.h"<br>
> > #include "timeval.h"<br>
> > #include "util.h"<br>
> ><br>
> > @@ -37,21 +39,25 @@<br>
> > * cryptographic-quality randomness. */<br>
> ><br>
> > /* Current random state. */<br>
> > -static uint32_t seed;<br>
> > +DEFINE_PER_THREAD_DATA(uint32_t, seed, 0);<br>
> ><br>
> > static uint32_t random_next(void);<br>
> ><br>
> > void<br>
> > random_init(void)<br>
> > {<br>
> > - while (!seed) {<br>
> ><br>
> + uint32_t *seedp = seed_get();<br>
><br>
> + while (!*seedp) {<br>
> > struct timeval tv;<br>
> > uint32_t entropy;<br>
> > + pthread_t self;<br>
> ><br>
> > xgettimeofday(&tv);<br>
> > get_entropy_or_die(&entropy, 4);<br>
> ><br>
> get_entropy() is not thread safe and that makes this function thread unsafe<br>
> as well: get_entropy()->ovs_retval_to_string() uses "static char<br>
> unknown[48]".<br>
<br>
</div></div>The patch titled "Replace all uses of strerror() by ovs_strerror(), for<br>
thread safety." should make ovs_retval_to_string() thread-safe, so I<br>
believe that that is fixed earlier in the series.<br>
<br></blockquote><div>I think you are right, sorry!<br><br></div><div>Looks good to me.<br></div></div></div></div>