From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from hera.aquilenet.fr (hera.aquilenet.fr [IPv6:2a0c:e300::1]) by sourceware.org (Postfix) with ESMTPS id B1B5F3851C09 for ; Sun, 28 Jun 2020 16:49:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B1B5F3851C09 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=samuel.thibault@ens-lyon.org Received: from localhost (localhost [127.0.0.1]) by hera.aquilenet.fr (Postfix) with ESMTP id 8C5781881; Sun, 28 Jun 2020 18:49:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at aquilenet.fr Received: from hera.aquilenet.fr ([127.0.0.1]) by localhost (hera.aquilenet.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 03HRlrzDNmA7; Sun, 28 Jun 2020 18:49:06 +0200 (CEST) Received: from function (lfbn-bor-1-797-11.w86-234.abo.wanadoo.fr [86.234.239.11]) by hera.aquilenet.fr (Postfix) with ESMTPSA id 677AF187E; Sun, 28 Jun 2020 18:49:06 +0200 (CEST) Received: from samy by function with local (Exim 4.94) (envelope-from ) id 1jpaUF-002n6k-ES; Sun, 28 Jun 2020 18:48:59 +0200 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited] hurd: make close a cancellation point Date: Sun, 28 Jun 2020 18:48:59 +0200 Message-Id: <20200628164859.665385-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jun 2020 16:49:11 -0000 and add _nocancel variant. * sysdeps/mach/hurd/Makefile [io] (sysdep_routines): Add close_nocancel. * sysdeps/mach/hurd/Versions (libc.GLIBC_PRIVATE, ld.GLIBC_PRIVATE): Add __close_nocancel. * sysdeps/mach/hurd/i386/localplt.data (__close_nocancel): Allow PLT. * sysdeps/mach/hurd/close.c: Include (__libc_close): Surround _hurd_fd_close with enabling async cancel. * sysdeps/mach/hurd/close_nocancel.c: New file. * sysdeps/mach/hurd/not-cancel.h (__close_nocancel): Replace macro with declaration with hidden proto. --- sysdeps/mach/hurd/Makefile | 2 +- sysdeps/mach/hurd/Versions | 2 ++ sysdeps/mach/hurd/close.c | 4 ++++ sysdeps/mach/hurd/close_nocancel.c | 34 ++++++++++++++++++++++++++++ sysdeps/mach/hurd/dl-sysdep.c | 2 ++ sysdeps/mach/hurd/i386/localplt.data | 3 ++- sysdeps/mach/hurd/not-cancel.h | 9 ++++---- 7 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 sysdeps/mach/hurd/close_nocancel.c diff --git a/sysdeps/mach/hurd/Makefile b/sysdeps/mach/hurd/Makefile index a58e8c1c3d..4bfd290c09 100644 --- a/sysdeps/mach/hurd/Makefile +++ b/sysdeps/mach/hurd/Makefile @@ -196,7 +196,7 @@ sysdep_routines += cthreads endif ifeq (io, $(subdir)) -sysdep_routines += f_setlk close_nocancel_nostatus \ +sysdep_routines += f_setlk close_nocancel close_nocancel_nostatus \ open_nocancel openat_nocancel read_nocancel \ pread64_nocancel write_nocancel pwrite64_nocancel endif diff --git a/sysdeps/mach/hurd/Versions b/sysdeps/mach/hurd/Versions index 67594d8c08..c456f472c4 100644 --- a/sysdeps/mach/hurd/Versions +++ b/sysdeps/mach/hurd/Versions @@ -13,6 +13,7 @@ libc { GLIBC_PRIVATE { # Functions shared with the dynamic linker __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64; + __close_nocancel; __open_nocancel; __read_nocancel; __pread64_nocancel; __write_nocancel; @@ -55,6 +56,7 @@ ld { # functions that must be shared with libc __access; __access_noerrno; __libc_read; __libc_write; __libc_lseek64; + __close_nocancel; __open_nocancel; __read_nocancel; __pread64_nocancel; __write_nocancel; diff --git a/sysdeps/mach/hurd/close.c b/sysdeps/mach/hurd/close.c index 4b1e203084..b461087447 100644 --- a/sysdeps/mach/hurd/close.c +++ b/sysdeps/mach/hurd/close.c @@ -19,14 +19,18 @@ #include #include #include +#include /* Close the file descriptor FD. */ int __close (int fd) { error_t err; + int cancel_oldtype; + cancel_oldtype = LIBC_CANCEL_ASYNC(); err = HURD_FD_USE (fd, _hurd_fd_close (descriptor)); + LIBC_CANCEL_RESET (cancel_oldtype); return err ? __hurd_fail (err) : 0; } diff --git a/sysdeps/mach/hurd/close_nocancel.c b/sysdeps/mach/hurd/close_nocancel.c new file mode 100644 index 0000000000..3411e321ab --- /dev/null +++ b/sysdeps/mach/hurd/close_nocancel.c @@ -0,0 +1,34 @@ +/* Copyright (C) 1991-2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +/* Close the file descriptor FD. */ +int +__close_nocancel (int fd) +{ + error_t err; + + err = HURD_FD_USE (fd, _hurd_fd_close (descriptor)); + + return err ? __hurd_fail (err) : 0; +} +libc_hidden_def (__close_nocancel) diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c index 8a87b9b0f2..2a9a6d12bc 100644 --- a/sysdeps/mach/hurd/dl-sysdep.c +++ b/sysdeps/mach/hurd/dl-sysdep.c @@ -353,6 +353,7 @@ weak_alias (__open, __open64) weak_alias (__open, __open_nocancel) check_no_hidden(__close); +check_no_hidden(__close_nocancel); int weak_function __close (int fd) { @@ -360,6 +361,7 @@ __close (int fd) __mach_port_deallocate (__mach_task_self (), (mach_port_t) fd); return 0; } +weak_alias (__close, __close_nocancel) check_no_hidden(__pread64); check_no_hidden(__pread64_nocancel); diff --git a/sysdeps/mach/hurd/i386/localplt.data b/sysdeps/mach/hurd/i386/localplt.data index 66e9c4f253..b199e14e7f 100644 --- a/sysdeps/mach/hurd/i386/localplt.data +++ b/sysdeps/mach/hurd/i386/localplt.data @@ -19,7 +19,8 @@ ld.so: _dl_catch_exception + REL R_386_GLOB_DAT ld.so: __open ? ld.so: __open64 ? ld.so: __open_nocancel -ld.so: __close +ld.so: __close ? +ld.so: __close_nocancel ld.so: __read ? ld.so: __read_nocancel ld.so: __pread64 diff --git a/sysdeps/mach/hurd/not-cancel.h b/sysdeps/mach/hurd/not-cancel.h index c627ec7bde..7e824c5f11 100644 --- a/sysdeps/mach/hurd/not-cancel.h +++ b/sysdeps/mach/hurd/not-cancel.h @@ -28,9 +28,8 @@ #include #include -/* For now we have none. Map the name to the normal functions. */ -#define __close_nocancel(fd) \ - __close (fd) +/* Non cancellable close syscall. */ +__typeof (__close) __close_nocancel; void __close_nocancel_nostatus (int fd); @@ -64,12 +63,15 @@ __typeof (__writev) __writev_nocancel; /* Non cancellable writev syscall with no status. */ void __writev_nocancel_nostatus (int fd, const struct iovec *vector, int count); +/* For now we have none. Map the name to the normal functions. */ # define __waitpid_nocancel(pid, stat_loc, options) \ __waitpid (pid, stat_loc, options) #define __fcntl64_nocancel(fd, cmd, ...) \ __fcntl64 (fd, cmd, __VA_ARGS__) #if IS_IN (libc) +hidden_proto (__close_nocancel) +hidden_proto (__close_nocancel_nostatus) hidden_proto (__open_nocancel) hidden_proto (__openat_nocancel) hidden_proto (__read_nocancel) @@ -78,7 +80,6 @@ hidden_proto (__write_nocancel) hidden_proto (__pwrite64_nocancel) hidden_proto (__writev_nocancel) hidden_proto (__writev_nocancel_nostatus) -hidden_proto (__close_nocancel_nostatus) #endif #endif /* NOT_CANCEL_H */ -- 2.27.0