You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by jo...@apache.org on 2015/06/04 13:23:26 UTC
svn commit: r1683520 - in /apr/apr/trunk: CHANGES configure.in
file_io/unix/mktemp.c
Author: jorton
Date: Thu Jun 4 11:23:26 2015
New Revision: 1683520
URL: http://svn.apache.org/r1683520
Log:
* configure.in: Detect mkostemp, mkostemp64.
* file_io/unix/mktemp.c (apr_file_mktemp): Use glibc mkostemp or
mkostemp64 where available to set FD_CLOEXEC without the extra
system calls.
Modified:
apr/apr/trunk/CHANGES
apr/apr/trunk/configure.in
apr/apr/trunk/file_io/unix/mktemp.c
Modified: apr/apr/trunk/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1683520&r1=1683519&r2=1683520&view=diff
==============================================================================
--- apr/apr/trunk/CHANGES [utf-8] (original)
+++ apr/apr/trunk/CHANGES [utf-8] Thu Jun 4 11:23:26 2015
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes for APR 2.0.0
+ *) apr_file_mktemp: Use mkostemp() where available to save on system
+ calls. [Joe Orton]
+
*) apr_pools: Fix pool debugging output so that creation events are
always emitted before allocation events and subpool destruction
events are emitted on pool clear/destroy for proper accounting.
Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?rev=1683520&r1=1683519&r2=1683520&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Thu Jun 4 11:23:26 2015
@@ -1331,7 +1331,7 @@ case $host in
dnl mkstemp is limited to 26 temporary files (a-z); use APR replacement
;;
*)
- AC_CHECK_FUNCS(mkstemp)
+ AC_CHECK_FUNCS(mkstemp mkostemp)
;;
esac
@@ -1781,7 +1781,7 @@ if test "${ac_cv_sizeof_off_t}${apr_cv_u
dnl mkstemp64 is limited to 26 temporary files (a-z); use APR replacement
;;
*)
- AC_CHECK_FUNCS(mkstemp64)
+ AC_CHECK_FUNCS(mkstemp64 mkostemp64)
;;
esac
elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then
Modified: apr/apr/trunk/file_io/unix/mktemp.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/file_io/unix/mktemp.c?rev=1683520&r1=1683519&r2=1683520&view=diff
==============================================================================
--- apr/apr/trunk/file_io/unix/mktemp.c (original)
+++ apr/apr/trunk/file_io/unix/mktemp.c Thu Jun 4 11:23:26 2015
@@ -173,6 +173,16 @@ static int gettemp(char *path, apr_file_
#endif
#endif /* !defined(HAVE_MKSTEMP) */
+#if defined(HAVE_MKOSTEMP64)
+#define wrap_mkostemp(t, f) mkostemp64(t, (f))
+#elif defined(HAVE_MKOSTEMP)
+#define wrap_mkostemp(t, f) mkostemp(t, (f))
+#elif defined(HAVE_MKSTEMP64)
+#define wrap_mkostemp(t, f) mkstemp64(t)
+#else
+#define wrap_mkostemp(t, f) mkstemp(t)
+#endif
+
APR_DECLARE(apr_status_t) apr_file_mktemp(apr_file_t **fp, char *template, apr_int32_t flags, apr_pool_t *p)
{
#ifdef HAVE_MKSTEMP
@@ -184,12 +194,8 @@ APR_DECLARE(apr_status_t) apr_file_mktem
return gettemp(template, fp, flags, p);
#else
-#ifdef HAVE_MKSTEMP64
- fd = mkstemp64(template);
-#else
- fd = mkstemp(template);
-#endif
-
+ fd = wrap_mkostemp(template,
+ (flags & APR_FOPEN_NOCLEANUP) ? 0 : O_CLOEXEC);
if (fd == -1) {
return errno;
}
@@ -204,6 +210,7 @@ APR_DECLARE(apr_status_t) apr_file_mktem
(*fp)->fname = apr_pstrdup(p, template);
if (!(flags & APR_FOPEN_NOCLEANUP)) {
+#if !defined(HAVE_MKOSTEMP64) && !defined(HAVE_MKOSTEMP)
int flags;
if ((flags = fcntl(fd, F_GETFD)) == -1)
@@ -212,6 +219,7 @@ APR_DECLARE(apr_status_t) apr_file_mktem
flags |= FD_CLOEXEC;
if (fcntl(fd, F_SETFD, flags) == -1)
return errno;
+#endif
apr_pool_cleanup_register((*fp)->pool, (void *)(*fp),
apr_unix_file_cleanup,