about summary refs log tree commit diff
path: root/sysdeps/mach/hurd
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r--sysdeps/mach/hurd/accept4.c7
-rw-r--r--sysdeps/mach/hurd/connect.c11
-rw-r--r--sysdeps/mach/hurd/fdatasync.c8
-rw-r--r--sysdeps/mach/hurd/fsync.c8
-rw-r--r--sysdeps/mach/hurd/ioctl.c11
-rw-r--r--sysdeps/mach/hurd/msync.c4
-rw-r--r--sysdeps/mach/hurd/sigsuspend.c5
-rw-r--r--sysdeps/mach/hurd/sigwait.c4
8 files changed, 52 insertions, 6 deletions
diff --git a/sysdeps/mach/hurd/accept4.c b/sysdeps/mach/hurd/accept4.c
index 639f159951..2da7a8b032 100644
--- a/sysdeps/mach/hurd/accept4.c
+++ b/sysdeps/mach/hurd/accept4.c
@@ -24,6 +24,7 @@
 #include <hurd.h>
 #include <hurd/fd.h>
 #include <hurd/socket.h>
+#include <sysdep-cancel.h>
 
 /* Await a connection on socket FD.
    When a connection arrives, open a new socket to communicate with it,
@@ -41,13 +42,17 @@ __libc_accept4 (int fd, __SOCKADDR_ARG addrarg, socklen_t *addr_len, int flags)
   char *buf = (char *) addr;
   mach_msg_type_number_t buflen;
   int type;
+  int cancel_oldtype;
 
   flags = sock_to_o_flags (flags);
 
   if (flags & ~(O_CLOEXEC | O_NONBLOCK))
     return __hurd_fail (EINVAL);
 
-  if (err = HURD_DPORT_USE (fd, __socket_accept (port, &new, &aport)))
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
+  err = HURD_DPORT_USE_CANCEL (fd, __socket_accept (port, &new, &aport));
+  LIBC_CANCEL_RESET (cancel_oldtype);
+  if (err)
     return __hurd_dfail (fd, err);
 
   if (addr != NULL)
diff --git a/sysdeps/mach/hurd/connect.c b/sysdeps/mach/hurd/connect.c
index b9b9fddf8b..2b03b879aa 100644
--- a/sysdeps/mach/hurd/connect.c
+++ b/sysdeps/mach/hurd/connect.c
@@ -22,6 +22,7 @@
 #include <hurd/socket.h>
 #include <sys/un.h>
 #include <hurd/ifsock.h>
+#include <sysdep-cancel.h>
 #include "hurd/hurdsocket.h"
 
 /* Open a connection on socket FD to peer at ADDR (which LEN bytes long).
@@ -34,13 +35,17 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
   error_t err;
   addr_port_t aport;
   const struct sockaddr_un *addr = addrarg.__sockaddr_un__;
+  int cancel_oldtype;
 
   if (addr->sun_family == AF_LOCAL)
     {
       char *name = _hurd_sun_path_dupa (addr, len);
       /* For the local domain, we must look up the name as a file and talk
 	 to it with the ifsock protocol.  */
-      file_t file = __file_name_lookup (name, 0, 0);
+      file_t file;
+      cancel_oldtype = LIBC_CANCEL_ASYNC();
+      file = __file_name_lookup (name, 0, 0);
+      LIBC_CANCEL_RESET (cancel_oldtype);
       if (file == MACH_PORT_NULL)
 	return -1;
       err = __ifsock_getsockaddr (file, &aport);
@@ -54,7 +59,7 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
   else
     err = EIEIO;
 
-  err = HURD_DPORT_USE (fd,
+  err = HURD_DPORT_USE_CANCEL (fd,
 			({
 			  if (err)
 			    err = __socket_create_address (port,
@@ -63,7 +68,9 @@ __connect (int fd, __CONST_SOCKADDR_ARG addrarg, socklen_t len)
 							   &aport);
 			  if (! err)
 			    {
+			      cancel_oldtype = LIBC_CANCEL_ASYNC();
 			      err = __socket_connect (port, aport);
+			      LIBC_CANCEL_RESET (cancel_oldtype);
 			      __mach_port_deallocate (__mach_task_self (),
 						      aport);
 			    }
diff --git a/sysdeps/mach/hurd/fdatasync.c b/sysdeps/mach/hurd/fdatasync.c
index 797fcf6a88..8ccda0a0b3 100644
--- a/sysdeps/mach/hurd/fdatasync.c
+++ b/sysdeps/mach/hurd/fdatasync.c
@@ -19,12 +19,18 @@
 #include <unistd.h>
 #include <hurd.h>
 #include <hurd/fd.h>
+#include <sysdep-cancel.h>
 
 /* Make all changes done to FD's file data actually appear on disk.  */
 int
 fdatasync (int fd)
 {
-  error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 1));
+  error_t err;
+  int cancel_oldtype;
+
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
+  err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 1));
+  LIBC_CANCEL_RESET (cancel_oldtype);
   if (err)
     {
       if (err == EOPNOTSUPP)
diff --git a/sysdeps/mach/hurd/fsync.c b/sysdeps/mach/hurd/fsync.c
index 85aa992db2..0b2a09dcf8 100644
--- a/sysdeps/mach/hurd/fsync.c
+++ b/sysdeps/mach/hurd/fsync.c
@@ -19,12 +19,18 @@
 #include <unistd.h>
 #include <hurd.h>
 #include <hurd/fd.h>
+#include <sysdep-cancel.h>
 
 /* Make all changes done to FD actually appear on disk.  */
 int
 fsync (int fd)
 {
-  error_t err = HURD_DPORT_USE (fd, __file_sync (port, 1, 0));
+  error_t err;
+  int cancel_oldtype;
+
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
+  err = HURD_DPORT_USE_CANCEL (fd, __file_sync (port, 1, 0));
+  LIBC_CANCEL_RESET (cancel_oldtype);
   if (err)
     {
       if (err == EOPNOTSUPP)
diff --git a/sysdeps/mach/hurd/ioctl.c b/sysdeps/mach/hurd/ioctl.c
index a9a148f1e3..4c0e54b038 100644
--- a/sysdeps/mach/hurd/ioctl.c
+++ b/sysdeps/mach/hurd/ioctl.c
@@ -27,6 +27,7 @@
 #include <stdint.h>
 #include <hurd/ioctl.h>
 #include <mach/mig_support.h>
+#include <sysdep-cancel.h>
 
 #include <hurd/ioctls.defs>
 
@@ -269,7 +270,15 @@ __ioctl (int fd, unsigned long int request, ...)
   /* Marshal the arguments into the request message and make the RPC.
      This wrapper function handles EBACKGROUND returns, turning them
      into either SIGTTOU or EIO.  */
-  err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc));
+  if (request == TIOCDRAIN)
+    {
+      /* This is a cancellation point.  */
+      int cancel_oldtype = LIBC_CANCEL_ASYNC();
+      err = HURD_DPORT_USE_CANCEL (fd, _hurd_ctty_output (port, ctty, send_rpc));
+      LIBC_CANCEL_RESET (cancel_oldtype);
+    }
+  else
+    err = HURD_DPORT_USE (fd, _hurd_ctty_output (port, ctty, send_rpc));
 
 #ifdef MACH_MSG_TYPE_BIT
   t = (mach_msg_type_t *) msg.data;
diff --git a/sysdeps/mach/hurd/msync.c b/sysdeps/mach/hurd/msync.c
index cec467eb7f..1820190dbe 100644
--- a/sysdeps/mach/hurd/msync.c
+++ b/sysdeps/mach/hurd/msync.c
@@ -19,6 +19,7 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <errno.h>
+#include <sysdep-cancel.h>
 
 #include <hurd/hurd.h>
 
@@ -44,6 +45,7 @@ msync (void *addr, size_t length, int flags)
   vm_offset_t offset;
 
   kern_return_t err;
+  int cancel_oldtype;
 
   if (flags & (MS_SYNC | MS_ASYNC) == (MS_SYNC | MS_ASYNC))
     return __hurd_fail (EINVAL);
@@ -77,8 +79,10 @@ msync (void *addr, size_t length, int flags)
 	  else
 	    sync_len = len;
 
+	  cancel_oldtype = LIBC_CANCEL_ASYNC();
 	  err = __vm_object_sync (obj, cur - begin + offset, sync_len,
 				  should_flush, 1, should_iosync);
+	  LIBC_CANCEL_RESET (cancel_oldtype);
 	  __mach_port_deallocate (__mach_task_self (), obj);
 
 	  if (err)
diff --git a/sysdeps/mach/hurd/sigsuspend.c b/sysdeps/mach/hurd/sigsuspend.c
index 38f095ef09..ed98104dce 100644
--- a/sysdeps/mach/hurd/sigsuspend.c
+++ b/sysdeps/mach/hurd/sigsuspend.c
@@ -20,6 +20,7 @@
 #include <hurd.h>
 #include <hurd/signal.h>
 #include <hurd/msg.h>
+#include <sysdep-cancel.h>
 
 /* Change the set of blocked signals to SET,
    wait until a signal arrives, and restore the set of blocked signals.  */
@@ -30,6 +31,7 @@ __sigsuspend (const sigset_t *set)
   sigset_t newmask, oldmask, pending;
   mach_port_t wait;
   mach_msg_header_t msg;
+  int cancel_oldtype;
 
   if (set != NULL)
     /* Crash before locking.  */
@@ -59,8 +61,11 @@ __sigsuspend (const sigset_t *set)
     __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ());
 
   /* Wait for the signal thread's message.  */
+
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
   __mach_msg (&msg, MACH_RCV_MSG, 0, sizeof (msg), wait,
 	      MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+  LIBC_CANCEL_RESET (cancel_oldtype);
   __mach_port_destroy (__mach_task_self (), wait);
 
   /* Restore the old mask and check for pending signals again.  */
diff --git a/sysdeps/mach/hurd/sigwait.c b/sysdeps/mach/hurd/sigwait.c
index 53d2110983..48ccaf05fe 100644
--- a/sysdeps/mach/hurd/sigwait.c
+++ b/sysdeps/mach/hurd/sigwait.c
@@ -21,6 +21,7 @@
 #include <hurd/msg.h>
 #include <hurd/sigpreempt.h>
 #include <assert.h>
+#include <sysdep-cancel.h>
 
 /* Select any of pending signals from SET or wait for any to arrive.  */
 int
@@ -33,6 +34,7 @@ __sigwait (const sigset_t *set, int *sig)
   jmp_buf buf;
   mach_port_t wait;
   mach_msg_header_t msg;
+  int cancel_oldtype;
 
   sighandler_t
     preempt_fun (struct hurd_signal_preemptor *pe,
@@ -71,6 +73,7 @@ __sigwait (const sigset_t *set, int *sig)
     __sigemptyset (&mask);
 
   ss = _hurd_self_sigstate ();
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
   _hurd_sigstate_lock (ss);
 
   /* See if one of these signals is currently pending.  */
@@ -128,6 +131,7 @@ __sigwait (const sigset_t *set, int *sig)
 
 all_done:
   _hurd_sigstate_unlock (ss);
+  LIBC_CANCEL_RESET (cancel_oldtype);
 
   __mach_port_destroy (__mach_task_self (), wait);
   *sig = signo;