]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Reinitialize _create_xid state after fork.
authorUlrich Drepper <drepper@redhat.com>
Sun, 22 Nov 2009 19:43:57 +0000 (11:43 -0800)
committerPetr Baudis <pasky@ucw.cz>
Fri, 4 Dec 2009 13:45:00 +0000 (14:45 +0100)
Programs forking and using RPC in the forks would use the same XIDs.

(cherry picked from commit c5a8b997e2de005697a992d8db5c54995bd361a8)

ChangeLog
sunrpc/create_xid.c

index e0fd11c15e3ab852a369e99594cce069b1d6e811..143c45af3921691d9d9bad5a05ae7417ab4f9267 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-11-22  Ulrich Drepper  <drepper@redhat.com>
+
+       * sunrpc/create_xid.c (_create_xid): Reinitialize state after fork.
+
 2009-11-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        [BZ #10162]
index 4e769186442cf6d778d1890b76b75df692323c37..c247568cee8df91f29d865eadf80b91f485dd35e 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 2000, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
 
@@ -27,7 +27,7 @@
 
 __libc_lock_define_initialized (static, createxid_lock)
 
-static int is_initialized;
+static pid_t is_initialized;
 static struct drand48_data __rpc_lrand48_data;
 
 unsigned long
@@ -37,13 +37,15 @@ _create_xid (void)
 
   __libc_lock_lock (createxid_lock);
 
-  if (!is_initialized)
+  pid_t pid = getpid ();
+  if (is_initialized != pid)
     {
       struct timeval now;
 
       __gettimeofday (&now, (struct timezone *) 0);
-      __srand48_r (now.tv_sec ^ now.tv_usec, &__rpc_lrand48_data);
-      is_initialized = 1;
+      __srand48_r (now.tv_sec ^ now.tv_usec ^ pid,
+                  &__rpc_lrand48_data);
+      is_initialized = pid;
     }
 
   lrand48_r (&__rpc_lrand48_data, &res);