aboutsummaryrefslogtreecommitdiff
path: root/sunrpc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-11-22 11:43:57 -0800
committerUlrich Drepper <drepper@redhat.com>2009-11-22 11:43:57 -0800
commitc5a8b997e2de005697a992d8db5c54995bd361a8 (patch)
tree6c6b319e6e4da4a26175aec669ffd9104809909d /sunrpc
parenteb4157390cac6212921ef198353635e138dc0a00 (diff)
downloadglibc-c5a8b997e2de005697a992d8db5c54995bd361a8.tar
glibc-c5a8b997e2de005697a992d8db5c54995bd361a8.tar.gz
glibc-c5a8b997e2de005697a992d8db5c54995bd361a8.tar.bz2
glibc-c5a8b997e2de005697a992d8db5c54995bd361a8.zip
Reinitialize _create_xid state after fork.
Programs forking and using RPC in the forks would use the same XIDs.
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/create_xid.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/sunrpc/create_xid.c b/sunrpc/create_xid.c
index 4e76918644..c247568cee 100644
--- a/sunrpc/create_xid.c
+++ b/sunrpc/create_xid.c
@@ -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);