On Fri, Aug 16, 2013 at 05:25:34PM +0100, Daniel P. Berrange wrote: > On Fri, Aug 16, 2013 at 06:01:25PM +0200, Stéphane Graber wrote: > > On Fri, Aug 16, 2013 at 10:36:58AM -0500, Serge Hallyn wrote: > > > Quoting Stéphane Graber (stgra...@ubuntu.com): > > > > initstate/random doesn't work on bionic, srand/rand works on everything, > > > > so let's use that. > > > > > > Is rand_r available on bionic? > > > > > > rand() isn't thread-safe. > > > > Unfortunately no, I actually don't think Bionic has any of the _r > > functions. > > > > Is it actually a problem in this case? It looks like the worst that > > could happen is that the random number generator gets re-seeded from > > urandom between two calls, which would just make it even more random, > > no? > > I don't think that's a safe assumption. You could have an rand() > call overlap with a srand() call, causing rand() to access invalid > state which may cause it to return a non-random number. > > Daniel
Hmm, fair enough. I'll add an extra configure.ac check for rand_r, so that we use that if available and only do the srand() + rand() when it's not. I guess if we ever really care about threading on Android we'll have to essentially re-implement our own rand_r function with the required looking to avoid the race, but at this point it's not really that important (none of the bindings work on Android, so only the command line tools may be used and none of them start containers in parallel). -- Stéphane Graber Ubuntu developer http://www.ubuntu.com
signature.asc
Description: Digital signature
------------------------------------------------------------------------------ Get 100% visibility into Java/.NET code with AppDynamics Lite! It's a free troubleshooting tool designed for production. Get down to code-level detail for bottlenecks, with <2% overhead. Download for free and get started troubleshooting in minutes. http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel