aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-07-15 07:52:52 +0000
committerUlrich Drepper <drepper@redhat.com>2003-07-15 07:52:52 +0000
commit73299943388c0eebf6a9c8d6288e9da8289f9dca (patch)
tree6da8f169d3c1867e38c1eaad12876981845e3cd5
parentda35d15e2b2b51fae6265a0906e87cfd5e4df98f (diff)
downloadglibc-73299943388c0eebf6a9c8d6288e9da8289f9dca.tar.xz
glibc-73299943388c0eebf6a9c8d6288e9da8289f9dca.zip
Update.
More cancellation handling fixups. * sysdeps/unix/sysv/linux/not-cancel.h: Add waitpid_not_cancel. * sysdeps/generic/not-cancel.h: Likewise. * catgets/open_catalog.c: Use not-cancelable syscalls. * time/Makefile (CFLAGS-getdate.c): Add -fexceptions. * sysdeps/unix/sysv/linux/llseek.c: Must not be cancelable. * sysdeps/unix/syscalls.list: Don't mark lseek as cancelable. * dlfcn/dlfcn.h: Mark dlopen with __THROW again. * io/fcntl.h: Don't mark posix_fallocate with __THROW. * libio/fileops.c: Use not-cancelable syscalls for fclose. * libio/iopopen.c: Use no-cancelable syscalls. * libio/stdio.h: Mark popen and pclose with __THROW again. * misc/Makefile (CFLAGS-syslog.c): Add -fexceptions. * misc/syslog.c: Fix locking and cancellation cleanup handling. * posix/unistd.h: Mark ttyname and ttyname_r again with __THROW. * stdio-common/Makefile (CFLAGS-tmpfile.c, CFLAGS-tmpfile64.c, CFLAGS-tempname.c): Add -fexceptions. * stdlib/Makefile (CFLAGS-mkstemp.c): Add -fexceptions. * string/string.h: Mark strerror and strerror_r with _THROW again. * sysdeps/generic/unwind.inc: New file. Copied from gcc. * sysdeps/generic/unwind-dw2.c: Update from gcc version. Remove #ifs since we now need all the code compiled. * sysdeps/posix/spawni.c: Use close_not_cancel instead of close. * sysdeps/unix/closedir.c: Use not-cancelable syscalls. * sysdeps/unix/opendir.c: Likewise.
-rw-r--r--ChangeLog26
-rw-r--r--catgets/open_catalog.c13
-rw-r--r--dlfcn/dlfcn.h7
-rw-r--r--io/fcntl.h12
-rw-r--r--libio/fileops.c9
-rw-r--r--libio/iopopen.c5
-rw-r--r--libio/stdio.h14
-rw-r--r--misc/Makefile1
-rw-r--r--misc/syslog.c101
-rw-r--r--nptl/Banner2
-rw-r--r--nptl/ChangeLog4
-rwxr-xr-xnptl/sysdeps/pthread/configure2
-rw-r--r--posix/unistd.h14
-rw-r--r--stdio-common/Makefile4
-rw-r--r--stdlib/Makefile1
-rw-r--r--string/string.h14
-rw-r--r--sysdeps/generic/not-cancel.h10
-rw-r--r--sysdeps/generic/unwind-dw2.c93
-rw-r--r--sysdeps/generic/unwind.inc309
-rw-r--r--sysdeps/posix/spawni.c5
-rw-r--r--sysdeps/unix/closedir.c7
-rw-r--r--sysdeps/unix/opendir.c12
-rw-r--r--sysdeps/unix/syscalls.list2
-rw-r--r--sysdeps/unix/sysv/linux/kernel-features.h2
-rw-r--r--sysdeps/unix/sysv/linux/llseek.c21
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h31
-rw-r--r--time/Makefile1
27 files changed, 543 insertions, 179 deletions
diff --git a/ChangeLog b/ChangeLog
index 80b617c381..bdbbf4b114 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
2003-07-14 Ulrich Drepper <drepper@redhat.com>
+ More cancellation handling fixups.
+ * sysdeps/unix/sysv/linux/not-cancel.h: Add waitpid_not_cancel.
+ * sysdeps/generic/not-cancel.h: Likewise.
+ * catgets/open_catalog.c: Use not-cancelable syscalls.
+ * time/Makefile (CFLAGS-getdate.c): Add -fexceptions.
+ * sysdeps/unix/sysv/linux/llseek.c: Must not be cancelable.
+ * sysdeps/unix/syscalls.list: Don't mark lseek as cancelable.
+ * dlfcn/dlfcn.h: Mark dlopen with __THROW again.
+ * io/fcntl.h: Don't mark posix_fallocate with __THROW.
+ * libio/fileops.c: Use not-cancelable syscalls for fclose.
+ * libio/iopopen.c: Use no-cancelable syscalls.
+ * libio/stdio.h: Mark popen and pclose with __THROW again.
+ * misc/Makefile (CFLAGS-syslog.c): Add -fexceptions.
+ * misc/syslog.c: Fix locking and cancellation cleanup handling.
+ * posix/unistd.h: Mark ttyname and ttyname_r again with __THROW.
+ * stdio-common/Makefile (CFLAGS-tmpfile.c, CFLAGS-tmpfile64.c,
+ CFLAGS-tempname.c): Add -fexceptions.
+ * stdlib/Makefile (CFLAGS-mkstemp.c): Add -fexceptions.
+ * string/string.h: Mark strerror and strerror_r with _THROW again.
+ * sysdeps/generic/unwind.inc: New file. Copied from gcc.
+ * sysdeps/generic/unwind-dw2.c: Update from gcc version. Remove
+ #ifs since we now need all the code compiled.
+ * sysdeps/posix/spawni.c: Use close_not_cancel instead of close.
+ * sysdeps/unix/closedir.c: Use not-cancelable syscalls.
+ * sysdeps/unix/opendir.c: Likewise.
+
* iconvdata/Makefile (modules): Add CP932 and EUC-JP-MS.
Add rule for EUC-JP-MS dependency.
* iconvdata/cp932.c: New file.
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 674a0c1bf0..8c563b2e26 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.org>.
@@ -30,6 +30,7 @@
#include <sys/stat.h>
#include "catgetsinfo.h"
+#include <not-cancel.h>
#define SWAPU32(w) bswap_32 (w)
@@ -49,7 +50,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
int result = -1;
if (strchr (cat_name, '/') != NULL || nlspath == NULL)
- fd = __open (cat_name, O_RDONLY);
+ fd = open_not_cancel_2 (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -177,7 +178,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = __open (buf, O_RDONLY);
+ fd = open_not_cancel_2 (buf, O_RDONLY);
if (fd >= 0)
break;
}
@@ -233,8 +234,8 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Save read, handle partial reads. */
do
{
- size_t now = __read (fd, (((char *) catalog->file_ptr)
- + (st.st_size - todo)), todo);
+ size_t now = read_not_cancel (fd, (((char *) catalog->file_ptr)
+ + (st.st_size - todo)), todo);
if (now == 0 || now == (size_t) -1)
{
#ifdef EINTR
@@ -324,7 +325,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Release the lock again. */
close_unlock_return:
- __close (fd);
+ close_not_cancel_no_status (fd);
return result;
}
diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h
index ad51bb9233..9d8ee0d6d1 100644
--- a/dlfcn/dlfcn.h
+++ b/dlfcn/dlfcn.h
@@ -45,11 +45,8 @@
__BEGIN_DECLS
/* Open the shared object FILE and map it in; return a handle that can be
- passed to `dlsym' to get symbol values from it.
-
- This function is a possible cancellation point and therefore not
- marked with __THROW. */
-extern void *dlopen (__const char *__file, int __mode);
+ passed to `dlsym' to get symbol values from it. */
+extern void *dlopen (__const char *__file, int __mode) __THROW;
/* Unmap and close a shared object opened by `dlopen'.
The handle cannot be used again after calling `dlclose'. */
diff --git a/io/fcntl.h b/io/fcntl.h
index 8131c24d88..5dbde77bf4 100644
--- a/io/fcntl.h
+++ b/io/fcntl.h
@@ -151,21 +151,23 @@ extern int posix_fadvise64 (int __fd, __off64_t __offset, size_t __len,
# endif
-/* Reserve storage for the data of the file associated with FD. */
+/* Reserve storage for the data of the file associated with FD.
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
# ifndef __USE_FILE_OFFSET64
-extern int posix_fallocate (int __fd, __off_t __offset, size_t __len) __THROW;
+extern int posix_fallocate (int __fd, __off_t __offset, size_t __len);
# else
# ifdef __REDIRECT
extern int __REDIRECT (posix_fallocate, (int __fd, __off64_t __offset,
- size_t __len) __THROW,
+ size_t __len),
posix_fallocate64);
# else
# define posix_fallocate posix_fallocate64
# endif
# endif
# ifdef __USE_LARGEFILE64
-extern int posix_fallocate64 (int __fd, __off64_t __offset, size_t __len)
- __THROW;
+extern int posix_fallocate64 (int __fd, __off64_t __offset, size_t __len);
# endif
#endif
diff --git a/libio/fileops.c b/libio/fileops.c
index aae02f001c..0faf01f09f 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -47,6 +47,7 @@
# include "../iconv/gconv_charset.h"
# include "../iconv/gconv_int.h"
# include <shlib-compat.h>
+# include <not-cancel.h>
#endif
#ifndef errno
extern int errno;
@@ -1240,14 +1241,18 @@ _IO_file_close_mmap (fp)
/* In addition to closing the file descriptor we have to unmap the file. */
(void) __munmap (fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base);
fp->_IO_buf_base = fp->_IO_buf_end = NULL;
- return close (fp->_fileno);
+ /* Cancelling close should be avoided if possible since it leaves an
+ unrecoverable state behind. */
+ return close_not_cancel (fp->_fileno);
}
int
_IO_file_close (fp)
_IO_FILE *fp;
{
- return close (fp->_fileno);
+ /* Cancelling close should be avoided if possible since it leaves an
+ unrecoverable state behind. */
+ return close_not_cancel (fp->_fileno);
}
INTDEF(_IO_file_close)
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 80a97f1b64..63094389d7 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -39,6 +39,7 @@
#ifdef _LIBC
# include <unistd.h>
# include <shlib-compat.h>
+# include <not-cancel.h>
#endif
#include <sys/types.h>
#include <sys/wait.h>
@@ -74,7 +75,7 @@ extern int _IO_dup2 __P ((int fd, int fd2));
#ifndef _IO_waitpid
#ifdef _LIBC
-#define _IO_waitpid __waitpid
+#define _IO_waitpid waitpid_not_cancel
#else
#define _IO_waitpid waitpid
#endif
@@ -89,7 +90,7 @@ extern int _IO_dup2 __P ((int fd, int fd2));
#ifndef _IO_close
#ifdef _LIBC
-#define _IO_close __close
+#define _IO_close close_not_cancel
#else
#define _IO_close close
#endif
diff --git a/libio/stdio.h b/libio/stdio.h
index f98d38ff32..88ef61b029 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -757,17 +757,11 @@ extern int fileno_unlocked (FILE *__stream) __THROW;
#if (defined __USE_POSIX2 || defined __USE_SVID || defined __USE_BSD || \
defined __USE_MISC)
-/* Create a new stream connected to a pipe running the given command.
+/* Create a new stream connected to a pipe running the given command. */
+extern FILE *popen (__const char *__command, __const char *__modes) __THROW;
- This function is a possible cancellation point and therefore not
- marked with __THROW. */
-extern FILE *popen (__const char *__command, __const char *__modes);
-
-/* Close a stream opened by popen and return the status of its child.
-
- This function is a possible cancellation point and therefore not
- marked with __THROW. */
-extern int pclose (FILE *__stream);
+/* Close a stream opened by popen and return the status of its child. */
+extern int pclose (FILE *__stream) __THROW;
#endif
diff --git a/misc/Makefile b/misc/Makefile
index 2685e908ee..e8828109a7 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -81,6 +81,7 @@ CFLAGS-pselect.c = -fexceptions
CFLAGS-readv.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-writev.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-usleep.c = -fexceptions
+CFLAGS-syslog.c = -fexceptions
include ../Rules
diff --git a/misc/syslog.c b/misc/syslog.c
index c1fdf5b6b9..d84cbbf47f 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)syslog.c 8.4 (Berkeley) 3/18/94";
#include <fcntl.h>
#include <paths.h>
#include <stdio.h>
+#include <stdio_ext.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
@@ -74,9 +75,27 @@ __libc_lock_define_initialized (static, syslog_lock)
static void openlog_internal(const char *, int, int) internal_function;
static void closelog_internal(void);
static void sigpipe_handler (int);
-#ifdef _LIBC_REENTRANT
-static void cancel_handler (void *);
-#endif
+
+
+struct cleanup_arg
+{
+ void *buf;
+ struct sigaction *oldaction;
+};
+
+static void
+cancel_handler (void *ptr)
+{
+ /* Restore the old signal handler. */
+ struct cleanup_arg *clarg = (struct cleanup_arg *) ptr;
+
+ if (clarg != NULL && clarg->oldaction != NULL)
+ __sigaction (SIGPIPE, clarg->oldaction, NULL);
+
+ /* Free the lock. */
+ __libc_lock_unlock (syslog_lock);
+}
+
/*
* syslog, vsyslog --
@@ -118,7 +137,6 @@ vsyslog(pri, fmt, ap)
size_t bufsize = 0;
size_t prioff, msgoff;
struct sigaction action, oldaction;
- struct sigaction *oldaction_ptr = NULL;
int sigpipe;
int saved_errno = errno;
char failbuf[3 * sizeof (pid_t) + sizeof "out of memory []"];
@@ -165,6 +183,7 @@ vsyslog(pri, fmt, ap)
}
else
{
+ __fsetlocking (f, FSETLOCKING_BYCALLER);
prioff = fprintf (f, "<%d>", pri);
(void) time (&now);
#ifdef USE_IN_LIBIO
@@ -182,9 +201,12 @@ vsyslog(pri, fmt, ap)
if (LogTag != NULL)
fputs_unlocked (LogTag, f);
if (LogStat & LOG_PID)
- fprintf (f, "[%d]", __getpid ());
+ fprintf (f, "[%d]", (int) __getpid ());
if (LogTag != NULL)
- putc_unlocked (':', f), putc_unlocked (' ', f);
+ {
+ putc_unlocked (':', f);
+ putc_unlocked (' ', f);
+ }
/* Restore errno for %m format. */
__set_errno (saved_errno);
@@ -212,16 +234,22 @@ vsyslog(pri, fmt, ap)
v->iov_base = (char *) "\n";
v->iov_len = 1;
}
+
+ __libc_cleanup_push (free, buf);
+
+ /* writev is a cancellation point. */
(void)__writev(STDERR_FILENO, iov, v - iov + 1);
+
+ __libc_cleanup_pop (0);
}
-#ifdef _LIBC_REENTRANT
/* Prepare for multiple users. We have to take care: open and
write are cancellation points. */
- __libc_cleanup_region_start (1, (void (*) (void *)) cancel_handler,
- &oldaction_ptr);
+ struct cleanup_arg clarg;
+ clarg.buf = buf;
+ clarg.oldaction = NULL;
+ __libc_cleanup_push (cancel_handler, &clarg);
__libc_lock_lock (syslog_lock);
-#endif
/* Prepare for a broken connection. */
memset (&action, 0, sizeof (action));
@@ -229,7 +257,7 @@ vsyslog(pri, fmt, ap)
sigemptyset (&action.sa_mask);
sigpipe = __sigaction (SIGPIPE, &action, &oldaction);
if (sigpipe == 0)
- oldaction_ptr = &oldaction;
+ clarg.oldaction = &oldaction;
/* Get connected, output the message to the local logger. */
if (!connected)
@@ -271,11 +299,9 @@ vsyslog(pri, fmt, ap)
if (sigpipe == 0)
__sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
-#ifdef _LIBC_REENTRANT
/* End of critical section. */
- __libc_cleanup_region_end (0);
+ __libc_cleanup_pop (0);
__libc_lock_unlock (syslog_lock);
-#endif
free (buf);
}
@@ -283,6 +309,7 @@ libc_hidden_def (vsyslog)
static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
+
static void
internal_function
openlog_internal(const char *ident, int logstat, int logfac)
@@ -312,8 +339,9 @@ openlog_internal(const char *ident, int logstat, int logfac)
== -1)
{
int saved_errno = errno;
- (void)__close(LogFile);
+ int fd = LogFile;
LogFile = -1;
+ (void)__close(fd);
if (LogType == SOCK_DGRAM
&& saved_errno == EPROTOTYPE)
{
@@ -329,28 +357,16 @@ openlog_internal(const char *ident, int logstat, int logfac)
}
}
-
-static void
-log_cleanup (void *arg)
-{
- __libc_lock_unlock (syslog_lock);
-}
-
void
openlog (const char *ident, int logstat, int logfac)
{
-#ifdef _LIBC_REENTRANT
- /* Protect against multiple users. */
- __libc_cleanup_region_start (1, log_cleanup, NULL);
+ /* Protect against multiple users and cancellation. */
+ __libc_cleanup_push (cancel_handler, NULL);
__libc_lock_lock (syslog_lock);
-#endif
openlog_internal (ident, logstat, logfac);
-#ifdef _LIBC_REENTRANT
- /* Free the lock. */
- __libc_cleanup_region_end (1);
-#endif
+ __libc_cleanup_pop (1);
}
static void
@@ -373,36 +389,17 @@ closelog_internal()
void
closelog ()
{
-#ifdef _LIBC_REENTRANT
- /* Protect against multiple users. */
- __libc_cleanup_region_start (1, log_cleanup, NULL);
+ /* Protect against multiple users and cancellation. */
+ __libc_cleanup_push (cancel_handler, NULL);
__libc_lock_lock (syslog_lock);
-#endif
closelog_internal ();
LogTag = NULL;
LogType = SOCK_DGRAM; /* this is the default */
-#ifdef _LIBC_REENTRANT
- /* Free the lock. */
- __libc_cleanup_region_end (1);
-#endif
-}
-
-#ifdef _LIBC_REENTRANT
-static void
-cancel_handler (void *ptr)
-{
- /* Restore the old signal handler. */
- struct sigaction *oldaction = *((struct sigaction **) ptr);
-
- if (oldaction != (struct sigaction *) NULL)
- __sigaction (SIGPIPE, oldaction, (struct sigaction *) NULL);
-
/* Free the lock. */
- __libc_lock_unlock (syslog_lock);
+ __libc_cleanup_pop (1);
}
-#endif
/* setlogmask -- set the log mask level */
int
diff --git a/nptl/Banner b/nptl/Banner
index 80e09ac5a5..fe38739940 100644
--- a/nptl/Banner
+++ b/nptl/Banner
@@ -1 +1 @@
-NPTL 0.52 by Ulrich Drepper
+NPTL 0.53 by Ulrich Drepper
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 7594e5fdf3..804968a8c5 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,7 @@
+2003-07-15 Ulrich Drepper <drepper@redhat.com>
+
+ * tst-tcancel-wrappers.sh: lseek and llseek are not cancelation points.
+
2003-07-14 Ulrich Drepper <drepper@redhat.com>
* sysdeps/pthread/configure.in: Require CFI directives also for
diff --git a/nptl/sysdeps/pthread/configure b/nptl/sysdeps/pthread/configure
index 00a58843cc..d10b23dee8 100755
--- a/nptl/sysdeps/pthread/configure
+++ b/nptl/sysdeps/pthread/configure
@@ -6,7 +6,7 @@ echo "$as_me: error: compiler support for __thread is required" >&2;}
{ (exit 1); exit 1; }; }
fi
-if test "sx$libc_cv_asm_cfi_directives" != xyes; then
+if test "x$libc_cv_asm_cfi_directives" != xyes; then
case "$base_machine" in
i386 | x86_64 | powerpc | s390)
{ { echo "$as_me:$LINENO: error: CFI directive support in assembler is required" >&5
diff --git a/posix/unistd.h b/posix/unistd.h
index