aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-07-31 19:20:56 +0000
committerUlrich Drepper <drepper@redhat.com>2001-07-31 19:20:56 +0000
commit34183f57d75b4e8b9ed6608f888f0f1e1ada8b34 (patch)
tree898543f608d73157cdcd592438cc361e159dc943
parent9f508673699baadac1a74b1f60d945a15c2e8478 (diff)
downloadglibc-34183f57d75b4e8b9ed6608f888f0f1e1ada8b34.zip
glibc-34183f57d75b4e8b9ed6608f888f0f1e1ada8b34.tar.gz
glibc-34183f57d75b4e8b9ed6608f888f0f1e1ada8b34.tar.bz2
Update.
2001-07-31 Ulrich Drepper <drepper@redhat.com> * libio/iopopen.c: Add lock for proc_file_chain access. Reported by Padraig Brady <Padraig@linux.ie>.
-rw-r--r--ChangeLog5
-rw-r--r--libio/iopopen.c28
2 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 47de0e6..695637f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-07-31 Ulrich Drepper <drepper@redhat.com>
+
+ * libio/iopopen.c: Add lock for proc_file_chain access.
+ Reported by Padraig Brady <Padraig@linux.ie>.
+
2001-07-31 Andreas Jaeger <aj@suse.de>
* sysdeps/unix/sysv/linux/sparc/bits/poll.h (NPOLLFILE): Removed.
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 7cdd279..c0c16b2 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993,1997,1998,1999,2000,2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Per Bothner <bothner@cygnus.com>.
@@ -108,6 +108,16 @@ static struct _IO_jump_t _IO_wproc_jumps;
static struct _IO_proc_file *proc_file_chain;
+#ifdef _IO_MTSAFE_IO
+static _IO_lock_t proc_file_chain_lock = _IO_lock_initializer;
+
+static void
+unlock (void *not_used)
+{
+ _IO_lock_unlock (proc_file_chain_lock);
+}
+#endif
+
_IO_FILE *
_IO_new_proc_open (fp, command, mode)
_IO_FILE *fp;
@@ -172,8 +182,16 @@ _IO_new_proc_open (fp, command, mode)
_IO_fileno (fp) = parent_end;
/* Link into proc_file_chain. */
+#ifdef _IO_MTSFE_IO
+ _IO_cleanup_region_start_noarg (unlock);
+ _IO_lock_lock (proc_file_chain_lock);
+#endif
((_IO_proc_file *) fp)->next = proc_file_chain;
proc_file_chain = (_IO_proc_file *) fp;
+#ifdef _IO_MTSFE_IO
+ _IO_lock_unlock (proc_file_chain_lock);
+ _IO_cleanup_region_end (0);
+#endif
_IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
return fp;
@@ -229,6 +247,10 @@ _IO_new_proc_close (fp)
int status = -1;
/* Unlink from proc_file_chain. */
+#ifdef _IO_MTSFE_IO
+ _IO_cleanup_region_start_noarg (unlock);
+ _IO_lock_lock (proc_file_chain_lock);
+#endif
for ( ; *ptr != NULL; ptr = &(*ptr)->next)
{
if (*ptr == (_IO_proc_file *) fp)
@@ -238,6 +260,10 @@ _IO_new_proc_close (fp)
break;
}
}
+#ifdef _IO_MTSFE_IO
+ _IO_lock_unlock (proc_file_chain_lock);
+ _IO_cleanup_region_end (0);
+#endif
if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
return -1;