]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Consolidate non cancellable close call
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 3 Jul 2017 18:22:58 +0000 (15:22 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 18 Aug 2017 21:38:55 +0000 (18:38 -0300)
This patch consolidates all the non cancellable close calls to use
the __close_nocancel{_nostatus} identifier.  For non cancellable targets
it will be just a macro to call the default respective symbol while on Linux
will be a internal one.

Also, since it is used on libcrypto it is also exported in GLIBC_PRIVATE
namespace.

Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.

* sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New macro.
(__close_nocancel_no_status): Likewise.
* sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove
macro.
(close_not_cancel): Likewise.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New prototype.
(__close_nocancel_no_status): New function.
* sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function.
* catgets/open_catalog.c (__open_catalog): Replace
close_not_cancel{_no_status) with __close_nocancel{_nostatus}.
* gmon/gmon.c (write_gmon): Likewise.
* iconv/gconv_cache.c (__gconv_load_cache): Likewise.
* intl/loadmsgcat.c (close): Likewise.
* io/ftw.c (open_dir_stream): Likewise.
(ftw_startup): Likewise.
* libio/fileops.c (_IO_file_open): Likewise.
(_IO_file_close_mmap): Likewise.
(_IO_file_close): Likewise.
* libio/iopopen.c (_IO_dup2): Likewise.
* locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(endutent_file): Likewise.
* misc/daemon.c (daemon): Likewise.
* nscd/nscd_getai.c (__nscd_getai): Likewise.
* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
* nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise.
* nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise.
* nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise.
* nscd/nscd_helper.c (open_socket): Likewise.
(__nscd_open_socket): Likewise.
* nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise.
* nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise.
(__nscd_innetgr): Likewise.
* nss/nss_db/db-open.c (internal_setent): Likewise.
* resolv/res-close.c (__res_iclose): Likewise.
* sunrpc/pm_getmaps.c (pmap_getmaps): Likewise.
* sysdeps/posix/closedir.c (__closedir): Likewise.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
(opendir_tail): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise.
* sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
(gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
* sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.

50 files changed:
ChangeLog
catgets/open_catalog.c
gmon/gmon.c
iconv/gconv_cache.c
intl/loadmsgcat.c
io/ftw.c
libio/fileops.c
libio/iopopen.c
locale/loadarchive.c
locale/loadlocale.c
login/utmp_file.c
misc/daemon.c
nscd/nscd_getai.c
nscd/nscd_getgr_r.c
nscd/nscd_gethst_r.c
nscd/nscd_getpw_r.c
nscd/nscd_getserv_r.c
nscd/nscd_helper.c
nscd/nscd_initgroups.c
nscd/nscd_netgroup.c
nss/nss_db/db-open.c
resolv/res-close.c
sunrpc/pm_getmaps.c
sysdeps/generic/not-cancel.h
sysdeps/posix/closedir.c
sysdeps/posix/getaddrinfo.c
sysdeps/posix/getcwd.c
sysdeps/posix/opendir.c
sysdeps/posix/spawni.c
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/check_native.c
sysdeps/unix/sysv/linux/check_pf.c
sysdeps/unix/sysv/linux/close.c
sysdeps/unix/sysv/linux/fips-private.h
sysdeps/unix/sysv/linux/gethostid.c
sysdeps/unix/sysv/linux/getloadavg.c
sysdeps/unix/sysv/linux/getlogin_r.c
sysdeps/unix/sysv/linux/getsysstats.c
sysdeps/unix/sysv/linux/grantpt.c
sysdeps/unix/sysv/linux/i386/smp.h
sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
sysdeps/unix/sysv/linux/if_index.c
sysdeps/unix/sysv/linux/libc_fatal.c
sysdeps/unix/sysv/linux/malloc-sysdep.h
sysdeps/unix/sysv/linux/mq_notify.c
sysdeps/unix/sysv/linux/not-cancel.h
sysdeps/unix/sysv/linux/pthread_getname.c
sysdeps/unix/sysv/linux/pthread_setname.c
sysdeps/unix/sysv/linux/spawni.c
sysdeps/unix/sysv/linux/sysconf.c

index 4cdf2f761689ce9510c9ee57570ca0667ef23198..b7493e0d5d4aef7970df320ff4be71e8edee29ee 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,78 @@
 2017-08-18  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+       * sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.
+       (close_not_cancel_no_status): Likewise.
+       (__close_nocancel): New macro.
+       (__close_nocancel_nostatus): Likewise.
+       * sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove
+       macro.
+       (close_not_cancel): Likewise.
+       (close_not_cancel_no_status): Likewise.
+       (__close_nocancel): New prototype.
+       (__close_nocancel_nostatus): New function.
+       * sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function.
+       * catgets/open_catalog.c (__open_catalog): Replace
+       close_not_cancel{_no_status) with __close_nocancel{_nostatus}.
+       * gmon/gmon.c (write_gmon): Likewise.
+       * iconv/gconv_cache.c (__gconv_load_cache): Likewise.
+       * intl/loadmsgcat.c (close): Likewise.
+       * io/ftw.c (open_dir_stream): Likewise.
+       (ftw_startup): Likewise.
+       * libio/fileops.c (_IO_file_open): Likewise.
+       (_IO_file_close_mmap): Likewise.
+       (_IO_file_close): Likewise.
+       * libio/iopopen.c (_IO_dup2): Likewise.
+       * locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
+       * locale/loadlocale.c (_nl_load_locale): Likewise.
+       * login/utmp_file.c (pututline_file): Likewise.
+       (endutent_file): Likewise.
+       * misc/daemon.c (daemon): Likewise.
+       * nscd/nscd_getai.c (__nscd_getai): Likewise.
+       * nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
+       * nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise.
+       * nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise.
+       * nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise.
+       * nscd/nscd_helper.c (open_socket): Likewise.
+       (__nscd_open_socket): Likewise.
+       * nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise.
+       * nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise.
+       (__nscd_innetgr): Likewise.
+       * nss/nss_db/db-open.c (internal_setent): Likewise.
+       * resolv/res-close.c (__res_iclose): Likewise.
+       * sunrpc/pm_getmaps.c (pmap_getmaps): Likewise.
+       * sysdeps/posix/closedir.c (__closedir): Likewise.
+       * sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise.
+       * sysdeps/posix/getcwd.c (__getcwd): Likewise.
+       * sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
+       (opendir_tail): Likewise.
+       * sysdeps/posix/spawni.c (__spawni_child): Likewise.
+       * sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise.
+       * sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise.
+       * sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise.
+       * sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
+       (gethostid): Likewise.
+       * sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
+       * sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
+       Likewise.
+       * sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
+       * sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise.
+       * sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
+       * sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
+       Likewise.
+       * sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise.
+       * sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise.
+       * sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
+       Likewise.
+       * sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise.
+       * sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
+       Likewise.
+       * sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
+       Likewise.
+       * sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
+       * sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
+       * sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
+       __close_nocancel.
+
        * sysdeps/generic/not-cancel.h (openat_not_cancel): Remove macro.
        (openat_not_cancel_3): Likewise.
        (openat64_not_cancel_3): Likewise).
index d79a6b1f3439ee731c9a2775a12a5f33c48a1ebe..42f61fb3f154d8cbf9619f7ee50bf8f1386b3584 100644 (file)
@@ -328,7 +328,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
 
   /* Release the lock again.  */
  close_unlock_return:
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
   free (buf);
 
   return result;
index e7701b9757cebfcf097bfc94567960154d7e40d1..90c7895980edc1419bedc24252d7fd21bac9fd7c 100644 (file)
@@ -386,7 +386,7 @@ write_gmon (void)
     /* write basic-block execution counts: */
     write_bb_counts (fd);
 
-    close_not_cancel_no_status (fd);
+    __close_nocancel_nostatus (fd);
 }
 
 
index f1dce291f5cd6a35095c3d400a295df8d4034188..d6a47de838e9a0c7cd9684b43b002d64d6ee6b64 100644 (file)
@@ -71,7 +71,7 @@ __gconv_load_cache (void)
       || (size_t) st.st_size < sizeof (struct gconvcache_header))
     {
     close_and_exit:
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       return -1;
     }
 
@@ -108,7 +108,7 @@ __gconv_load_cache (void)
     }
 
   /* We don't need the file descriptor anymore.  */
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   /* Check the consistency.  */
   header = (struct gconvcache_header *) gconv_cache;
index 514e38fed6877a28473bd912a6bb0474a10ac8b8..13e2f2a573897fb2dc9713748622a23b115a3099 100644 (file)
    because some ISO C functions will require linking with this object
    file and the name space must not be polluted.  */
 # define open(name, flags)     __open_nocancel (name, flags)
-# define close(fd)             close_not_cancel_no_status (fd)
+# define close(fd)             __close_nocancel_nostatus (fd)
 # define read(fd, buf, n)      __read_nocancel (fd, buf, n)
 # define mmap(addr, len, prot, flags, fd, offset) \
   __mmap (addr, len, prot, flags, fd, offset)
index f33fed327d3c73b70c2f0a772b49d375b06c0a63..106b6bf4ecf47f3c55a1bd210127ef7b3b3dd17f 100644 (file)
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -341,7 +341,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
                                        O_RDONLY | O_DIRECTORY | O_NDELAY);
          dirp->stream = NULL;
          if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL)
-           close_not_cancel_no_status (fd);
+           __close_nocancel_nostatus (fd);
        }
       else
        {
@@ -791,7 +791,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
     {
       int save_err = errno;
       __fchdir (cwdfd);
-      close_not_cancel_no_status (cwdfd);
+      __close_nocancel_nostatus (cwdfd);
       __set_errno (save_err);
     }
   else if (cwd != NULL)
index f02517877ad5bc4bf3e83abebbcccc4e1fc4046c..b8b02ba2613ca64c35c0e481b1dc3bdc5567b6ae 100644 (file)
@@ -242,7 +242,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
       _IO_off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end);
       if (new_pos == _IO_pos_BAD && errno != ESPIPE)
        {
-         close_not_cancel (fdesc);
+         __close_nocancel (fdesc);
          return NULL;
        }
     }
@@ -1231,7 +1231,7 @@ _IO_file_close_mmap (_IO_FILE *fp)
   fp->_IO_buf_base = fp->_IO_buf_end = NULL;
   /* Cancelling close should be avoided if possible since it leaves an
      unrecoverable state behind.  */
-  return close_not_cancel (fp->_fileno);
+  return __close_nocancel (fp->_fileno);
 }
 
 int
@@ -1239,7 +1239,7 @@ _IO_file_close (_IO_FILE *fp)
 {
   /* Cancelling close should be avoided if possible since it leaves an
      unrecoverable state behind.  */
-  return close_not_cancel (fp->_fileno);
+  return __close_nocancel (fp->_fileno);
 }
 libc_hidden_def (_IO_file_close)
 
index b78e7e5ef265c2a025f5bd2a1b4e57290a7e90ed..0c20cbbfe2b1182248d8e7f6ff801b49bbffec39 100644 (file)
@@ -76,7 +76,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW;
 
 #ifndef _IO_close
 #ifdef _LIBC
-#define _IO_close close_not_cancel
+#define _IO_close __close_nocancel
 #else
 #define _IO_close close
 #endif
index 7825a1c655572351bc79bcbbcf1e5c2bf9d40966..158cf14af8d21a1ade62d348ddbfa410880ef150 100644 (file)
@@ -213,7 +213,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
          /* stat failed, very strange.  */
        close_and_out:
          if (fd >= 0)
-           close_not_cancel_no_status (fd);
+           __close_nocancel_nostatus (fd);
          return NULL;
        }
 
@@ -253,7 +253,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
        {
          /* We've mapped the whole file already, so we can be
             sure we won't need this file descriptor later.  */
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
          fd = -1;
        }
 
@@ -452,7 +452,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
 
   /* We don't need the file descriptor any longer.  */
   if (fd >= 0)
-    close_not_cancel_no_status (fd);
+    __close_nocancel_nostatus (fd);
   fd = -1;
 
   /* We succeeded in mapping all the necessary regions of the archive.
index 781fa8808c89a785720d5ceb49c7fd791169b8e4..24ad671ead0a2d73a607753b87d1458ca11c04eb 100644 (file)
@@ -181,7 +181,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
   if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
     {
     puntfd:
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       return;
     }
   if (__glibc_unlikely (S_ISDIR (st.st_mode)))
@@ -191,7 +191,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
       char *newp;
       size_t filenamelen;
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
 
       filenamelen = strlen (file->filename);
       newp = (char *) alloca (filenamelen
@@ -257,7 +257,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
 #endif /* _POSIX_MAPPED_FILES */
 
   /* We have mapped the data, so we no longer need the descriptor.  */
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   if (__glibc_unlikely (filedata == NULL))
     /* We failed to map or read the data.  */
index 26e3f4bf8943252e503d365477bd84eadfe70a13..68e00f2a0212b3dbd6cacbdf9c66ff57331c5034 100644 (file)
@@ -382,10 +382,10 @@ pututline_file (const struct utmp *data)
       if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1
          || __dup2 (new_fd, file_fd) < 0)
        {
-         close_not_cancel_no_status (new_fd);
+         __close_nocancel_nostatus (new_fd);
          return NULL;
        }
-      close_not_cancel_no_status (new_fd);
+      __close_nocancel_nostatus (new_fd);
       file_writable = true;
     }
 
@@ -471,7 +471,7 @@ endutent_file (void)
 {
   assert (file_fd >= 0);
 
-  close_not_cancel_no_status (file_fd);
+  __close_nocancel_nostatus (file_fd);
   file_fd = -1;
 }
 
@@ -518,7 +518,7 @@ unlock_return:
   UNLOCK_FILE (fd);
 
   /* Close WTMP file.  */
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return result;
 }
index dd38f2b87f2720377ec9a23068cc49198108115c..21e785966ac19eb8fb547971c4405187163371c3 100644 (file)
@@ -80,12 +80,12 @@ daemon (int nochdir, int noclose)
                        } else {
                                /* We must set an errno value since no
                                   function call actually failed.  */
-                               close_not_cancel_no_status (fd);
+                               __close_nocancel_nostatus (fd);
                                __set_errno (ENODEV);
                                return -1;
                        }
                } else {
-                       close_not_cancel_no_status (fd);
+                       __close_nocancel_nostatus (fd);
                        return -1;
                }
        }
index daaf6d68b286d9b0a877e450a7bf2616f8290c4f..03c02961d1df4ede5c8f0df4d5b261a6f9007097 100644 (file)
@@ -189,7 +189,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index 87b4552197d364195091ecf3400a8304770aedde..1f6026101b52b8296683ccd3e4f6daa00bbb275d 100644 (file)
@@ -305,7 +305,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index daa708b3d37aab9ce8a7fea9958edf973f854e36..e234c7f2f3bee960988ed9cbf8b25dd5f797e687 100644 (file)
@@ -436,7 +436,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index b291d2fa44d6bacf281def8c4178be07dafa98ae..fbece1c99a80d14fde423dd9e7f6194ba2052447 100644 (file)
@@ -218,7 +218,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index 7dfb1c828deea08797f187db01abd4378be65711..12c3104cc4cd8f1e1b3ee4bb9eb8d7dbf8d42c52 100644 (file)
@@ -356,7 +356,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index 22905d0b839671cc42d606230921a70827b356bc..a225623f9273832fd66e74760c04f8f89f2ac40e 100644 (file)
@@ -236,7 +236,7 @@ open_socket (request_type type, const char *key, size_t keylen)
     }
 
  out:
-  close_not_cancel_no_status (sock);
+  __close_nocancel_nostatus (sock);
 
   return -1;
 }
@@ -555,7 +555,7 @@ __nscd_open_socket (const char *key, size_t keylen, request_type type,
            return sock;
        }
 
-      close_not_cancel_no_status (sock);
+      __close_nocancel_nostatus (sock);
     }
 
   __set_errno (saved_errno);
index 00c650896ab551c61ff8be17b2e17cdcf4be8e15..c06f2f88cb1062348c535cb3a3dbce45184be748 100644 (file)
@@ -157,7 +157,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index 44f37ef95783a3b6cba88b512236ab33870286c7..559bb349c55d7aa33f929ea41a1a28c1eebdf8c7 100644 (file)
@@ -139,7 +139,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
@@ -263,7 +263,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user,
 
  out_close:
   if (sock != -1)
-    close_not_cancel_no_status (sock);
+    __close_nocancel_nostatus (sock);
  out:
   if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
     {
index 40a2540d95c7a6cd135cbcaa6eff1e8e1a20f6bd..bf08ac9ca5c04ecda6dd95ed1785a32c30edd52f 100644 (file)
@@ -52,7 +52,7 @@ internal_setent (const char *file, struct nss_db_map *mapping)
            status = NSS_STATUS_TRYAGAIN;
        }
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
     }
 
   return status;
index 21f038c2c77f737567967cc168b5694510c8cc35..766bf429db00da7c5bc3c4cb21e77aff3c99c0a4 100644 (file)
@@ -94,7 +94,7 @@ __res_iclose (res_state statp, bool free_addr)
 {
   if (statp->_vcsock >= 0)
     {
-      close_not_cancel_no_status (statp->_vcsock);
+      __close_nocancel_nostatus (statp->_vcsock);
       statp->_vcsock = -1;
       statp->_flags &= ~(RES_F_VC | RES_F_CONN);
     }
@@ -103,7 +103,7 @@ __res_iclose (res_state statp, bool free_addr)
       {
         if (statp->_u._ext.nssocks[ns] != -1)
           {
-            close_not_cancel_no_status (statp->_u._ext.nssocks[ns]);
+            __close_nocancel_nostatus (statp->_u._ext.nssocks[ns]);
             statp->_u._ext.nssocks[ns] = -1;
           }
         if (free_addr)
index 88c44f01543e365c4de114f168efeab7feda6b71..094492b2b4484651fa5d36bef049d04651f0ebb8 100644 (file)
@@ -81,7 +81,7 @@ pmap_getmaps (struct sockaddr_in *address)
     }
   /* We only need to close the socket here if we opened  it.  */
   if (closeit)
-    close_not_cancel (socket);
+    __close_nocancel (socket);
   address->sin_port = 0;
   return head;
 }
index df9aea640bc1dc44d0c383fdf928cb7822f4aea1..ee9988a9909e57401dab1f9adbe622009a24e414 100644 (file)
@@ -26,9 +26,9 @@
   __openat (__VA_ARGS__)
 #define __openat64_nocancel(...) \
   __openat64 (__VA_ARGS__)
-#define close_not_cancel(fd) \
+#define __close_nocancel(fd) \
   __close (fd)
-#define close_not_cancel_no_status(fd) \
+#define __close_nocancel_nostatus(fd) \
   (void) __close (fd)
 #define __read_nocancel(fd, buf, n) \
   __read (fd, buf, n)
index e7b7d77fdefa00d1ab2745b49740d217653113d5..dbde65f5dcb8cb6cfcaf0a5b8d4404e39a563a56 100644 (file)
@@ -49,6 +49,6 @@ __closedir (DIR *dirp)
 
   free ((void *) dirp);
 
-  return close_not_cancel (fd);
+  return __close_nocancel (fd);
 }
 weak_alias (__closedir, closedir)
index 09f85fc472f9e1774ee39a3670396d8fcd1cdcc6..f02bbbe533b289e77ca4010b4e3b6b903ec5117c 100644 (file)
@@ -2399,7 +2399,7 @@ getaddrinfo (const char *name, const char *service,
                {
                  if (fd != -1)
                  close_retry:
-                   close_not_cancel_no_status (fd);
+                   __close_nocancel_nostatus (fd);
                  af = q->ai_family;
                  fd = __socket (af, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_IP);
                }
@@ -2502,7 +2502,7 @@ getaddrinfo (const char *name, const char *service,
        }
 
       if (fd != -1)
-       close_not_cancel_no_status (fd);
+       __close_nocancel_nostatus (fd);
 
       /* We got all the source addresses we can get, now sort using
         the information.  */
index caa352732a93f3f1a856af27d1e06f9607bec72e..702a052306c7e414cff2d82462a3447e896abb13 100644 (file)
@@ -176,7 +176,7 @@ extern char *alloca ();
 # include <kernel-features.h>
 #else
 # define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode)
-# define close_not_cancel_no_status(fd) close (fd)
+# define __close_nocancel_nostatus(fd) close (fd)
 #endif
 
 #ifndef PATH_MAX
@@ -521,7 +521,7 @@ __getcwd (char *buf, size_t size)
   if (dirstream != NULL)
     __closedir (dirstream);
   if (fd_needs_closing)
-    close_not_cancel_no_status (fd);
+    __close_nocancel_nostatus (fd);
 #ifndef NO_ALLOCATION
   if (buf == NULL)
     free (path);
index 51a92e853cc0e8e5c58162fa82d9d26c54599504..880ebc904c34cc85f444795f10f537fed392aa30 100644 (file)
@@ -65,7 +65,7 @@ tryopen_o_directory (void)
 
   if (x >= 0)
     {
-      close_not_cancel_no_status (x);
+      __close_nocancel_nostatus (x);
       o_directory_works = -1;
     }
   else if (errno != ENOTDIR)
@@ -129,7 +129,7 @@ opendir_tail (int fd)
     {
       __set_errno (ENOTDIR);
     lose:
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       return NULL;
     }
 
@@ -227,7 +227,7 @@ __alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
          if (close_fd)
            {
              int save_errno = errno;
-             close_not_cancel_no_status (fd);
+             __close_nocancel_nostatus (fd);
              __set_errno (save_errno);
            }
          return NULL;
index b5732714ae5ff821149b02b92e9a971e64461a71..0605562ef3c6bcd71badab66258baba4828eec53 100644 (file)
@@ -157,7 +157,7 @@ __spawni_child (void *arguments)
          switch (action->tag)
            {
            case spawn_do_close:
-             if (close_not_cancel (action->action.close_action.fd) != 0)
+             if (__close_nocancel (action->action.close_action.fd) != 0)
                {
                  if (have_fdlimit == 0)
                    {
@@ -180,7 +180,7 @@ __spawni_child (void *arguments)
                   with the process already at maximum number of file descriptor
                   opened and also for multiple actions on single-open special
                   paths (like /dev/watchdog).  */
-               close_not_cancel (action->action.open_action.fd);
+               __close_nocancel (action->action.open_action.fd);
 
                int new_fd = __open_nocancel (action->action.open_action.path,
                                              action->action.open_action.oflag
@@ -197,7 +197,7 @@ __spawni_child (void *arguments)
                        != action->action.open_action.fd)
                      goto fail;
 
-                   if (close_not_cancel (new_fd) != 0)
+                   if (__close_nocancel (new_fd) != 0)
                      goto fail;
                  }
              }
index b553514c279f30c4942dcba8399adfe87278a968..6c9e06f4f997d17d0148834612a16964b1d511d1 100644 (file)
@@ -171,6 +171,7 @@ libc {
     __syscall_rt_sigqueueinfo;
     __open_nocancel;
     __read_nocancel;
+    __close_nocancel;
     # functions used by nscd
     __netlink_assert_response;
   }
index 7e5a7c9be30c05e7bfaf0b7d281054caaaed29e2..dc2da835526ba94e945295a83c8f7d9a5f465f84 100644 (file)
@@ -167,7 +167,7 @@ __check_native (uint32_t a1_index, int *a1_native,
   while (! done);
 
  out:
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return;
 
index 3bf221a177e93bf9c22c5189eba5ef05d949a13b..4dd02751444ad9d1ff90dc3ac7b2a95239a0533a 100644 (file)
@@ -328,7 +328,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
                                &addr_len) == 0)
            data = make_request (fd, nladdr.nl_pid);
 
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
        }
 
       if (data != NULL)
index 1ac71ce9806c5e20f918488a1a91f606ee1050fc..dd21d8d5fbcc9932f60cf2600ac130bb250b94b2 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <unistd.h>
 #include <sysdep-cancel.h>
+#include <not-cancel.h>
 
 /* Close the file descriptor FD.  */
 int
@@ -28,3 +29,14 @@ __close (int fd)
 libc_hidden_def (__close)
 strong_alias (__close, __libc_close)
 weak_alias (__close, close)
+
+# if !IS_IN (rtld)
+int
+__close_nocancel (int fd)
+{
+  return INLINE_SYSCALL_CALL (close, fd);
+}
+#else
+strong_alias (__libc_close, __close_nocancel)
+#endif
+libc_hidden_def (__close_nocancel)
index 775f2c2b50d3768fbf5e3125fd917420c4ecb3f2..23833f03fbc1d35bdf06f3067dde3fda02c717ab 100644 (file)
@@ -50,7 +50,7 @@ fips_enabled_p (void)
          char buf[32];
          ssize_t n;
          n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
 
          if (n > 0)
            {
index 11c7e7321b97851edb082ffc6494d2c282dda546..ca0387723873aa8c87fad12bec4a74528c6bdbc0 100644 (file)
@@ -53,7 +53,7 @@ sethostid (long int id)
 
   written = __write_nocancel (fd, &id32, sizeof (id32));
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return written != sizeof (id32) ? -1 : 0;
 }
@@ -82,7 +82,7 @@ gethostid (void)
     {
       ssize_t n = __read_nocancel (fd, &id, sizeof (id));
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
 
       if (n == sizeof (id))
        return id;
index 64bad17046cccfb0c555465ea095df92aed84172..4b75741809f02a425fb63b6864259e99a89bbb63 100644 (file)
@@ -43,7 +43,7 @@ getloadavg (double loadavg[], int nelem)
       int i;
 
       nread = __read_nocancel (fd, buf, sizeof buf - 1);
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       if (nread <= 0)
        return -1;
       buf[nread - 1] = '\0';
index 1de746b3d3206278e3f2c7209052d6e016ed14b2..45c468f5a13529d81143a1a1f6e67cb05a53ce56 100644 (file)
@@ -43,7 +43,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
   char uidbuf[12];
   ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf,
                                                   sizeof (uidbuf)));
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   uid_t uid;
   char *endp;
index d1400d6cc6ada40fb25202785690c710f2fd0ff7..d02c86d7397abfb71427289d6f6c2baafded02bf 100644 (file)
@@ -180,7 +180,7 @@ __get_nprocs (void)
          }
        while (l < re);
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
 
       if (result > 0)
        goto out;
@@ -207,7 +207,7 @@ __get_nprocs (void)
        else if (isdigit (l[3]))
          ++result;
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
     }
   else
     {
@@ -215,7 +215,7 @@ __get_nprocs (void)
       if (fd != -1)
        {
          GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result);
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
        }
     }
 
index 97c6ba79979560c210f2ae51acb6d7286a8f26ae..2030e07fa6e652aac32c775b8c6e005844c3c4eb 100644 (file)
@@ -26,7 +26,7 @@ close_all_fds (void)
            char *endp;
            long int fd = strtol (d->d_name, &endp, 10);
            if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir))
-             close_not_cancel_no_status (fd);
+             __close_nocancel_nostatus (fd);
          }
 
       __closedir (dir);
index eb1ac5ddea5f7ea8c0ce5c576001721c244d8983..320958ae98801cc9c40335cc29d7e82fe4a018d5 100644 (file)
@@ -47,7 +47,7 @@ is_smp_system (void)
        /* This also didn't work.  We give up and say it's a UP machine.  */
        u.buf[0] = '\0';
 
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       cp = u.buf;
     }
 
index 6aab1e87a69f504110ebf9b2fd50cba5ac38672e..79c95b4bd9236ca960d289dc9d5a088062cdf481 100644 (file)
@@ -41,7 +41,7 @@ has_cpuclock (void)
              || buf[0] != '0' || buf[1] != '\n')
            newval = -1;
 
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
        }
 
       itc_usable = newval;
index 8ba5eae7818b49cd77d94049696b3d569de82fe9..56f3f136cb4284c52b140bbff59c7600f09be27e 100644 (file)
@@ -47,12 +47,12 @@ __if_nametoindex (const char *ifname)
   if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
     {
       int saved_errno = errno;
-      close_not_cancel_no_status (fd);
+      __close_nocancel_nostatus (fd);
       if (saved_errno == EINVAL)
        __set_errno (ENOSYS);
       return 0;
     }
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
   return ifr.ifr_ifindex;
 #endif
 }
@@ -224,7 +224,7 @@ __if_indextoname (unsigned int ifindex, char *ifname)
   ifr.ifr_ifindex = ifindex;
   status = __ioctl (fd, SIOCGIFNAME, &ifr);
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   if (status  < 0)
     {
index c7c6a070046380481d1a152ecfefdb1cb1452cbe..4bc152145c38c169e3f00fb1da056b5e14e6995a 100644 (file)
@@ -59,7 +59,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
           while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0)
             if (__write_nocancel (fd, buf, n2) != n2)
               break;
-          close_not_cancel_no_status (fd2);
+          __close_nocancel_nostatus (fd2);
         }
     }
 }
index 7a7acbadb84db7a7ee869e55ed8f4539d5425281..4bb7bc0a1dda45ca6709ea0f178c5623eb5ec316 100644 (file)
@@ -49,7 +49,7 @@ check_may_shrink_heap (void)
          char val;
          ssize_t n = __read_nocancel (fd, &val, 1);
          may_shrink_heap = n > 0 && val == '2';
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
        }
     }
 
index 626430ccc738780a50f150ac0820893d60ebe1f0..f12e6f52c13b2603f70de3a1b822afc0efcd4ba6 100644 (file)
@@ -209,7 +209,7 @@ init_mq_netlink (void)
 
   if (err != 0)
     {
-      close_not_cancel_no_status (netlink_socket);
+      __close_nocancel_nostatus (netlink_socket);
       netlink_socket = -1;
     }
 }
index 08ad773486573e1d450d72e6ff6b2945ab68d9e3..51824515da98cd61f48694454add1acdbdfca5ab 100644 (file)
@@ -51,13 +51,16 @@ __typeof (__write) __write_nocancel;
 libc_hidden_proto (__write_nocancel)
 
 /* Uncancelable close.  */
-#define __close_nocancel(fd) \
-  INLINE_SYSCALL (close, 1, fd)
-#define close_not_cancel(fd) \
-  __close_nocancel (fd)
-#define close_not_cancel_no_status(fd) \
-  (void) ({ INTERNAL_SYSCALL_DECL (err);                                     \
-           INTERNAL_SYSCALL (close, err, 1, (fd)); })
+__typeof (__close) __close_nocancel;
+libc_hidden_proto (__close_nocancel)
+
+/* Non cancellable close syscall that does not also set errno in case of
+   failure.  */
+static inline void
+__close_nocancel_nostatus (int fd)
+{
+  __close_nocancel (fd);
+}
 
 /* Uncancelable writev.  */
 #define writev_not_cancel_no_status(fd, iov, n) \
index 93c1dfd72962f69e6d68135d5b8fe6aa8360f9b8..d3dfee03a48441fb3bdd80ce3d8b37ad499d907d 100644 (file)
@@ -63,7 +63,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len)
        buf[n] = '\0';
     }
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return res;
 }
index c5e9a339e8f9d2274f91676503f4817a94f66e0b..2f680868222f6b915a88e1966344493d52b15350 100644 (file)
@@ -57,7 +57,7 @@ pthread_setname_np (pthread_t th, const char *name)
   else if (n != name_len)
     res = EIO;
 
-  close_not_cancel_no_status (fd);
+  __close_nocancel_nostatus (fd);
 
   return res;
 }
index 4994a07491c1f995c049a1d17b8d242b54164113..dea1650d08ded5fd848f263aebebe8748e703697 100644 (file)
@@ -205,7 +205,7 @@ __spawni_child (void *arguments)
          switch (action->tag)
            {
            case spawn_do_close:
-             if (close_not_cancel (action->action.close_action.fd) != 0)
+             if (__close_nocancel (action->action.close_action.fd) != 0)
                {
                  if (!have_fdlimit)
                    {
@@ -228,7 +228,7 @@ __spawni_child (void *arguments)
                   with the process already at maximum number of file descriptor
                   opened and also for multiple actions on single-open special
                   paths (like /dev/watchdog).  */
-               close_not_cancel (action->action.open_action.fd);
+               __close_nocancel (action->action.open_action.fd);
 
                int ret = __open_nocancel (action->action.open_action.path,
                                           action->action.
@@ -247,7 +247,7 @@ __spawni_child (void *arguments)
                        != action->action.open_action.fd)
                      goto fail;
 
-                   if (close_not_cancel (new_fd) != 0)
+                   if (__close_nocancel (new_fd) != 0)
                      goto fail;
                  }
              }
index f9becfbb33fd63f0565c29b0c2dda9805d858bab..773a6acfd43462e2726dded5785de3ac2bad2817 100644 (file)
@@ -122,7 +122,7 @@ __sysconf (int name)
          char buf[32];
          ssize_t n;
          n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
-         close_not_cancel_no_status (fd);
+         __close_nocancel_nostatus (fd);
 
          if (n > 0)
            {