]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sunrpc/create_xid.c
support: Correct confusing comment
[thirdparty/glibc.git] / sunrpc / create_xid.c
index 21b83a7656655ecf1b7bb9fc0c846c286f181b04..a44187f07c2b83a0dce90a352cb6fe1e7d2206c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 2000 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
 
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <unistd.h>
 #include <stdlib.h>
 #include <sys/time.h>
-#include <bits/libc-lock.h>
+#include <libc-lock.h>
 #include <rpc/rpc.h>
 
 /* The RPC code is not threadsafe, but new code should be threadsafe. */
 
 __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
 _create_xid (void)
 {
-  unsigned long res;
+  long int res;
 
   __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);