]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: Make send* cancellation points
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 14 Jun 2020 17:09:59 +0000 (17:09 +0000)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sun, 14 Jun 2020 17:11:22 +0000 (17:11 +0000)
* sysdeps/mach/hurd/send.c (__send): Make the __socket_send call
a cancellation point.
* sysdeps/mach/hurd/sendto.c (__sendto): Likewise.
* sysdeps/mach/hurd/sendmsg.c (__libc_sendmsg): Likewise.

sysdeps/mach/hurd/send.c
sysdeps/mach/hurd/sendmsg.c
sysdeps/mach/hurd/sendto.c

index af002765d2309c684cc4c06a5edee9ca19f07b85..78edbc2ff38fa151af7bd3dae16c4259c8df2363 100644 (file)
@@ -20,6 +20,7 @@
 #include <hurd.h>
 #include <hurd/socket.h>
 #include <hurd/fd.h>
+#include <sysdep-cancel.h>
 
 /* Send N bytes of BUF to socket FD.  Returns the number sent or -1.  */
 ssize_t
@@ -27,11 +28,14 @@ __send (int fd, const void *buf, size_t n, int flags)
 {
   error_t err;
   size_t wrote;
+  int cancel_oldtype;
 
+  cancel_oldtype = LIBC_CANCEL_ASYNC();
   err = HURD_DPORT_USE (fd, __socket_send (port, MACH_PORT_NULL,
                                           flags, buf, n,
                                           NULL, MACH_MSG_TYPE_COPY_SEND, 0,
                                           NULL, 0, &wrote));
+  LIBC_CANCEL_RESET (cancel_oldtype);
 
   if (err == MIG_BAD_ID || err == EOPNOTSUPP)
     /* The file did not grok the socket protocol.  */
index dfc5afd4c6e12af0f78edf4417220ad8dbb90f23..37ab7f3ce0eb0c2234387e4dbd7692bcab11be1c 100644 (file)
@@ -24,6 +24,7 @@
 #include <hurd/fd.h>
 #include <hurd/ifsock.h>
 #include <hurd/socket.h>
+#include <sysdep-cancel.h>
 #include "hurd/hurdsocket.h"
 
 /* Send a message described MESSAGE on socket FD.
@@ -184,6 +185,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
                          if (! err)
                            {
                              /* Send the data.  */
+                             int cancel_oldtype = LIBC_CANCEL_ASYNC();
                              err = __socket_send (port, aport,
                                                   flags, data.ptr, len,
                                                   ports,
@@ -192,6 +194,7 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
                                                   message->msg_control,
                                                   message->msg_controllen,
                                                   &amount);
+                             LIBC_CANCEL_RESET (cancel_oldtype);
                              __mach_port_deallocate (__mach_task_self (),
                                                      aport);
                            }
index 2f26b36b9e7cc8bf1ed3c24c0a12c5c0dc887721..a5faf8ea2e261197f713ed741a7e21445c680ddf 100644 (file)
@@ -22,6 +22,7 @@
 #include <hurd/fd.h>
 #include <hurd/ifsock.h>
 #include <hurd/socket.h>
+#include <sysdep-cancel.h>
 #include "hurd/hurdsocket.h"
 
 /* Send N bytes of BUF on socket FD to peer at address ADDR (which is
@@ -82,11 +83,13 @@ __sendto (int fd,
                          if (! err)
                            {
                              /* Send the data.  */
+                             int cancel_oldtype = LIBC_CANCEL_ASYNC();
                              err = __socket_send (port, aport,
                                                   flags, buf, n,
                                                   NULL,
                                                   MACH_MSG_TYPE_COPY_SEND, 0,
                                                   NULL, 0, &wrote);
+                             LIBC_CANCEL_RESET (cancel_oldtype);
                            }
                          err;
                        }));