summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Leonard <d@cvs.openbsd.org>1999-06-09 07:16:18 +0000
committerDavid Leonard <d@cvs.openbsd.org>1999-06-09 07:16:18 +0000
commit5b25504c910ae952393636884728bb911ccd8733 (patch)
tree883d88f07de3449ef2ca038b75c007b57ce95e3d /lib
parent26ab430a80ba9c64b06a358f6b69d491a912f54a (diff)
document cancellation point handling a bit better
Diffstat (limited to 'lib')
-rw-r--r--lib/libc_r/uthread/uthread_close.c7
-rw-r--r--lib/libc_r/uthread/uthread_fcntl.c5
-rw-r--r--lib/libc_r/uthread/uthread_fsync.c7
-rw-r--r--lib/libc_r/uthread/uthread_join.c4
-rw-r--r--lib/libc_r/uthread/uthread_msync.c8
-rw-r--r--lib/libc_r/uthread/uthread_nanosleep.c7
-rw-r--r--lib/libc_r/uthread/uthread_open.c4
-rw-r--r--lib/libc_r/uthread/uthread_read.c6
-rw-r--r--lib/libc_r/uthread/uthread_sigwait.c6
-rw-r--r--lib/libc_r/uthread/uthread_wait4.c7
-rw-r--r--lib/libc_r/uthread/uthread_write.c8
-rw-r--r--lib/libpthread/uthread/uthread_close.c7
-rw-r--r--lib/libpthread/uthread/uthread_fcntl.c5
-rw-r--r--lib/libpthread/uthread/uthread_fsync.c7
-rw-r--r--lib/libpthread/uthread/uthread_join.c4
-rw-r--r--lib/libpthread/uthread/uthread_msync.c8
-rw-r--r--lib/libpthread/uthread/uthread_nanosleep.c7
-rw-r--r--lib/libpthread/uthread/uthread_open.c4
-rw-r--r--lib/libpthread/uthread/uthread_read.c6
-rw-r--r--lib/libpthread/uthread/uthread_sigwait.c6
-rw-r--r--lib/libpthread/uthread/uthread_wait4.c7
-rw-r--r--lib/libpthread/uthread/uthread_write.c8
22 files changed, 114 insertions, 24 deletions
diff --git a/lib/libc_r/uthread/uthread_close.c b/lib/libc_r/uthread/uthread_close.c
index bc94d162b2a..6cfde5ca48e 100644
--- a/lib/libc_r/uthread/uthread_close.c
+++ b/lib/libc_r/uthread/uthread_close.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_close.c,v 1.4 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_close.c,v 1.5 1999/06/09 07:16:16 d Exp $
*/
#include <stdlib.h>
#include <unistd.h>
@@ -46,7 +46,9 @@ close(int fd)
int ret;
struct stat sb;
+ /* This is a cancelation point: */
_thread_enter_cancellation_point();
+
/* Lock the file descriptor while the file is closed: */
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
/* Get file descriptor status. */
@@ -85,7 +87,10 @@ close(int fd)
free(_thread_fd_table[fd]);
_thread_fd_table[fd] = NULL;
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libc_r/uthread/uthread_fcntl.c b/lib/libc_r/uthread/uthread_fcntl.c
index 1a0a3e9548a..c1348a7b27e 100644
--- a/lib/libc_r/uthread/uthread_fcntl.c
+++ b/lib/libc_r/uthread/uthread_fcntl.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_fcntl.c,v 1.4 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_fcntl.c,v 1.5 1999/06/09 07:16:16 d Exp $
*/
#include <stdarg.h>
#include <unistd.h>
@@ -47,6 +47,7 @@ fcntl(int fd, int cmd,...)
int ret;
va_list ap;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* Lock the file descriptor: */
@@ -137,6 +138,8 @@ fcntl(int fd, int cmd,...)
/* Unlock the file descriptor: */
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libc_r/uthread/uthread_fsync.c b/lib/libc_r/uthread/uthread_fsync.c
index 9db34f5564c..2136d62afe7 100644
--- a/lib/libc_r/uthread/uthread_fsync.c
+++ b/lib/libc_r/uthread/uthread_fsync.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_fsync.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_fsync.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <unistd.h>
#ifdef _THREAD_SAFE
@@ -41,12 +41,17 @@ fsync(int fd)
{
int ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
ret = _thread_sys_fsync(fd);
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libc_r/uthread/uthread_join.c b/lib/libc_r/uthread/uthread_join.c
index ab7b7860ecc..42ef1f778bc 100644
--- a/lib/libc_r/uthread/uthread_join.c
+++ b/lib/libc_r/uthread/uthread_join.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_join.c,v 1.4 1999/05/26 00:18:24 d Exp $
+ * $OpenBSD: uthread_join.c,v 1.5 1999/06/09 07:16:17 d Exp $
*/
#include <errno.h>
#ifdef _THREAD_SAFE
@@ -100,7 +100,7 @@ pthread_join(pthread_t pthread, void **thread_return)
/* Return the thread's return value: */
*thread_return = pthread->ret;
- /* This operation was a cancel point: */
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libc_r/uthread/uthread_msync.c b/lib/libc_r/uthread/uthread_msync.c
index 246cdde7226..fb7d5a7e86e 100644
--- a/lib/libc_r/uthread/uthread_msync.c
+++ b/lib/libc_r/uthread/uthread_msync.c
@@ -1,7 +1,7 @@
/*
* David Leonard <d@openbsd.org>, 1999. Public Domain.
*
- * $OpenBSD: uthread_msync.c,v 1.1 1999/01/17 23:43:18 d Exp $
+ * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
*/
#include <sys/types.h>
@@ -24,9 +24,15 @@ msync(addr, len, flags)
* write. The only real use of this wrapper is to guarantee
* a cancellation point, as per the standard. sigh.
*/
+
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
ret = _thread_sys_msync(addr, len, flags);
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libc_r/uthread/uthread_nanosleep.c b/lib/libc_r/uthread/uthread_nanosleep.c
index 0f5c4c9c2ab..4e182adfb6c 100644
--- a/lib/libc_r/uthread/uthread_nanosleep.c
+++ b/lib/libc_r/uthread/uthread_nanosleep.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_nanosleep.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_nanosleep.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <stdio.h>
#include <errno.h>
@@ -48,7 +48,9 @@ nanosleep(const struct timespec * time_to_sleep,
struct timespec remaining_time;
struct timeval tv;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/* Check if the time to sleep is legal: */
if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000 || time_to_sleep->tv_sec < 0) {
/* Return an EINVAL error : */
@@ -96,7 +98,10 @@ nanosleep(const struct timespec * time_to_sleep,
ret = -1;
}
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libc_r/uthread/uthread_open.c b/lib/libc_r/uthread/uthread_open.c
index 9c03daa4f47..bfdcea73091 100644
--- a/lib/libc_r/uthread/uthread_open.c
+++ b/lib/libc_r/uthread/uthread_open.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_open.c,v 1.4 1998/04/29 09:59:07 jb Exp $
- * $OpenBSD: uthread_open.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_open.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <stdarg.h>
@@ -49,6 +49,7 @@ open(const char *path, int flags,...)
int mode = 0;
va_list ap;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* Check if the file is being created: */
@@ -70,6 +71,7 @@ open(const char *path, int flags,...)
fd = -1;
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the file descriptor or -1 on error: */
diff --git a/lib/libc_r/uthread/uthread_read.c b/lib/libc_r/uthread/uthread_read.c
index 22d1d03f091..6b9c96352d0 100644
--- a/lib/libc_r/uthread/uthread_read.c
+++ b/lib/libc_r/uthread/uthread_read.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_read.c,v 1.6 1998/06/10 22:28:43 jb Exp $
- * $OpenBSD: uthread_read.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_read.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <sys/types.h>
@@ -48,10 +48,12 @@ read(int fd, void *buf, size_t nbytes)
int ret;
int type;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* POSIX says to do just this: */
if (nbytes == 0) {
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -66,6 +68,7 @@ read(int fd, void *buf, size_t nbytes)
/* File is not open for read: */
errno = EBADF;
_FD_UNLOCK(fd, FD_READ);
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (-1);
}
@@ -98,6 +101,7 @@ read(int fd, void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_READ);
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (ret);
}
diff --git a/lib/libc_r/uthread/uthread_sigwait.c b/lib/libc_r/uthread/uthread_sigwait.c
index b4277133310..00cf99ef20b 100644
--- a/lib/libc_r/uthread/uthread_sigwait.c
+++ b/lib/libc_r/uthread/uthread_sigwait.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_sigwait.c,v 1.5 1999/05/26 00:18:26 d Exp $
+ * $OpenBSD: uthread_sigwait.c,v 1.6 1999/06/09 07:16:17 d Exp $
*/
#include <signal.h>
#include <errno.h>
@@ -45,7 +45,9 @@ sigwait(const sigset_t * set, int *sig)
sigset_t tempset;
struct sigaction act;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/*
* Specify the thread kernel signal handler.
*/
@@ -76,6 +78,7 @@ sigwait(const sigset_t * set, int *sig)
/* Return the signal number to the caller: */
*sig = i;
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -129,6 +132,7 @@ sigwait(const sigset_t * set, int *sig)
}
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libc_r/uthread/uthread_wait4.c b/lib/libc_r/uthread/uthread_wait4.c
index a4f44e1d405..aef609468d4 100644
--- a/lib/libc_r/uthread/uthread_wait4.c
+++ b/lib/libc_r/uthread/uthread_wait4.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_wait4.c,v 1.3 1999/01/17 23:57:28 d Exp $
+ * $OpenBSD: uthread_wait4.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <errno.h>
#include <sys/wait.h>
@@ -42,7 +42,9 @@ wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
{
pid_t ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/* Perform a non-blocking wait4 syscall: */
while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) {
/* Reset the interrupted operation flag: */
@@ -58,7 +60,10 @@ wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
break;
}
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libc_r/uthread/uthread_write.c b/lib/libc_r/uthread/uthread_write.c
index b7c974ee289..7d91092f9ae 100644
--- a/lib/libc_r/uthread/uthread_write.c
+++ b/lib/libc_r/uthread/uthread_write.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_write.c,v 1.10 1998/09/07 21:55:01 alex Exp $
- * $OpenBSD: uthread_write.c,v 1.3 1999/01/17 23:57:28 d Exp $
+ * $OpenBSD: uthread_write.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <sys/types.h>
@@ -51,10 +51,12 @@ write(int fd, const void *buf, size_t nbytes)
ssize_t num = 0;
ssize_t ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* POSIX says to do just this: */
if (nbytes == 0) {
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -69,6 +71,7 @@ write(int fd, const void *buf, size_t nbytes)
/* File is not open for write: */
errno = EBADF;
_FD_UNLOCK(fd, FD_WRITE);
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (-1);
}
@@ -135,7 +138,10 @@ write(int fd, const void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_close.c b/lib/libpthread/uthread/uthread_close.c
index bc94d162b2a..6cfde5ca48e 100644
--- a/lib/libpthread/uthread/uthread_close.c
+++ b/lib/libpthread/uthread/uthread_close.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_close.c,v 1.4 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_close.c,v 1.5 1999/06/09 07:16:16 d Exp $
*/
#include <stdlib.h>
#include <unistd.h>
@@ -46,7 +46,9 @@ close(int fd)
int ret;
struct stat sb;
+ /* This is a cancelation point: */
_thread_enter_cancellation_point();
+
/* Lock the file descriptor while the file is closed: */
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
/* Get file descriptor status. */
@@ -85,7 +87,10 @@ close(int fd)
free(_thread_fd_table[fd]);
_thread_fd_table[fd] = NULL;
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_fcntl.c b/lib/libpthread/uthread/uthread_fcntl.c
index 1a0a3e9548a..c1348a7b27e 100644
--- a/lib/libpthread/uthread/uthread_fcntl.c
+++ b/lib/libpthread/uthread/uthread_fcntl.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_fcntl.c,v 1.4 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_fcntl.c,v 1.5 1999/06/09 07:16:16 d Exp $
*/
#include <stdarg.h>
#include <unistd.h>
@@ -47,6 +47,7 @@ fcntl(int fd, int cmd,...)
int ret;
va_list ap;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* Lock the file descriptor: */
@@ -137,6 +138,8 @@ fcntl(int fd, int cmd,...)
/* Unlock the file descriptor: */
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libpthread/uthread/uthread_fsync.c b/lib/libpthread/uthread/uthread_fsync.c
index 9db34f5564c..2136d62afe7 100644
--- a/lib/libpthread/uthread/uthread_fsync.c
+++ b/lib/libpthread/uthread/uthread_fsync.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_fsync.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_fsync.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <unistd.h>
#ifdef _THREAD_SAFE
@@ -41,12 +41,17 @@ fsync(int fd)
{
int ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
if ((ret = _FD_LOCK(fd, FD_RDWR, NULL)) == 0) {
ret = _thread_sys_fsync(fd);
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_join.c b/lib/libpthread/uthread/uthread_join.c
index ab7b7860ecc..42ef1f778bc 100644
--- a/lib/libpthread/uthread/uthread_join.c
+++ b/lib/libpthread/uthread/uthread_join.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_join.c,v 1.4 1999/05/26 00:18:24 d Exp $
+ * $OpenBSD: uthread_join.c,v 1.5 1999/06/09 07:16:17 d Exp $
*/
#include <errno.h>
#ifdef _THREAD_SAFE
@@ -100,7 +100,7 @@ pthread_join(pthread_t pthread, void **thread_return)
/* Return the thread's return value: */
*thread_return = pthread->ret;
- /* This operation was a cancel point: */
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libpthread/uthread/uthread_msync.c b/lib/libpthread/uthread/uthread_msync.c
index 246cdde7226..fb7d5a7e86e 100644
--- a/lib/libpthread/uthread/uthread_msync.c
+++ b/lib/libpthread/uthread/uthread_msync.c
@@ -1,7 +1,7 @@
/*
* David Leonard <d@openbsd.org>, 1999. Public Domain.
*
- * $OpenBSD: uthread_msync.c,v 1.1 1999/01/17 23:43:18 d Exp $
+ * $OpenBSD: uthread_msync.c,v 1.2 1999/06/09 07:16:17 d Exp $
*/
#include <sys/types.h>
@@ -24,9 +24,15 @@ msync(addr, len, flags)
* write. The only real use of this wrapper is to guarantee
* a cancellation point, as per the standard. sigh.
*/
+
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
ret = _thread_sys_msync(addr, len, flags);
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_nanosleep.c b/lib/libpthread/uthread/uthread_nanosleep.c
index 0f5c4c9c2ab..4e182adfb6c 100644
--- a/lib/libpthread/uthread/uthread_nanosleep.c
+++ b/lib/libpthread/uthread/uthread_nanosleep.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_nanosleep.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_nanosleep.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <stdio.h>
#include <errno.h>
@@ -48,7 +48,9 @@ nanosleep(const struct timespec * time_to_sleep,
struct timespec remaining_time;
struct timeval tv;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/* Check if the time to sleep is legal: */
if (time_to_sleep == NULL || time_to_sleep->tv_nsec < 0 || time_to_sleep->tv_nsec > 1000000000 || time_to_sleep->tv_sec < 0) {
/* Return an EINVAL error : */
@@ -96,7 +98,10 @@ nanosleep(const struct timespec * time_to_sleep,
ret = -1;
}
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_open.c b/lib/libpthread/uthread/uthread_open.c
index 9c03daa4f47..bfdcea73091 100644
--- a/lib/libpthread/uthread/uthread_open.c
+++ b/lib/libpthread/uthread/uthread_open.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_open.c,v 1.4 1998/04/29 09:59:07 jb Exp $
- * $OpenBSD: uthread_open.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_open.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <stdarg.h>
@@ -49,6 +49,7 @@ open(const char *path, int flags,...)
int mode = 0;
va_list ap;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* Check if the file is being created: */
@@ -70,6 +71,7 @@ open(const char *path, int flags,...)
fd = -1;
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the file descriptor or -1 on error: */
diff --git a/lib/libpthread/uthread/uthread_read.c b/lib/libpthread/uthread/uthread_read.c
index 22d1d03f091..6b9c96352d0 100644
--- a/lib/libpthread/uthread/uthread_read.c
+++ b/lib/libpthread/uthread/uthread_read.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_read.c,v 1.6 1998/06/10 22:28:43 jb Exp $
- * $OpenBSD: uthread_read.c,v 1.3 1999/01/17 23:57:27 d Exp $
+ * $OpenBSD: uthread_read.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <sys/types.h>
@@ -48,10 +48,12 @@ read(int fd, void *buf, size_t nbytes)
int ret;
int type;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* POSIX says to do just this: */
if (nbytes == 0) {
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -66,6 +68,7 @@ read(int fd, void *buf, size_t nbytes)
/* File is not open for read: */
errno = EBADF;
_FD_UNLOCK(fd, FD_READ);
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (-1);
}
@@ -98,6 +101,7 @@ read(int fd, void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_READ);
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (ret);
}
diff --git a/lib/libpthread/uthread/uthread_sigwait.c b/lib/libpthread/uthread/uthread_sigwait.c
index b4277133310..00cf99ef20b 100644
--- a/lib/libpthread/uthread/uthread_sigwait.c
+++ b/lib/libpthread/uthread/uthread_sigwait.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_sigwait.c,v 1.5 1999/05/26 00:18:26 d Exp $
+ * $OpenBSD: uthread_sigwait.c,v 1.6 1999/06/09 07:16:17 d Exp $
*/
#include <signal.h>
#include <errno.h>
@@ -45,7 +45,9 @@ sigwait(const sigset_t * set, int *sig)
sigset_t tempset;
struct sigaction act;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/*
* Specify the thread kernel signal handler.
*/
@@ -76,6 +78,7 @@ sigwait(const sigset_t * set, int *sig)
/* Return the signal number to the caller: */
*sig = i;
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -129,6 +132,7 @@ sigwait(const sigset_t * set, int *sig)
}
}
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
/* Return the completion status: */
diff --git a/lib/libpthread/uthread/uthread_wait4.c b/lib/libpthread/uthread/uthread_wait4.c
index a4f44e1d405..aef609468d4 100644
--- a/lib/libpthread/uthread/uthread_wait4.c
+++ b/lib/libpthread/uthread/uthread_wait4.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $OpenBSD: uthread_wait4.c,v 1.3 1999/01/17 23:57:28 d Exp $
+ * $OpenBSD: uthread_wait4.c,v 1.4 1999/06/09 07:16:17 d Exp $
*/
#include <errno.h>
#include <sys/wait.h>
@@ -42,7 +42,9 @@ wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
{
pid_t ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
+
/* Perform a non-blocking wait4 syscall: */
while ((ret = _thread_sys_wait4(pid, istat, options | WNOHANG, rusage)) == 0 && (options & WNOHANG) == 0) {
/* Reset the interrupted operation flag: */
@@ -58,7 +60,10 @@ wait4(pid_t pid, int *istat, int options, struct rusage * rusage)
break;
}
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif
diff --git a/lib/libpthread/uthread/uthread_write.c b/lib/libpthread/uthread/uthread_write.c
index b7c974ee289..7d91092f9ae 100644
--- a/lib/libpthread/uthread/uthread_write.c
+++ b/lib/libpthread/uthread/uthread_write.c
@@ -30,7 +30,7 @@
* SUCH DAMAGE.
*
* $FreeBSD: uthread_write.c,v 1.10 1998/09/07 21:55:01 alex Exp $
- * $OpenBSD: uthread_write.c,v 1.3 1999/01/17 23:57:28 d Exp $
+ * $OpenBSD: uthread_write.c,v 1.4 1999/06/09 07:16:17 d Exp $
*
*/
#include <sys/types.h>
@@ -51,10 +51,12 @@ write(int fd, const void *buf, size_t nbytes)
ssize_t num = 0;
ssize_t ret;
+ /* This is a cancellation point: */
_thread_enter_cancellation_point();
/* POSIX says to do just this: */
if (nbytes == 0) {
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (0);
}
@@ -69,6 +71,7 @@ write(int fd, const void *buf, size_t nbytes)
/* File is not open for write: */
errno = EBADF;
_FD_UNLOCK(fd, FD_WRITE);
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
return (-1);
}
@@ -135,7 +138,10 @@ write(int fd, const void *buf, size_t nbytes)
}
_FD_UNLOCK(fd, FD_RDWR);
}
+
+ /* No longer in a cancellation point: */
_thread_leave_cancellation_point();
+
return (ret);
}
#endif