[apr] 01/01: Upstream tarball 1.5.1
Stefan Fritsch
sf at moszumanska.debian.org
Thu May 1 08:32:29 UTC 2014
This is an automated email from the git hooks/post-receive script.
sf pushed a commit to branch upstream
in repository apr.
commit 7b14536d55750881336d13c4318c42d7ff0bb716
Author: Stefan Fritsch <sf at sfritsch.de>
Date: Thu May 1 10:30:09 2014 +0200
Upstream tarball 1.5.1
---
CHANGES | 43 +++++++-
CMakeLists.txt | 10 +-
Makefile.in | 7 +-
NOTICE | 4 +-
README.cmake | 2 +
apr.spec | 2 +-
build-outputs.mk | 2 +-
build/config.guess | 184 +++++----------------------------
build/config.sub | 6 +-
configure | 19 ++++
configure.in | 7 ++
docs/canonical_filenames.html | 6 +-
encoding/apr_escape.c | 45 ++++++--
file_io/unix/mktemp.c | 2 +-
file_io/win32/dir.c | 41 ++++----
file_io/win32/open.c | 2 +-
file_io/win32/pipe.c | 2 +-
include/apr_escape.h | 26 ++---
include/apr_file_info.h | 2 +-
include/apr_file_io.h | 2 -
include/apr_fnmatch.h | 18 ++--
include/apr_lib.h | 26 ++---
include/apr_network_io.h | 2 +
include/apr_poll.h | 10 +-
include/apr_skiplist.h | 203 ++++++++++++++++++++++++++++++++++---
include/apr_strings.h | 8 +-
include/apr_thread_mutex.h | 2 +-
include/apr_time.h | 36 +++----
include/apr_version.h | 4 +-
include/arch/netware/apr_private.h | 2 +-
locks/unix/proc_mutex.c | 11 +-
network_io/unix/socket_util.c | 3 +-
network_io/unix/sockets.c | 15 ++-
shmem/unix/shm.c | 101 ++++++++++++++++--
test/sockchild.c | 8 +-
test/testatomic.c | 12 +++
test/testdir.c | 135 ++++++++++++++++++++++++
test/testescape.c | 2 +
test/testmmap.c | 22 ++--
test/testsock.c | 55 +++++++++-
40 files changed, 785 insertions(+), 304 deletions(-)
diff --git a/CHANGES b/CHANGES
index 15cefbc..d04ad11 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,45 @@
-*- coding: utf-8 -*-
+Changes for APR 1.5.1
+
+ *) apr_os_proc_mutex_get() on Unix: Avoid segfault for cross-
+ process pthread mutexes. [Yann Ylavic <ylavic.dev gmail.com>]
+
+ *) When using shmget-based shared memory, the ID used for ftok is
+ now an APR hash of the filename instead of the constant '1'.
+ We do this to help avoid collisions. PR 53996 [Jim Jagielski]
+
+ *) apr_socket_atreadeof(): Fix breakage on OS X. [Jim Jagielski]
+
+ *) Fix POSIX shared memory (shm_open) use for named shared memory.
+ Includes adding '--enable-posix-shm' to force POSIX shm if
+ available, and OS X compatibility. PR 55928.
+ [Jozef Hatala <jh-asf skrt org>, Jim Jagielski]
+
+ *) Fix race condition when calling apr_dir_make_recursive from
+ multiple threads on Windows.
+ [Bert Huijben]
+
+ *) Fix apr_escape.c compilation errors on EBCDIC platforms.
+ [Eric Covener]
+
+ *) FreeBSD 10: Correct a regression in 1.5.0 which affected non-
+ blocking sockets in some applications, including httpd. [Jeff
+ Trawick]
+
+ *) Windows cmake build: Fix incorrect installation of some .pdb
+ files. Fix incorrect use of some logic intended for Windows 9x,
+ including legacy filesystem interfaces and dynamic loading of
+ some Windows APIs. [Jeff Trawick]
+
+ *) apr_skiplist: Add compatibility with C++ applications.
+ [Jeff Trawick]
+
+ *) Correct a regression in 1.5.0 which affected out-of-tree
+ builds on Unix. [Rainer Jung]
+
+ *) Improve platform detection for bundled expat by updating
+ config.guess and config.sub. [Rainer Jung]
+
Changes for APR 1.5.0
*) Fix Linux kernel version check to recognize more versions,
@@ -9,7 +50,7 @@ Changes for APR 1.5.0
refers to the wildcard address for the protocol family (e.g.,
0.0.0.0/INADDR_ANY for IPv4). [Jeff Trawick]
- *) apr_file_dup2() on Windows: Fix debug RTL assertion in when
+ *) apr_file_dup2() on Windows: Fix debug RTL assertion when
attempting to _commit(stdout) or _commit(stderr). [Mike Rumph
<mike.rumph oracle.com>]
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35a5665..04903f9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,26 +259,26 @@ ADD_LIBRARY(libapr-1 SHARED ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED} libap
SET(install_targets ${install_targets} libapr-1)
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libapr-1.pdb)
TARGET_LINK_LIBRARIES(libapr-1 ${APR_SYSTEM_LIBS})
-SET_TARGET_PROPERTIES(libapr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_EXPORT")
+SET_TARGET_PROPERTIES(libapr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_EXPORT;WINNT")
ADD_DEPENDENCIES(libapr-1 test_char_header)
ADD_LIBRARY(apr-1 STATIC ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} apr-1)
SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/apr-1.pdb)
TARGET_LINK_LIBRARIES(apr-1 ${APR_SYSTEM_LIBS})
-SET_TARGET_PROPERTIES(apr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC")
+SET_TARGET_PROPERTIES(apr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;WINNT")
ADD_DEPENDENCIES(apr-1 test_char_header)
# libaprapp-1 and aprapp-1 are static
ADD_LIBRARY(libaprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} libaprapp-1)
-SET(install_lib_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libaprapp-1.pdb)
-SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS APR_APP)
+SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/libaprapp-1.pdb)
+SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_APP;WINNT")
ADD_LIBRARY(aprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} aprapp-1)
SET(install_lib_pdb ${install_lib_pdb} ${PROJECT_BINARY_DIR}/aprapp-1.pdb)
-SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP")
+SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP;WINNT")
IF(APR_BUILD_TESTAPR)
ENABLE_TESTING()
diff --git a/Makefile.in b/Makefile.in
index 2ccaaf3..6f99733 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,7 +18,7 @@ APR_MAJOR_VERSION=@APR_MAJOR_VERSION@
INCDIR=./include
OSDIR=$(top_srcdir)/include/arch/@OSDIR@
DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
-INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR) -I$(top_srcdir)/include/arch/@DEFAULT_OSDIR@ -I$(top_srcdir)/include -I$(top_srcdir)/include/private
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR) -I$(top_srcdir)/include/arch/@DEFAULT_OSDIR@ -I$(top_srcdir)/include -I$(top_srcdir)/include/private -I$(top_blddir)/include/private
#
# Macros for target determination
@@ -129,11 +129,16 @@ check: $(TARGET_LIB)
etags:
etags `find . -name '*.[ch]'`
+make_tools_dir:
+ $(APR_MKDIR) tools
+
OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
+tools/gen_test_char.lo: make_tools_dir
tools/gen_test_char at EXEEXT@: $(OBJECTS_gen_test_char)
$(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS)
include/private/apr_escape_test_char.h: tools/gen_test_char at EXEEXT@
+ $(APR_MKDIR) include/private
tools/gen_test_char at EXEEXT@ > $@
LINK_PROG = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) $(LT_LDFLAGS) \
diff --git a/NOTICE b/NOTICE
index 6643ee6..b16965b 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,7 +1,7 @@
Apache Portable Runtime
-Copyright (c) 2011 The Apache Software Foundation.
+Copyright (c) 2000-2014 The Apache Software Foundation.
-This product includes software developed by
+This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Portions of this software were developed at the National Center
diff --git a/README.cmake b/README.cmake
index 42c99c1..cfff8ca 100644
--- a/README.cmake
+++ b/README.cmake
@@ -4,6 +4,8 @@ Status
------
This build support is currently intended only for Microsoft Windows.
+Only Windows NT-based systems can be targeted. (The traditional
+Windows build support for APR can target Windows 9x as well.)
This build support is experimental. Specifically,
diff --git a/apr.spec b/apr.spec
index 09b1858..b3db167 100644
--- a/apr.spec
+++ b/apr.spec
@@ -3,7 +3,7 @@
Summary: Apache Portable Runtime library
Name: apr
-Version: 1.5.0
+Version: 1.5.1
Release: 1
License: Apache Software License
Group: System Environment/Libraries
diff --git a/build-outputs.mk b/build-outputs.mk
index f25ec81..526f179 100644
--- a/build-outputs.mk
+++ b/build-outputs.mk
@@ -93,7 +93,7 @@ random/unix/sha2_glue.lo: random/unix/sha2_glue.c .make.dirs include/apr_allocat
OBJECTS_random_unix = random/unix/apr_random.lo random/unix/sha2.lo random/unix/sha2_glue.lo
-shmem/unix/shm.lo: shmem/unix/shm.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_user.h include/apr_want.h
+shmem/unix/shm.lo: shmem/unix/shm.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_general.h include/apr_hash.h include/apr_pools.h include/apr_strings.h include/apr_thread_mutex.h include/apr_user.h include/apr_want.h
OBJECTS_shmem_unix = shmem/unix/shm.lo
diff --git a/build/config.guess b/build/config.guess
index b79252d..72625d4 100755
--- a/build/config.guess
+++ b/build/config.guess
@@ -1,8 +1,8 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright 1992-2014 Free Software Foundation, Inc.
-timestamp='2013-06-10'
+timestamp='2014-02-12'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -149,7 +149,7 @@ Linux|GNU|GNU/*)
LIBC=gnu
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
;;
esac
@@ -1260,16 +1260,26 @@ EOF
if test "$UNAME_PROCESSOR" = unknown ; then
UNAME_PROCESSOR=powerpc
fi
- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
- grep IS_64BIT_ARCH >/dev/null
- then
- case $UNAME_PROCESSOR in
- i386) UNAME_PROCESSOR=x86_64 ;;
- powerpc) UNAME_PROCESSOR=powerpc64 ;;
- esac
+ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+ grep IS_64BIT_ARCH >/dev/null
+ then
+ case $UNAME_PROCESSOR in
+ i386) UNAME_PROCESSOR=x86_64 ;;
+ powerpc) UNAME_PROCESSOR=powerpc64 ;;
+ esac
+ fi
fi
+ elif test "$UNAME_PROCESSOR" = i386 ; then
+ # Avoid executing cc on OS X 10.9, as it ships with a stub
+ # that puts up a graphical alert prompting to install
+ # developer tools. Any system running Mac OS X 10.7 or
+ # later (Darwin 11 and later) is required to have a 64-bit
+ # processor. This is not true of the ARM version of Darwin
+ # that Apple uses in portable devices.
+ UNAME_PROCESSOR=x86_64
fi
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
exit ;;
@@ -1361,154 +1371,6 @@ EOF
exit ;;
esac
-eval $set_cc_for_build
-cat >$dummy.c <<EOF
-#ifdef _SEQUENT_
-# include <sys/types.h>
-# include <sys/utsname.h>
-#endif
-main ()
-{
-#if defined (sony)
-#if defined (MIPSEB)
- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
- I don't know.... */
- printf ("mips-sony-bsd\n"); exit (0);
-#else
-#include <sys/param.h>
- printf ("m68k-sony-newsos%s\n",
-#ifdef NEWSOS4
- "4"
-#else
- ""
-#endif
- ); exit (0);
-#endif
-#endif
-
-#if defined (__arm) && defined (__acorn) && defined (__unix)
- printf ("arm-acorn-riscix\n"); exit (0);
-#endif
-
-#if defined (hp300) && !defined (hpux)
- printf ("m68k-hp-bsd\n"); exit (0);
-#endif
-
-#if defined (NeXT)
-#if !defined (__ARCHITECTURE__)
-#define __ARCHITECTURE__ "m68k"
-#endif
- int version;
- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
- if (version < 4)
- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
- else
- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
- exit (0);
-#endif
-
-#if defined (MULTIMAX) || defined (n16)
-#if defined (UMAXV)
- printf ("ns32k-encore-sysv\n"); exit (0);
-#else
-#if defined (CMU)
- printf ("ns32k-encore-mach\n"); exit (0);
-#else
- printf ("ns32k-encore-bsd\n"); exit (0);
-#endif
-#endif
-#endif
-
-#if defined (__386BSD__)
- printf ("i386-pc-bsd\n"); exit (0);
-#endif
-
-#if defined (sequent)
-#if defined (i386)
- printf ("i386-sequent-dynix\n"); exit (0);
-#endif
-#if defined (ns32000)
- printf ("ns32k-sequent-dynix\n"); exit (0);
-#endif
-#endif
-
-#if defined (_SEQUENT_)
- struct utsname un;
-
- uname(&un);
-
- if (strncmp(un.version, "V2", 2) == 0) {
- printf ("i386-sequent-ptx2\n"); exit (0);
- }
- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
- printf ("i386-sequent-ptx1\n"); exit (0);
- }
- printf ("i386-sequent-ptx\n"); exit (0);
-
-#endif
-
-#if defined (vax)
-# if !defined (ultrix)
-# include <sys/param.h>
-# if defined (BSD)
-# if BSD == 43
- printf ("vax-dec-bsd4.3\n"); exit (0);
-# else
-# if BSD == 199006
- printf ("vax-dec-bsd4.3reno\n"); exit (0);
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# endif
-# else
- printf ("vax-dec-bsd\n"); exit (0);
-# endif
-# else
- printf ("vax-dec-ultrix\n"); exit (0);
-# endif
-#endif
-
-#if defined (alliant) && defined (i860)
- printf ("i860-alliant-bsd\n"); exit (0);
-#endif
-
- exit (1);
-}
-EOF
-
-$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
- { echo "$SYSTEM_NAME"; exit; }
-
-# Apollos put the system type in the environment.
-
-test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
-
-# Convex versions that predate uname can use getsysinfo(1)
-
-if [ -x /usr/convex/getsysinfo ]
-then
- case `getsysinfo -f cpu_type` in
- c1*)
- echo c1-convex-bsd
- exit ;;
- c2*)
- if getsysinfo -f scalar_acc
- then echo c32-convex-bsd
- else echo c2-convex-bsd
- fi
- exit ;;
- c34*)
- echo c34-convex-bsd
- exit ;;
- c38*)
- echo c38-convex-bsd
- exit ;;
- c4*)
- echo c4-convex-bsd
- exit ;;
- esac
-fi
-
cat >&2 <<EOF
$0: unable to guess system type
diff --git a/build/config.sub b/build/config.sub
index 61cb4bc..092cff0 100755
--- a/build/config.sub
+++ b/build/config.sub
@@ -1,8 +1,8 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2013 Free Software Foundation, Inc.
+# Copyright 1992-2014 Free Software Foundation, Inc.
-timestamp='2013-10-01'
+timestamp='2014-01-01'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
@@ -68,7 +68,7 @@ Report bugs and patches to <config-patches at gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2013 Free Software Foundation, Inc.
+Copyright 1992-2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
diff --git a/configure b/configure
index 0b5b83a..860c65b 100755
--- a/configure
+++ b/configure
@@ -920,6 +920,7 @@ enable_lfs
enable_nonportable_atomics
enable_threads
with_efence
+enable_posix_shm
with_sendfile
enable_allocator_uses_mmap
enable_dso
@@ -1564,6 +1565,7 @@ Optional Features:
--disable-lfs Disable large file support on 32-bit platforms
--enable-nonportable-atomics Use optimized atomic code which may produce nonportable binaries
--enable-threads Enable threading support in APR.
+ --enable-posix-shm Use POSIX shared memory (shm_open) if available
--enable-allocator-uses-mmap Use mmap in apr_allocator instead of malloc
--disable-dso Disable DSO support
--enable-other-child Enable reliable child processes
@@ -21572,6 +21574,23 @@ else
fi
+# Check whether --enable-posix-shm was given.
+if test "${enable_posix_shm+set}" = set; then :
+ enableval=$enable_posix_shm;
+if test "$havemmapshm" = "1"; then
+ ac_decision=''
+ for ac_item in USE_SHMEM_MMAP_SHM; do
+ eval "ac_decision_this=\$ac_decision_${ac_item}"
+ if test ".$ac_decision_this" = .yes; then
+ ac_decision=$ac_item
+ eval "ac_decision_msg=\$ac_decision_${ac_item}_msg"
+ fi
+ done
+
+fi
+
+fi
+
case $host in
*linux* )
# Linux pre-2.4 had problems with MM_SHMT_MMANON even though
diff --git a/configure.in b/configure.in
index 56ccc19..2a37a30 100644
--- a/configure.in
+++ b/configure.in
@@ -1256,6 +1256,13 @@ APR_IFALLYES(header:os2.h,
APR_IFALLYES(header:windows.h,
[havewin32shm="1"
APR_DECIDE(USE_SHMEM_WIN32, [Windows shared memory])])
+AC_ARG_ENABLE(posix-shm,
+[ --enable-posix-shm Use POSIX shared memory (shm_open) if available],
+[
+if test "$havemmapshm" = "1"; then
+ APR_DECISION_OVERRIDE(USE_SHMEM_MMAP_SHM)
+fi
+])
case $host in
*linux* )
# Linux pre-2.4 had problems with MM_SHMT_MMANON even though
diff --git a/docs/canonical_filenames.html b/docs/canonical_filenames.html
index 10867d3..2bd9bdb 100644
--- a/docs/canonical_filenames.html
+++ b/docs/canonical_filenames.html
@@ -104,9 +104,9 @@ used as the parent to create child entries to reduce the number of expensive
stat and case canonicalization calls to the OS.</p>
<p>The comparison operation provides that the APR can postpone correction
-of case by simply relying upon the device and inode for equivilance. The
+of case by simply relying upon the device and inode for equivalence. The
stat implementation provides that two files are the same, while their
-strings are not equivilant, and eliminates the need for the operating
+strings are not equivalent, and eliminates the need for the operating
system to return the proper form of the name.</p>
<p>In any case, returning the char* path, with a flag to request the proper
@@ -153,4 +153,4 @@ For each of this path Segments
</pre>
</BODY>
-</HTML>
\ No newline at end of file
+</HTML>
diff --git a/encoding/apr_escape.c b/encoding/apr_escape.c
index 8bb403c..2bcfec4 100644
--- a/encoding/apr_escape.c
+++ b/encoding/apr_escape.c
@@ -30,11 +30,43 @@
#include "apr_lib.h"
#include "apr_strings.h"
-/* helper for Latin1 <-> entity encoding */
#if APR_CHARSET_EBCDIC
-#include "apr_xlate.h"
-#define RAW_ASCII_CHAR(ch) apr_xlate_conv_byte(ap_hdrs_from_ascii, \
- (unsigned char)ch)
+static int convert_a2e[256] = {
+ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2D, 0x2E, 0x2F, 0x16, 0x05, 0x15, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x3C, 0x3D, 0x32, 0x26, 0x18, 0x19, 0x3F, 0x27, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61,
+ 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F,
+ 0x7C, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6,
+ 0xD7, 0xD8, 0xD9, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D,
+ 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96,
+ 0x97, 0x98, 0x99, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xC0, 0x4F, 0xD0, 0xA1, 0x07,
+ 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x06, 0x17, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x09, 0x0A, 0x1B,
+ 0x30, 0x31, 0x1A, 0x33, 0x34, 0x35, 0x36, 0x08, 0x38, 0x39, 0x3A, 0x3B, 0x04, 0x14, 0x3E, 0xFF,
+ 0x41, 0xAA, 0x4A, 0xB1, 0x9F, 0xB2, 0x6A, 0xB5, 0xBB, 0xB4, 0x9A, 0x8A, 0xB0, 0xCA, 0xAF, 0xBC,
+ 0x90, 0x8F, 0xEA, 0xFA, 0xBE, 0xA0, 0xB6, 0xB3, 0x9D, 0xDA, 0x9B, 0x8B, 0xB7, 0xB8, 0xB9, 0xAB,
+ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9E, 0x68, 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77,
+ 0xAC, 0x69, 0xED, 0xEE, 0xEB, 0xEF, 0xEC, 0xBF, 0x80, 0xFD, 0xFE, 0xFB, 0xFC, 0xBA, 0xAE, 0x59,
+ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9C, 0x48, 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57,
+ 0x8C, 0x49, 0xCD, 0xCE, 0xCB, 0xCF, 0xCC, 0xE1, 0x70, 0xDD, 0xDE, 0xDB, 0xDC, 0x8D, 0x8E, 0xDF };
+
+static int convert_e2a[256] = {
+ 0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F, 0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
+ 0x10, 0x11, 0x12, 0x13, 0x9D, 0x0A, 0x08, 0x87, 0x18, 0x19, 0x92, 0x8F, 0x1C, 0x1D, 0x1E, 0x1F,
+ 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x17, 0x1B, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x05, 0x06, 0x07,
+ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, 0x98, 0x99, 0x9A, 0x9B, 0x14, 0x15, 0x9E, 0x1A,
+ 0x20, 0xA0, 0xE2, 0xE4, 0xE0, 0xE1, 0xE3, 0xE5, 0xE7, 0xF1, 0xA2, 0x2E, 0x3C, 0x28, 0x2B, 0x7C,
+ 0x26, 0xE9, 0xEA, 0xEB, 0xE8, 0xED, 0xEE, 0xEF, 0xEC, 0xDF, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E,
+ 0x2D, 0x2F, 0xC2, 0xC4, 0xC0, 0xC1, 0xC3, 0xC5, 0xC7, 0xD1, 0xA6, 0x2C, 0x25, 0x5F, 0x3E, 0x3F,
+ 0xF8, 0xC9, 0xCA, 0xCB, 0xC8, 0xCD, 0xCE, 0xCF, 0xCC, 0x60, 0x3A, 0x23, 0x40, 0x27, 0x3D, 0x22,
+ 0xD8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0xAB, 0xBB, 0xF0, 0xFD, 0xFE, 0xB1,
+ 0xB0, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0xAA, 0xBA, 0xE6, 0xB8, 0xC6, 0xA4,
+ 0xB5, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0xBF, 0xD0, 0x5B, 0xDE, 0xAE,
+ 0xAC, 0xA3, 0xA5, 0xB7, 0xA9, 0xA7, 0xB6, 0xBC, 0xBD, 0xBE, 0xDD, 0xA8, 0xAF, 0x5D, 0xB4, 0xD7,
+ 0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0xAD, 0xF4, 0xF6, 0xF2, 0xF3, 0xF5,
+ 0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0xB9, 0xFB, 0xFC, 0xF9, 0xFA, 0xFF,
+ 0x5C, 0xF7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0xB2, 0xD4, 0xD6, 0xD2, 0xD3, 0xD5,
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0xB3, 0xDB, 0xDC, 0xD9, 0xDA, 0x9F };
+#define RAW_ASCII_CHAR(ch) convert_e2a[(unsigned char)ch]
#else /* APR_CHARSET_EBCDIC */
#define RAW_ASCII_CHAR(ch) (ch)
#endif /* !APR_CHARSET_EBCDIC */
@@ -139,8 +171,7 @@ static char x2c(const char *what)
xstr[2]=what[0];
xstr[3]=what[1];
xstr[4]='\0';
- digit = apr_xlate_conv_byte(ap_hdrs_from_ascii,
- 0xFF & strtol(xstr, NULL, 16));
+ digit = convert_a2e[0xFF & strtol(xstr, NULL, 16)];
#endif /*APR_CHARSET_EBCDIC*/
return (digit);
}
@@ -299,7 +330,7 @@ static APR_INLINE unsigned char *c2x(unsigned what, unsigned char prefix,
unsigned char *where)
{
#if APR_CHARSET_EBCDIC
- what = apr_xlate_conv_byte(ap_hdrs_to_ascii, (unsigned char)what);
+ what = convert_e2a[(unsigned char)what];
#endif /*APR_CHARSET_EBCDIC*/
*where++ = prefix;
*where++ = c2x_table[what >> 4];
diff --git a/file_io/unix/mktemp.c b/file_io/unix/mktemp.c
index 28aaf90..7530a25 100644
--- a/file_io/unix/mktemp.c
+++ b/file_io/unix/mktemp.c
@@ -74,7 +74,7 @@
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#if APR_HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#if APR_HAVE_FCNTL_H
diff --git a/file_io/win32/dir.c b/file_io/win32/dir.c
index f6eeb87..5c30af8 100644
--- a/file_io/win32/dir.c
+++ b/file_io/win32/dir.c
@@ -316,8 +316,8 @@ static apr_status_t dir_make_parent(char *path,
if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */
rv = dir_make_parent(path, perm, pool);
- if (rv == APR_SUCCESS) {
- rv = apr_dir_make (path, perm, pool); /* And complete the path */
+ if (rv == APR_SUCCESS || APR_STATUS_IS_EEXIST(rv)) {
+ rv = apr_dir_make(path, perm, pool); /* And complete the path */
}
}
@@ -330,28 +330,35 @@ APR_DECLARE(apr_status_t) apr_dir_make_recursive(const char *path,
apr_pool_t *pool)
{
apr_status_t rv = 0;
-
+
rv = apr_dir_make (path, perm, pool); /* Try to make PATH right out */
-
+
if (APR_STATUS_IS_ENOENT(rv)) { /* Missing an intermediate dir */
char *dir;
-
+
rv = apr_filepath_merge(&dir, "", path, APR_FILEPATH_NATIVE, pool);
- if (rv == APR_SUCCESS)
- rv = dir_make_parent(dir, perm, pool); /* Make intermediate dirs */
-
- if (rv == APR_SUCCESS)
+ if (rv != APR_SUCCESS)
+ return rv;
+
+ rv = dir_make_parent(dir, perm, pool); /* Make intermediate dirs */
+
+ if (rv == APR_SUCCESS || APR_STATUS_IS_EEXIST(rv)) {
rv = apr_dir_make (dir, perm, pool); /* And complete the path */
- }
- /*
- * It's OK if PATH exists. Timing issues can lead to the second
- * apr_dir_make being called on existing dir, therefore this check
- * has to come last.
- */
- if (APR_STATUS_IS_EEXIST(rv))
- return APR_SUCCESS;
+ if (APR_STATUS_IS_EEXIST(rv)) {
+ rv = APR_SUCCESS; /* Timing issue; see comment below */
+ }
+ }
+ }
+ else if (APR_STATUS_IS_EEXIST(rv)) {
+ /*
+ * It's OK if PATH exists. Timing issues can lead to the
+ * second apr_dir_make being called on existing dir, therefore
+ * this check has to come last.
+ */
+ rv = APR_SUCCESS;
+ }
return rv;
}
diff --git a/file_io/win32/open.c b/file_io/win32/open.c
index b668645..3c00bfc 100644
--- a/file_io/win32/open.c
+++ b/file_io/win32/open.c
@@ -26,7 +26,7 @@
#endif
#include <winbase.h>
#include <string.h>
-#if APR_HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include "apr_arch_misc.h"
diff --git a/file_io/win32/pipe.c b/file_io/win32/pipe.c
index 79138e7..f240eba 100644
--- a/file_io/win32/pipe.c
+++ b/file_io/win32/pipe.c
@@ -26,7 +26,7 @@
#if APR_HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
-#if APR_HAVE_SYS_STAT_H
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#if APR_HAVE_PROCESS_H
diff --git a/include/apr_escape.h b/include/apr_escape.h
index bf9b1b6..5b60ac6 100644
--- a/include/apr_escape.h
+++ b/include/apr_escape.h
@@ -72,7 +72,7 @@ APR_DECLARE(apr_status_t) apr_escape_shell(char *escaped, const char *str,
APR_DECLARE(const char *) apr_pescape_shell(apr_pool_t *p, const char *str)
__attribute__((nonnull(1)));
-/*
+/**
* Unescapes a URL, leaving reserved characters intact.
* @param escaped Optional buffer to write the encoded string, can be
* NULL
@@ -93,7 +93,7 @@ APR_DECLARE(apr_status_t) apr_unescape_url(char *escaped, const char *url,
apr_ssize_t slen, const char *forbid, const char *reserved, int plus,
apr_size_t *len);
-/*
+/**
* Unescapes a URL, leaving reserved characters intact, returning the
* result from a pool.
* @param p Pool to allocate from
@@ -212,7 +212,7 @@ APR_DECLARE(const char *) apr_pescape_urlencoded(apr_pool_t *p,
* double quote becomes '"" and the single quote becomes '''.
*
* If toasc is not zero, any non ascii character will be encoded as
- * '%#ddd;', where ddd is the decimal code of the character.
+ * '%\#ddd;', where ddd is the decimal code of the character.
* @param escaped Optional buffer to write the encoded string, can be
* NULL
* @param str The original string
@@ -239,14 +239,14 @@ APR_DECLARE(apr_status_t) apr_escape_entity(char *escaped, const char *str,
APR_DECLARE(const char *) apr_pescape_entity(apr_pool_t *p, const char *str,
int toasc) __attribute__((nonnull(1)));
-/*
+/**
* Decodes html entities or numeric character references in a string. If
* the string to be unescaped is syntactically incorrect, then the
* following fixups will be made:
* unknown entities will be left undecoded;
* references to unused numeric characters will be deleted.
* In particular, will not be decoded, but will be deleted.
- * @param escaped Optional buffer to write the encoded string, can be
+ * @param unescaped Optional buffer to write the encoded string, can be
* NULL
* @param str The original string
* @param slen The length of the original string, or APR_ESCAPE_STRING
@@ -257,7 +257,7 @@ APR_DECLARE(const char *) apr_pescape_entity(apr_pool_t *p, const char *str,
APR_DECLARE(apr_status_t) apr_unescape_entity(char *unescaped, const char *str,
apr_ssize_t slen, apr_size_t *len);
-/*
+/**
* Decodes html entities or numeric character references in a string. If
* the string to be unescaped is syntactically incorrect, then the
* following fixups will be made:
@@ -275,10 +275,10 @@ APR_DECLARE(const char *) apr_punescape_entity(apr_pool_t *p, const char *str)
/**
* Escape control characters in a string, as performed by the shell's
* 'echo' command. Characters are replaced as follows:
- * \a alert (bell), \b backspace, \f form feed, \n new line, \r carriage
- * return, \t horizontal tab, \v vertical tab, \\ backslash.
+ * \\a alert (bell), \\b backspace, \\f form feed, \\n new line, \\r carriage
+ * return, \\t horizontal tab, \\v vertical tab, \\ backslash.
*
- * Any non ascii character will be encoded as '\xHH', where HH is the hex
+ * Any non ascii character will be encoded as '\\xHH', where HH is the hex
* code of the character.
*
* If quote is not zero, the double quote character will also be escaped.
@@ -297,11 +297,11 @@ APR_DECLARE(apr_status_t) apr_escape_echo(char *escaped, const char *str,
/**
* Escape control characters in a string, as performed by the shell's
* 'echo' command, and return the results from a pool. Characters are
- * replaced as follows: \a alert (bell), \b backspace, \f form feed,
- * \n new line, \r carriage return, \t horizontal tab, \v vertical tab,
+ * replaced as follows: \\a alert (bell), \\b backspace, \\f form feed,
+ * \\n new line, \\r carriage return, \\t horizontal tab, \\v vertical tab,
* \\ backslash.
*
- * Any non ascii character will be encoded as '\xHH', where HH is the hex
+ * Any non ascii character will be encoded as '\\xHH', where HH is the hex
* code of the character.
*
* If quote is not zero, the double quote character will also be escaped.
@@ -342,7 +342,7 @@ APR_DECLARE(const char *) apr_pescape_hex(apr_pool_t *p, const void *src,
/**
* Convert hex encoded string to binary data.
* @param dest The destination buffer, can be NULL
- * @param src The original buffer
+ * @param str The original buffer
* @param slen The length of the original buffer
* @param colon If not zero, ignore colon characters between hex digits.
* @param len If present, returns the length of the string
diff --git a/include/apr_file_info.h b/include/apr_file_info.h
index b3006ac..1d19eb6 100644
--- a/include/apr_file_info.h
+++ b/include/apr_file_info.h
@@ -208,7 +208,7 @@ struct apr_finfo_t {
const char *fname;
/** The file's name (no path) in filesystem case */
const char *name;
- /** The file's handle, if accessed (can be submitted to apr_duphandle) */
+ /** Unused */
struct apr_file_t *filehand;
};
diff --git a/include/apr_file_io.h b/include/apr_file_io.h
index 65a62af..eb683af 100644
--- a/include/apr_file_io.h
+++ b/include/apr_file_io.h
@@ -237,8 +237,6 @@ typedef struct apr_file_t apr_file_t;
* support, see WARNING below
* @li #APR_FOPEN_SPARSE Platform dependent flag to enable sparse file
* support, see WARNING below
- * @li #APR_FOPEN_ROTATING Do file file rotation checking
- * @li #APR_FOPEN_MANUAL_ROTATE Enable Manual rotation
* @li #APR_FOPEN_NONBLOCK Platform dependent flag to enable
* non blocking file io
* @param perm Access permissions for file.
diff --git a/include/apr_fnmatch.h b/include/apr_fnmatch.h
index ef6d0b2..e8f6b03 100644
--- a/include/apr_fnmatch.h
+++ b/include/apr_fnmatch.h
@@ -60,9 +60,7 @@ extern "C" {
#define APR_FNM_NOESCAPE 0x01 /**< Disable backslash escaping. */
#define APR_FNM_PATHNAME 0x02 /**< Slash must be matched by slash. */
#define APR_FNM_PERIOD 0x04 /**< Period must be matched by period. */
-#define APR_FNM_CASE_BLIND 0x08 /**< Compare characters case-insensitively.
- * @remark This flag is an Apache addition
- */
+#define APR_FNM_CASE_BLIND 0x08 /**< Compare characters case-insensitively. */
/**
* Try to match the string to the given pattern, return APR_SUCCESS if
@@ -130,13 +128,19 @@ APR_DECLARE(apr_status_t) apr_fnmatch(const char *pattern,
APR_DECLARE(int) apr_fnmatch_test(const char *pattern);
/**
- * Find all files that match a specified pattern.
- * @param pattern The pattern to use for finding files.
+ * Find all files that match a specified pattern in a directory.
+ * @param dir_pattern The pattern to use for finding files, appended
+ * to the search directory. The pattern is anything following the
+ * final forward or backward slash in the parameter. If no slash
+ * is found, the current directory is searched.
* @param result Array to use when storing the results
* @param p The pool to use.
- * @return non-zero if pattern has any glob characters in it
+ * @return APR_SUCCESS if no processing errors occurred, APR error
+ * code otherwise
+ * @remark The returned array may be empty even if APR_SUCCESS was
+ * returned.
*/
-APR_DECLARE(apr_status_t) apr_match_glob(const char *pattern,
+APR_DECLARE(apr_status_t) apr_match_glob(const char *dir_pattern,
apr_array_header_t **result,
apr_pool_t *p);
diff --git a/include/apr_lib.h b/include/apr_lib.h
index 8c0fea7..466e818 100644
--- a/include/apr_lib.h
+++ b/include/apr_lib.h
@@ -111,19 +111,19 @@ APR_DECLARE(const char *) apr_filepath_name_get(const char *pathname);
* <PRE>
* The extensions are:
*
- * %%pA takes a struct in_addr *, and prints it as a.b.c.d
- * %%pI takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
- * [ipv6-address]:port
- * %%pT takes an apr_os_thread_t * and prints it in decimal
- * ('0' is printed if !APR_HAS_THREADS)
- * %%pt takes an apr_os_thread_t * and prints it in hexadecimal
- * ('0' is printed if !APR_HAS_THREADS)
- * %%pm takes an apr_status_t * and prints the appropriate error
- * string (from apr_strerror) corresponding to that error code.
- * %%pp takes a void * and outputs it in hex
- * %%pB takes a apr_uint32_t * as bytes and outputs it's apr_strfsize
- * %%pF same as above, but takes a apr_off_t *
- * %%pS same as above, but takes a apr_size_t *
+ * - %%pA takes a struct in_addr *, and prints it as a.b.c.d
+ * - %%pI takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
+ * \[ipv6-address\]:port
+ * - %%pT takes an apr_os_thread_t * and prints it in decimal
+ * ('0' is printed if !APR_HAS_THREADS)
+ * - %%pt takes an apr_os_thread_t * and prints it in hexadecimal
+ * ('0' is printed if !APR_HAS_THREADS)
+ * - %%pm takes an apr_status_t * and prints the appropriate error
+ * string (from apr_strerror) corresponding to that error code.
+ * - %%pp takes a void * and outputs it in hex
+ * - %%pB takes a apr_uint32_t * as bytes and outputs it's apr_strfsize
+ * - %%pF same as above, but takes a apr_off_t *
+ * - %%pS same as above, but takes a apr_size_t *
*
* %%pA, %%pI, %%pT, %%pp are available from APR 1.0.0 onwards (and in 0.9.x).
* %%pt is only available from APR 1.2.0 onwards.
diff --git a/include/apr_network_io.h b/include/apr_network_io.h
index 7b57cd8..0d34a84 100644
--- a/include/apr_network_io.h
+++ b/include/apr_network_io.h
@@ -405,6 +405,8 @@ APR_DECLARE(apr_status_t) apr_sockaddr_info_get(apr_sockaddr_t **sa,
* @param hostname The hostname.
* @param sa The apr_sockaddr_t.
* @param flags Special processing flags.
+ * @remark Results can vary significantly between platforms
+ * when processing wildcard socket addresses.
*/
APR_DECLARE(apr_status_t) apr_getnameinfo(char **hostname,
apr_sockaddr_t *sa,
diff --git a/include/apr_poll.h b/include/apr_poll.h
index fd0e589..1381ddd 100644
--- a/include/apr_poll.h
+++ b/include/apr_poll.h
@@ -42,7 +42,9 @@ extern "C" {
*/
/**
- * Poll options
+ * @defgroup pollopts Poll options
+ * @ingroup apr_poll
+ * @{
*/
#define APR_POLLIN 0x001 /**< Can read without blocking */
#define APR_POLLPRI 0x002 /**< Priority data available */
@@ -50,9 +52,12 @@ extern "C" {
#define APR_POLLERR 0x010 /**< Pending error */
#define APR_POLLHUP 0x020 /**< Hangup occurred */
#define APR_POLLNVAL 0x040 /**< Descriptor invalid */
+/** @} */
/**
- * Pollset Flags
+ * @defgroup pollflags Pollset Flags
+ * @ingroup apr_poll
+ * @{
*/
#define APR_POLLSET_THREADSAFE 0x001 /**< Adding or removing a descriptor is
* thread-safe
@@ -67,6 +72,7 @@ extern "C" {
* the specified non-default method cannot be
* used
*/
+/** @} */
/**
* Pollset Methods
diff --git a/include/apr_skiplist.h b/include/apr_skiplist.h
index 37306da..bc17efd 100644
--- a/include/apr_skiplist.h
+++ b/include/apr_skiplist.h
@@ -14,69 +14,246 @@
* limitations under the License.
*/
-#ifndef _APR_SKIPLIST_P_H
-#define _APR_SKIPLIST_P_H
+#ifndef APR_SKIPLIST_H
+#define APR_SKIPLIST_H
+/**
+ * @file apr_skiplist.h
+ * @brief APR skip list implementation
+ */
#include "apr.h"
#include "apr_portable.h"
#include <stdlib.h>
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @defgroup apr_skiplist Skip list implementation
+ * Refer to http://en.wikipedia.org/wiki/Skip_list for information
+ * about the purpose of and ideas behind skip lists.
+ * @ingroup APR
+ * @{
+ */
-/* This is the function type that must be implemented per object type
- that is used in a skiplist for comparisons to maintain order */
+/**
+ * apr_skiplist_compare is the function type that must be implemented
+ * per object type that is used in a skip list for comparisons to maintain
+ * order
+ * */
typedef int (*apr_skiplist_compare) (void *, void *);
+
+/**
+ * apr_skiplist_freefunc is the function type that must be implemented
+ * to handle elements as they are removed from a skip list.
+ */
typedef void (*apr_skiplist_freefunc) (void *);
+/** Opaque structure used to represent the skip list */
struct apr_skiplist;
-struct apr_skiplistnode;
+/** Opaque structure used to represent the skip list */
+typedef struct apr_skiplist apr_skiplist;
+/**
+ * Opaque structure used to represent abstract nodes in the skip list
+ * (an abstraction above the raw elements which are collected in the
+ * skip list).
+ */
+struct apr_skiplistnode;
+/** Opaque structure */
typedef struct apr_skiplistnode apr_skiplistnode;
-typedef struct apr_skiplist apr_skiplist;
+/**
+ * Allocate memory using the same mechanism as the skip list.
+ * @param sl The skip list
+ * @param size The amount to allocate
+ * @remark If a pool was provided to apr_skiplist_init(), memory will
+ * be allocated from the pool or from a free list maintained with
+ * the skip list. Otherwise, memory will be allocated using the
+ * C standard library heap functions.
+ */
APR_DECLARE(void *) apr_skiplist_alloc(apr_skiplist *sl, size_t size);
+/**
+ * Free memory using the same mechanism as the skip list.
+ * @param sl The skip list
+ * @param mem The object to free
+ * @remark If a pool was provided to apr_skiplist_init(), memory will
+ * be added to a free list maintained with the skip list and be available
+ * to operations on the skip list or to other calls to apr_skiplist_alloc().
+ * Otherwise, memory will be freed using the C standard library heap
+ * functions.
+ */
APR_DECLARE(void) apr_skiplist_free(apr_skiplist *sl, void *mem);
+/**
+ * Allocate a new skip list
+ * @param sl The pointer in which to return the newly created skip list
+ * @param p The pool from which to allocate the skip list (optional).
+ * @remark Unlike most APR functions, a pool is optional. If no pool
+ * is provided, the C standard library heap functions will be used instead.
+ */
APR_DECLARE(apr_status_t) apr_skiplist_init(apr_skiplist **sl, apr_pool_t *p);
-APR_DECLARE(void) apr_skiplist_set_compare(apr_skiplist *sl, apr_skiplist_compare,
- apr_skiplist_compare);
+/**
+ * Set the comparison functions to be used for searching the skip list.
+ * @param sl The skip list
+ * @param XXX1 FIXME
+ * @param XXX2 FIXME
+ *
+ * @remark If existing comparison functions are being replaced, the index
+ * will be replaced during this call. That is a potentially expensive
+ * operation.
+ */
+APR_DECLARE(void) apr_skiplist_set_compare(apr_skiplist *sl, apr_skiplist_compare XXX1,
+ apr_skiplist_compare XXX2);
-APR_DECLARE(void) apr_skiplist_add_index(apr_skiplist *sl, apr_skiplist_compare,
- apr_skiplist_compare);
+/**
+ * Set the indexing functions to the specified comparison functions and
+ * rebuild the index.
+ * @param sl The skip list
+ * @param XXX1 FIXME
+ * @param XXX2 FIXME
+ *
+ * @remark If an index already exists, it will not be replaced and the
+ * comparison functions will not be changed.
+ */
+APR_DECLARE(void) apr_skiplist_add_index(apr_skiplist *sl, apr_skiplist_compare XXX1,
+ apr_skiplist_compare XXX2);
+/**
+ * Return the list maintained by the skip list abstraction.
+ * @param sl The skip list
+ */
APR_DECLARE(apr_skiplistnode *) apr_skiplist_getlist(apr_skiplist *sl);
+/**
+ * Return the next matching element in the skip list using the specified
+ * comparison function.
+ * @param sl The skip list
+ * @param data The value to search for
+ * @param iter A pointer to the returned skip list node representing the element
+ * found
+ * @param func The comparison function to use
+ */
APR_DECLARE(void *) apr_skiplist_find_compare(apr_skiplist *sl,
void *data,
apr_skiplistnode **iter,
apr_skiplist_compare func);
+/**
+ * Return the next matching element in the skip list using the current comparison
+ * function.
+ * @param sl The skip list
+ * @param data The value to search for
+ * @param iter A pointer to the returned skip list node representing the element
+ * found
+ */
APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter);
+/**
+ * Return the next element in the skip list.
+ * @param sl The skip list
+ * @param iter On entry, a pointer to the skip list node to start with; on return,
+ * a pointer to the skip list node representing the element returned
+ * @remark If iter points to a NULL value on entry, NULL will be returned.
+ */
APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter);
+/**
+ * Return the previous element in the skip list.
+ * @param sl The skip list
+ * @param iter On entry, a pointer to the skip list node to start with; on return,
+ * a pointer to the skip list node representing the element returned
+ * @remark If iter points to a NULL value on entry, NULL will be returned.
+ */
APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **iter);
-
+/**
+ * Insert an element into the skip list using the specified comparison function.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @param comp The comparison function to use for placement into the skip list
+ */
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl,
void *data, apr_skiplist_compare comp);
+/**
+ * Insert an element into the skip list using the existing comparison function.
+ * @param sl The skip list
+ * @param data The element to insert
+ * @remark If no comparison function has been set for the skip list, the element
+ * will not be inserted and NULL will be returned.
+ */
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist* sl, void *data);
+/**
+ * Remove an element from the skip list using the specified comparison function for
+ * locating the element.
+ * @param sl The skip list
+ * @param data The element to remove
+ * @param myfree A function to be called for each removed element
+ * @param comp The comparison function to use for placement into the skip list
+ * @remark If the element is not found, 0 will be returned. Otherwise, the heightXXX
+ * will be returned.
+ */
APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sl, void *data,
apr_skiplist_freefunc myfree, apr_skiplist_compare comp);
+/**
+ * Remove an element from the skip list using the existing comparison function for
+ * locating the element.
+ * @param sl The skip list
+ * @param data The element to remove
+ * @param myfree A function to be called for each removed element
+ * @remark If the element is not found, 0 will be returned. Otherwise, the heightXXX
+ * will be returned.
+ * @remark If no comparison function has been set for the skip list, the element
+ * will not be removed and 0 will be returned.
+ */
APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, apr_skiplist_freefunc myfree);
+/**
+ * Remove all elements from the skip list.
+ * @param sl The skip list
+ * @param myfree A function to be called for each removed element
+ */
APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefunc myfree);
+/**
+ * Remove each element from the skip list.
+ * @param sl The skip list
+ * @param myfree A function to be called for each removed element
+ */
APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc myfree);
-APR_DECLARE(void *) apr_skiplist_pop(apr_skiplist *a, apr_skiplist_freefunc myfree);
+/**
+ * Return the first element in the skip list, leaving the element in the skip list.
+ * @param sl The skip list
+ * @param myfree A function to be called for the removed element
+ * @remark NULL will be returned if there are no elements
+ */
+APR_DECLARE(void *) apr_skiplist_pop(apr_skiplist *sl, apr_skiplist_freefunc myfree);
-APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *a);
+/**
+ * Return the first element in the skip list, leaving the element in the skip list.
+ * @param sl The skip list
+ * @remark NULL will be returned if there are no elements
+ */
+APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *sl);
+/**
+ * Merge two skip lists. XXX SEMANTICS
+ * @param sl1 One of two skip lists to be merged
+ * @param sl2 The other of two skip lists to be merged
+ */
APR_DECLARE(apr_skiplist *) apr_skiplist_merge(apr_skiplist *sl1, apr_skiplist *sl2);
+/** @} */
+
+#ifdef __cplusplus
+}
#endif
+
+#endif /* ! APR_SKIPLIST_H */
diff --git a/include/apr_strings.h b/include/apr_strings.h
index ed41931..c0642ad 100644
--- a/include/apr_strings.h
+++ b/include/apr_strings.h
@@ -235,8 +235,14 @@ APR_DECLARE(apr_status_t) apr_tokenize_to_argv(const char *arg_str,
* first call to apr_strtok() for a given string, and NULL
* on subsequent calls.
* @param sep The set of delimiters
- * @param last Internal state saved by apr_strtok() between calls.
+ * @param last State saved by apr_strtok() between calls.
* @return The next token from the string
+ * @note the 'last' state points to the trailing NUL char of the final
+ * token, otherwise it points to the character following the current
+ * token (all successive or empty occurances of sep are skiped on the
+ * subsequent call to apr_strtok). Therefore it is possible to avoid
+ * a strlen() determination, with the following logic;
+ * toklen = last - retval; if (*last) --toklen;
*/
APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last);
diff --git a/include/apr_thread_mutex.h b/include/apr_thread_mutex.h
index 4596dce..193a70a 100644
--- a/include/apr_thread_mutex.h
+++ b/include/apr_thread_mutex.h
@@ -59,7 +59,7 @@ typedef struct apr_thread_mutex_t apr_thread_mutex_t;
* </PRE>
* @param pool the pool from which to allocate the mutex.
* @warning Be cautious in using APR_THREAD_MUTEX_DEFAULT. While this is the
- * most optimial mutex based on a given platform's performance charateristics,
+ * most optimal mutex based on a given platform's performance characteristics,
* it will behave as either a nested or an unnested lock.
*/
APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
diff --git a/include/apr_time.h b/include/apr_time.h
index 6dd70cc..15e0b96 100644
--- a/include/apr_time.h
+++ b/include/apr_time.h
@@ -42,7 +42,7 @@ APR_DECLARE_DATA extern const char apr_month_snames[12][4];
APR_DECLARE_DATA extern const char apr_day_snames[7][4];
-/** number of microseconds since 00:00:00 january 1, 1970 UTC */
+/** number of microseconds since 00:00:00 January 1, 1970 UTC */
typedef apr_int64_t apr_time_t;
@@ -93,7 +93,7 @@ typedef struct apr_time_exp_t apr_time_exp_t;
/**
* a structure similar to ANSI struct tm with the following differences:
* - tm_usec isn't an ANSI field
- * - tm_gmtoff isn't an ANSI field (it's a bsdism)
+ * - tm_gmtoff isn't an ANSI field (it's a BSDism)
*/
struct apr_time_exp_t {
/** microseconds past tm_sec */
@@ -110,9 +110,9 @@ struct apr_time_exp_t {
apr_int32_t tm_mon;
/** year since 1900 */
apr_int32_t tm_year;
- /** (0-6) days since sunday */
+ /** (0-6) days since Sunday */
apr_int32_t tm_wday;
- /** (0-365) days since jan 1 */
+ /** (0-365) days since January 1 */
apr_int32_t tm_yday;
/** daylight saving time */
apr_int32_t tm_isdst;
@@ -121,7 +121,7 @@ struct apr_time_exp_t {
};
/**
- * convert an ansi time_t to an apr_time_t
+ * Convert an ansi time_t to an apr_time_t
* @param result the resulting apr_time_t
* @param input the time_t to convert
*/
@@ -129,8 +129,8 @@ APR_DECLARE(apr_status_t) apr_time_ansi_put(apr_time_t *result,
time_t input);
/**
- * convert a time to its human readable components using an offset
- * from GMT
+ * Convert a time to its human readable components using an offset
+ * from GMT.
* @param result the exploded time
* @param input the time to explode
* @param offs the number of seconds offset to apply
@@ -140,7 +140,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_tz(apr_time_exp_t *result,
apr_int32_t offs);
/**
- * convert a time to its human readable components in GMT timezone
+ * Convert a time to its human readable components (GMT).
* @param result the exploded time
* @param input the time to explode
*/
@@ -148,7 +148,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_gmt(apr_time_exp_t *result,
apr_time_t input);
/**
- * convert a time to its human readable components in local timezone
+ * Convert a time to its human readable components in the local timezone.
* @param result the exploded time
* @param input the time to explode
*/
@@ -156,8 +156,8 @@ APR_DECLARE(apr_status_t) apr_time_exp_lt(apr_time_exp_t *result,
apr_time_t input);
/**
- * Convert time value from human readable format to a numeric apr_time_t
- * e.g. elapsed usec since epoch
+ * Convert time value from human readable format to a numeric apr_time_t
+ * (elapsed microseconds since the epoch).
* @param result the resulting imploded time
* @param input the input exploded time
*/
@@ -166,7 +166,7 @@ APR_DECLARE(apr_status_t) apr_time_exp_get(apr_time_t *result,
/**
* Convert time value from human readable format to a numeric apr_time_t that
- * always represents GMT
+ * always represents GMT.
* @param result the resulting imploded time
* @param input the input exploded time
*/
@@ -185,7 +185,7 @@ APR_DECLARE(void) apr_sleep(apr_interval_time_t t);
/**
* apr_rfc822_date formats dates in the RFC822
* format in an efficient manner. It is a fixed length
- * format which requires the indicated amount of storage,
+ * format which requires APR_RFC822_DATA_LEN bytes of storage,
* including the trailing NUL terminator.
* @param date_str String to write to.
* @param t the time to convert
@@ -196,18 +196,18 @@ APR_DECLARE(apr_status_t) apr_rfc822_date(char *date_str, apr_time_t t);
#define APR_CTIME_LEN (25)
/**
* apr_ctime formats dates in the ctime() format
- * in an efficient manner. it is a fixed length format
- * and requires the indicated amount of storage including
+ * in an efficient manner. It is a fixed length format
+ * and requires APR_CTIME_LEN bytes of storage including
* the trailing NUL terminator.
* Unlike ANSI/ISO C ctime(), apr_ctime() does not include
- * a \n at the end of the string.
+ * a \\n at the end of the string.
* @param date_str String to write to.
* @param t the time to convert
*/
APR_DECLARE(apr_status_t) apr_ctime(char *date_str, apr_time_t t);
/**
- * formats the exploded time according to the format specified
+ * Formats the exploded time according to the format specified
* @param s string to write to
* @param retsize The length of the returned string
* @param max The maximum length of the string
@@ -220,7 +220,7 @@ APR_DECLARE(apr_status_t) apr_strftime(char *s, apr_size_t *retsize,
/**
* Improve the clock resolution for the lifetime of the given pool.
- * Generally this is only desireable on benchmarking and other very
+ * Generally this is only desirable on benchmarking and other very
* time-sensitive applications, and has no impact on most platforms.
* @param p The pool to associate the finer clock resolution
*/
diff --git a/include/apr_version.h b/include/apr_version.h
index a2dcec2..2111053 100644
--- a/include/apr_version.h
+++ b/include/apr_version.h
@@ -38,7 +38,7 @@
*/
-#define APR_COPYRIGHT "Copyright (c) 2013 The Apache Software " \
+#define APR_COPYRIGHT "Copyright (c) 2000-2014 The Apache Software " \
"Foundation or its licensors, as applicable."
/* The numeric compile-time version constants. These constants are the
@@ -62,7 +62,7 @@
* The Patch Level never includes API changes, simply bug fixes.
* Reset to 0 when upgrading APR_MINOR_VERSION
*/
-#define APR_PATCH_VERSION 0
+#define APR_PATCH_VERSION 1
/**
* The symbol APR_IS_DEV_VERSION is only defined for internal,
diff --git a/include/arch/netware/apr_private.h b/include/arch/netware/apr_private.h
index dbb3d21..04f336d 100644
--- a/include/arch/netware/apr_private.h
+++ b/include/arch/netware/apr_private.h
@@ -79,7 +79,7 @@
#define HAVE_GETPASS_R 1
/*
* Hack around older NDKs which have only the getpassword() function,
- * a threadsafe, API-equivilant of getpass_r().
+ * a threadsafe, API-equivalent of getpass_r().
*/
#if (CURRENT_NDK_THRESHOLD < 709060000)
#define getpass_r getpassword
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index f9637e0..fa8a872 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -102,8 +102,8 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
apr_ssize_t flen = strlen(fname);
char *p = apr_pstrndup(new_mutex->pool, fname, strlen(fname));
unsigned int h1, h2;
- h1 = apr_hashfunc_default((const char *)p, &flen);
- h2 = rshash(p);
+ h1 = (apr_hashfunc_default((const char *)p, &flen) & 0xffffffff);
+ h2 = (rshash(p) & 0xffffffff);
apr_snprintf(semname, sizeof(semname), "/ApR.%xH%x", h1, h2);
} else {
apr_time_t now;
@@ -951,7 +951,12 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
apr_proc_mutex_t *pmutex)
{
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE || APR_HAS_POSIXSEM_SERIALIZE
- ospmutex->crossproc = pmutex->interproc->filedes;
+ if (pmutex->interproc) {
+ ospmutex->crossproc = pmutex->interproc->filedes;
+ }
+ else {
+ ospmutex->crossproc = -1;
+ }
#endif
#if APR_HAS_PROC_PTHREAD_SERIALIZE
ospmutex->pthread_interproc = pmutex->pthread_interproc;
diff --git a/network_io/unix/socket_util.c b/network_io/unix/socket_util.c
index 6cd28a5..93fe259 100644
--- a/network_io/unix/socket_util.c
+++ b/network_io/unix/socket_util.c
@@ -46,7 +46,8 @@ APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock, int *atreadeo
/* Some other error -> unexpected error. */
return rv;
}
- else if (nfds == 1 && pfds[0].rtnevents == APR_POLLIN) {
+ /* Many platforms return only APR_POLLIN; OS X returns APR_POLLHUP|APR_POLLIN */
+ else if (nfds == 1 && (pfds[0].rtnevents & APR_POLLIN) == APR_POLLIN) {
apr_sockaddr_t unused;
apr_size_t len = 1;
char buf;
diff --git a/network_io/unix/sockets.c b/network_io/unix/sockets.c
index 748dd70..514edb1 100644
--- a/network_io/unix/sockets.c
+++ b/network_io/unix/sockets.c
@@ -207,7 +207,20 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
sa.salen = sizeof(sa.sa);
#ifdef HAVE_ACCEPT4
- s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, SOCK_CLOEXEC);
+ {
+ int flags = SOCK_CLOEXEC;
+
+#if defined(SOCK_NONBLOCK) && APR_O_NONBLOCK_INHERITED
+ /* With FreeBSD accept4() (avail in 10+), O_NONBLOCK is not inherited
+ * (unlike Linux). Mimic the accept() behavior here in a way that
+ * may help other platforms.
+ */
+ if (apr_is_option_set(sock, APR_SO_NONBLOCK) == 1) {
+ flags |= SOCK_NONBLOCK;
+ }
+#endif
+ s = accept4(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen, flags);
+ }
#else
s = accept(sock->socketdes, (struct sockaddr *)&sa.sa, &sa.salen);
#endif
diff --git a/shmem/unix/shm.c b/shmem/unix/shm.c
index 87a7ce0..f102b4b 100644
--- a/shmem/unix/shm.c
+++ b/shmem/unix/shm.c
@@ -20,6 +20,62 @@
#include "apr_errno.h"
#include "apr_user.h"
#include "apr_strings.h"
+#include "apr_hash.h"
+
+#if APR_USE_SHMEM_MMAP_SHM
+/*
+ * For portable use, a shared memory object should be identified by a name of
+ * the form /somename; that is, a null-terminated string of up to NAME_MAX
+ * (i.e., 255) characters consisting of an initial slash, followed by one or
+ * more characters, none of which are slashes.
+ */
+#ifndef NAME_MAX
+#define NAME_MAX 255
+#endif
+
+/* See proc_mutex.c and sem_open for the reason for all this! */
+static unsigned int rshash (const char *p) {
+ /* hash function from Robert Sedgwicks 'Algorithms in C' book */
+ unsigned int b = 378551;
+ unsigned int a = 63689;
+ unsigned int retval = 0;
+
+ for( ; *p; p++) {
+ retval = retval * a + (*p);
+ a *= b;
+ }
+
+ return retval;
+}
+
+static const char *make_shm_open_safe_name(const char *filename,
+ apr_pool_t *pool)
+{
+ apr_ssize_t flen;
+ unsigned int h1, h2;
+
+ if (filename == NULL) {
+ return NULL;
+ }
+
+ flen = strlen(filename);
+ h1 = (apr_hashfunc_default(filename, &flen) & 0xffffffff);
+ h2 = (rshash(filename) & 0xffffffff);
+ return apr_psprintf(pool, "/ShM.%xH%x", h1, h2);
+
+}
+#endif
+
+#if APR_USE_SHMEM_SHMGET
+static key_t our_ftok(const char *filename)
+{
+ /* to help avoid collisions while still using
+ * an easily recreated proj_id */
+ apr_ssize_t slen = strlen(filename);
+ return ftok(filename,
+ (int)apr_hashfunc_default(filename, &slen));
+}
+#endif
static apr_status_t shm_cleanup_owner(void *m_)
{
@@ -58,7 +114,7 @@ static apr_status_t shm_cleanup_owner(void *m_)
if (munmap(m->base, m->realsize) == -1) {
return errno;
}
- if (shm_unlink(m->filename) == -1) {
+ if (shm_unlink(make_shm_open_safe_name(m->filename, m->pool)) == -1 && errno != ENOENT) {
return errno;
}
return APR_SUCCESS;
@@ -220,7 +276,9 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
new_m->pool = pool;
new_m->reqsize = reqsize;
new_m->filename = apr_pstrdup(pool, filename);
-
+#if APR_USE_SHMEM_MMAP_SHM
+ const char *shm_name = make_shm_open_safe_name(filename, pool);
+#endif
#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
new_m->realsize = reqsize +
APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */
@@ -245,7 +303,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
}
status = apr_file_trunc(file, new_m->realsize);
- if (status != APR_SUCCESS) {
+ if (status != APR_SUCCESS && status != APR_ESPIPE) {
apr_file_close(file); /* ignore errors, we're failing */
apr_file_remove(new_m->filename, new_m->pool);
return status;
@@ -261,7 +319,8 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
}
#endif /* APR_USE_SHMEM_MMAP_TMP */
#if APR_USE_SHMEM_MMAP_SHM
- tmpfd = shm_open(filename, O_RDWR | O_CREAT | O_EXCL, 0644);
+ /* FIXME: SysV uses 0600... should we? */
+ tmpfd = shm_open(shm_name, O_RDWR | O_CREAT | O_EXCL, 0644);
if (tmpfd == -1) {
return errno;
}
@@ -274,11 +333,11 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
}
status = apr_file_trunc(file, new_m->realsize);
- if (status != APR_SUCCESS) {
- shm_unlink(filename); /* we're failing, remove the object */
+ if (status != APR_SUCCESS && status != APR_ESPIPE) {
+ shm_unlink(shm_name); /* we're failing, remove the object */
return status;
}
- new_m->base = mmap(NULL, reqsize, PROT_READ | PROT_WRITE,
+ new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE,
MAP_SHARED, tmpfd, 0);
/* FIXME: check for errors */
@@ -312,7 +371,7 @@ APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
apr_file_close(file);
return errno;
@@ -387,7 +446,8 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename,
#if APR_USE_SHMEM_MMAP_TMP
return apr_file_remove(filename, pool);
#elif APR_USE_SHMEM_MMAP_SHM
- if (shm_unlink(filename) == -1) {
+ const char *shm_name = make_shm_open_safe_name(filename, pool);
+ if (shm_unlink(shm_name) == -1) {
return errno;
}
return APR_SUCCESS;
@@ -401,7 +461,7 @@ APR_DECLARE(apr_status_t) apr_shm_remove(const char *filename,
/* ftok() (on solaris at least) requires that the file actually
* exist before calling ftok(). */
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
goto shm_remove_failed;
}
@@ -482,7 +542,23 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
new_m = apr_palloc(pool, sizeof(apr_shm_t));
new_m->pool = pool;
new_m->filename = apr_pstrdup(pool, filename);
+#if APR_USE_SHMEM_MMAP_SHM
+ const char *shm_name = make_shm_open_safe_name(filename, pool);
+ /* FIXME: SysV uses 0600... should we? */
+ tmpfd = shm_open(shm_name, O_RDWR, 0644);
+ if (tmpfd == -1) {
+ return errno;
+ }
+
+ status = apr_os_file_put(&file, &tmpfd,
+ APR_READ | APR_WRITE,
+ pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+#elif APR_USE_SHMEM_MMAP_TMP
status = apr_file_open(&file, filename,
APR_READ | APR_WRITE,
APR_OS_DEFAULT, pool);
@@ -493,6 +569,9 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
if (status != APR_SUCCESS) {
return status;
}
+#else
+ return APR_ENOTIMPL;
+#endif
nbytes = sizeof(new_m->realsize);
status = apr_file_read(file, (void *)&(new_m->realsize),
@@ -555,7 +634,7 @@ APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
new_m->filename = apr_pstrdup(pool, filename);
new_m->pool = pool;
- shmkey = ftok(filename, 1);
+ shmkey = our_ftok(filename);
if (shmkey == (key_t)-1) {
return errno;
}
diff --git a/test/sockchild.c b/test/sockchild.c
index ec7ffb8..0777e1e 100644
--- a/test/sockchild.c
+++ b/test/sockchild.c
@@ -69,8 +69,14 @@ int main(int argc, char *argv[])
exit((int)length);
}
- else if (!strcmp("write", argv[1])) {
+ else if (!strcmp("write", argv[1])
+ || !strcmp("write_after_delay", argv[1])) {
apr_size_t length = strlen(DATASTR);
+
+ if (!strcmp("write_after_delay", argv[1])) {
+ apr_sleep(apr_time_from_sec(2));
+ }
+
apr_socket_send(sock, DATASTR, &length);
apr_socket_close(sock);
diff --git a/test/testatomic.c b/test/testatomic.c
index 8e00fb1..ca0398a 100644
--- a/test/testatomic.c
+++ b/test/testatomic.c
@@ -167,6 +167,17 @@ static void test_add32(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, 27, y32);
}
+static void test_add32_neg(abts_case *tc, void *data)
+{
+ apr_uint32_t oldval;
+ apr_uint32_t y32;
+
+ apr_atomic_set32(&y32, 23);
+ oldval = apr_atomic_add32(&y32, -10);
+ ABTS_INT_EQUAL(tc, 23, oldval);
+ ABTS_INT_EQUAL(tc, 13, y32);
+}
+
static void test_inc32(abts_case *tc, void *data)
{
apr_uint32_t oldval;
@@ -509,6 +520,7 @@ abts_suite *testatomic(abts_suite *suite)
abts_run_test(suite, test_casptr_equal_nonnull, NULL);
abts_run_test(suite, test_casptr_notequal, NULL);
abts_run_test(suite, test_add32, NULL);
+ abts_run_test(suite, test_add32_neg, NULL);
abts_run_test(suite, test_inc32, NULL);
abts_run_test(suite, test_set_add_inc_sub, NULL);
abts_run_test(suite, test_wrap_zero, NULL);
diff --git a/test/testdir.c b/test/testdir.c
index 417a1d7..ac1bcfa 100644
--- a/test/testdir.c
+++ b/test/testdir.c
@@ -22,6 +22,7 @@
#include "apr_errno.h"
#include "apr_general.h"
#include "apr_lib.h"
+#include "apr_thread_proc.h"
#include "testutil.h"
static void test_mkdir(abts_case *tc, void *data)
@@ -59,6 +60,73 @@ static void test_mkdir_recurs(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, APR_DIR, finfo.filetype);
}
+struct thread_data
+{
+ abts_case *tc;
+ apr_pool_t *pool;
+};
+
+static void *APR_THREAD_FUNC thread_mkdir_func(apr_thread_t *thd, void *data)
+{
+ struct thread_data *td = data;
+ apr_status_t s1, s2, s3, s4, s5;
+
+ s1 = apr_dir_make_recursive("data/prll/one/thwo/three",
+ APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
+ td->pool);
+ s2 = apr_dir_make_recursive("data/prll/four/five/six/seven/eight",
+ APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
+ td->pool);
+ s3 = apr_dir_make_recursive("data/prll/nine/ten",
+ APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
+ td->pool);
+ s4 = apr_dir_make_recursive("data/prll/11/12/13/14/15/16/17/18/19/20",
+ APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
+ td->pool);
+ s5 = apr_dir_make_recursive("data/fortytwo",
+ APR_FPROT_UREAD | APR_FPROT_UWRITE | APR_FPROT_UEXECUTE,
+ td->pool);
+
+ ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s1);
+ ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s2);
+ ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s3);
+ ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s4);
+ ABTS_INT_EQUAL(td->tc, APR_SUCCESS, s5);
+ return NULL;
+}
+
+static void test_mkdir_recurs_parallel(abts_case *tc, void *data)
+{
+ struct thread_data td1, td2, td3, td4;
+ apr_thread_t *t1, *t2, *t3, *t4;
+ apr_status_t s1, s2, s3, s4;
+
+ td1.tc = td2.tc = td3.tc = td4.tc = tc;
+ apr_pool_create(&td1.pool, p);
+ apr_pool_create(&td2.pool, p);
+ apr_pool_create(&td3.pool, p);
+ apr_pool_create(&td4.pool, p);
+
+ s1 = apr_thread_create(&t1, NULL, thread_mkdir_func, &td1, td1.pool);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
+ s2 = apr_thread_create(&t2, NULL, thread_mkdir_func, &td2, td2.pool);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
+ s3 = apr_thread_create(&t3, NULL, thread_mkdir_func, &td3, td3.pool);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
+ s4 = apr_thread_create(&t4, NULL, thread_mkdir_func, &td4, td4.pool);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
+
+ apr_thread_join(&s1, t1);
+ apr_thread_join(&s2, t2);
+ apr_thread_join(&s3, t3);
+ apr_thread_join(&s4, t4);
+
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s1);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s2);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s3);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, s4);
+}
+
static void test_remove(abts_case *tc, void *data)
{
apr_status_t rv;
@@ -91,6 +159,72 @@ static void test_removeall(abts_case *tc, void *data)
rv = apr_dir_remove("data/one", p);
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/one/thwo/three", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/one/thwo", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/one", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/four/five/six/seven/eight", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/four/five/six/seven", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/four/five/six", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/four/five", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/four", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/nine/ten", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/nine", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15/16/17/18/19/20", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15/16/17/18/19", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15/16/17/18", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15/16/17", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15/16", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14/15", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13/14", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12/13", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11/12", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll/11", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/prll", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_dir_remove("data/fortytwo", p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
static void test_remove_notthere(abts_case *tc, void *data)
@@ -245,6 +379,7 @@ abts_suite *testdir(abts_suite *suite)
abts_run_test(suite, test_mkdir, NULL);
abts_run_test(suite, test_mkdir_recurs, NULL);
+ abts_run_test(suite, test_mkdir_recurs_parallel, NULL);
abts_run_test(suite, test_remove, NULL);
abts_run_test(suite, test_removeall_fail, NULL);
abts_run_test(suite, test_removeall, NULL);
diff --git a/test/testescape.c b/test/testescape.c
index 28e1f09..323ff56 100644
--- a/test/testescape.c
+++ b/test/testescape.c
@@ -166,6 +166,7 @@ static void test_escape(abts_case *tc, void *data)
apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
(len == strlen(dest) + 1));
+#if !APR_CHARSET_EBCDIC
src = "Hello";
dest = apr_pescape_entity(pool, src, 1);
ABTS_PTR_EQUAL(tc, src, dest);
@@ -209,6 +210,7 @@ static void test_escape(abts_case *tc, void *data)
ABTS_ASSERT(tc,
apr_psprintf(pool, "size mismatch (%" APR_SIZE_T_FMT "!=%" APR_SIZE_T_FMT ")", len, strlen(dest) + 1),
(len == strlen(dest) + 1));
+#endif
src = "Hello";
dest = apr_pescape_echo(pool, src, 0);
diff --git a/test/testmmap.c b/test/testmmap.c
index 74c0c9f..140d5c3 100644
--- a/test/testmmap.c
+++ b/test/testmmap.c
@@ -26,16 +26,16 @@
* length on a platform?
*/
#define PATH_LEN 255
-#define TEST_STRING "This is the MMAP data file."APR_EOL_STR
#if !APR_HAS_MMAP
static void not_implemented(abts_case *tc, void *data)
{
- ABTS_NOT_IMPL(tc, "User functions");
+ ABTS_NOT_IMPL(tc, "MMAP functions");
}
#else
+static char test_string[256]; /* read from the datafile */
static apr_mmap_t *themmap = NULL;
static apr_file_t *thefile = NULL;
static char *file1;
@@ -69,6 +69,17 @@ static void test_file_close(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
}
+static void read_expected_contents(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_size_t nbytes = sizeof(test_string) - 1;
+
+ rv = apr_file_read(thefile, test_string, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ test_string[nbytes] = '\0';
+ thisfsize = strlen(test_string);
+}
+
static void test_file_open(abts_case *tc, void *data)
{
apr_status_t rv;
@@ -105,7 +116,7 @@ static void test_mmap_contents(abts_case *tc, void *data)
ABTS_SIZE_EQUAL(tc, thisfsize, themmap->size);
/* Must use nEquals since the string is not guaranteed to be NULL terminated */
- ABTS_STR_NEQUAL(tc, themmap->mm, TEST_STRING, thisfsize);
+ ABTS_STR_NEQUAL(tc, themmap->mm, test_string, thisfsize);
}
static void test_mmap_delete(abts_case *tc, void *data)
@@ -127,7 +138,7 @@ static void test_mmap_offset(abts_case *tc, void *data)
ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
/* Must use nEquals since the string is not guaranteed to be NULL terminated */
- ABTS_STR_NEQUAL(tc, addr, TEST_STRING + 5, thisfsize-5);
+ ABTS_STR_NEQUAL(tc, addr, test_string + 5, thisfsize-5);
}
#endif
@@ -136,10 +147,9 @@ abts_suite *testmmap(abts_suite *suite)
suite = ADD_SUITE(suite)
#if APR_HAS_MMAP
- thisfsize = strlen(TEST_STRING);
-
abts_run_test(suite, create_filename, NULL);
abts_run_test(suite, test_file_open, NULL);
+ abts_run_test(suite, read_expected_contents, NULL);
abts_run_test(suite, test_get_filesize, NULL);
abts_run_test(suite, test_mmap_create, NULL);
abts_run_test(suite, test_mmap_contents, NULL);
diff --git a/test/testsock.c b/test/testsock.c
index ef62f0f..6a6b7ec 100644
--- a/test/testsock.c
+++ b/test/testsock.c
@@ -23,6 +23,8 @@
#include "apr_lib.h"
#include "apr_strings.h"
#include "apr_poll.h"
+#define APR_WANT_BYTEFUNC
+#include "apr_want.h"
static void launch_child(abts_case *tc, apr_proc_t *proc, const char *arg1, apr_pool_t *p)
{
@@ -350,8 +352,8 @@ static void test_get_addr(abts_case *tc, void *data)
APR_ASSERT_SUCCESS(tc, "create subpool", apr_pool_create(&subp, p));
- if ((ld = setup_socket(tc)) != APR_SUCCESS)
- return;
+ ld = setup_socket(tc);
+ if (!ld) return;
APR_ASSERT_SUCCESS(tc,
"get local address of bound socket",
@@ -438,6 +440,54 @@ static void test_get_addr(abts_case *tc, void *data)
apr_pool_destroy(subp);
}
+/* Make sure that setting a connected socket non-blocking works
+ * when the listening socket was non-blocking.
+ * If APR thinks that non-blocking is inherited but it really
+ * isn't, this testcase will fail.
+ */
+static void test_nonblock_inheritance(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_socket_t *sock;
+ apr_socket_t *sock2;
+ apr_proc_t proc;
+ char buffer[10];
+ apr_size_t length;
+ int tries;
+
+ sock = setup_socket(tc);
+ if (!sock) return;
+
+ rv = apr_socket_opt_set(sock, APR_SO_NONBLOCK, 1);
+ APR_ASSERT_SUCCESS(tc, "Could not make listening socket nonblocking", rv);
+
+ launch_child(tc, &proc, "write_after_delay", p);
+
+ tries = 10;
+ while (tries--) {
+ rv = apr_socket_accept(&sock2, sock, p);
+ if (!APR_STATUS_IS_EAGAIN(rv)) {
+ break;
+ }
+ apr_sleep(apr_time_from_msec(50));
+ }
+ APR_ASSERT_SUCCESS(tc, "Problem with receiving connection", rv);
+
+ rv = apr_socket_opt_set(sock2, APR_SO_NONBLOCK, 1);
+ APR_ASSERT_SUCCESS(tc, "Could not make connected socket nonblocking", rv);
+
+ length = sizeof buffer;
+ rv = apr_socket_recv(sock2, buffer, &length);
+ ABTS_ASSERT(tc, "should have gotten EAGAIN", APR_STATUS_IS_EAGAIN(rv));
+
+ wait_child(tc, &proc);
+
+ rv = apr_socket_close(sock2);
+ APR_ASSERT_SUCCESS(tc, "Problem closing connected socket", rv);
+ rv = apr_socket_close(sock);
+ APR_ASSERT_SUCCESS(tc, "Problem closing socket", rv);
+}
+
abts_suite *testsock(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -451,6 +501,7 @@ abts_suite *testsock(abts_suite *suite)
abts_run_test(suite, test_timeout, NULL);
abts_run_test(suite, test_print_addr, NULL);
abts_run_test(suite, test_get_addr, NULL);
+ abts_run_test(suite, test_nonblock_inheritance, NULL);
return suite;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-apache/apr.git
More information about the Pkg-apache-commits
mailing list