summaryrefslogtreecommitdiffstats
path: root/contrib/apr
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2015-10-12 04:57:36 +0000
committerpeter <peter@FreeBSD.org>2015-10-12 04:57:36 +0000
commit6a8fa4cab570f77af8326e0339fdf0b4c09756c6 (patch)
tree64caa5ea4f1fe4b74e7d1dcbc5bdc3c674998b26 /contrib/apr
parent5ee4ad2f183130d523ba9911b00fe7b158897de8 (diff)
downloadFreeBSD-src-6a8fa4cab570f77af8326e0339fdf0b4c09756c6.zip
FreeBSD-src-6a8fa4cab570f77af8326e0339fdf0b4c09756c6.tar.gz
MFC: r269851,r272076,r274884,r282328,r285644,r286503,r286504,r286505,
r286506,r286510,r286561,r286562,r287034 Update svnlite from 1.8.10 to 1.8.14, and the support components: serf->1.3.8, apr->1.5.2, apr-util->1.5.4, sqlite3->3.8.11.1 This includes syncing the developer templates with head.
Diffstat (limited to 'contrib/apr')
-rw-r--r--contrib/apr/CHANGES63
-rw-r--r--contrib/apr/CMakeLists.txt9
-rw-r--r--contrib/apr/Makefile.in6
-rw-r--r--contrib/apr/NOTICE2
-rw-r--r--contrib/apr/NWGNUmakefile5
-rw-r--r--contrib/apr/apr.dsp63
-rw-r--r--contrib/apr/apr.spec4
-rw-r--r--contrib/apr/build-outputs.mk2
-rwxr-xr-xcontrib/apr/configure73
-rw-r--r--contrib/apr/configure.in35
-rw-r--r--contrib/apr/encoding/apr_escape.c2
-rw-r--r--contrib/apr/include/apr_skiplist.h16
-rw-r--r--contrib/apr/include/apr_version.h4
-rw-r--r--contrib/apr/libapr.dsp75
-rw-r--r--contrib/apr/locks/unix/proc_mutex.c22
-rw-r--r--contrib/apr/memory/unix/apr_pools.c26
-rw-r--r--contrib/apr/misc/unix/errorcodes.c11
-rw-r--r--contrib/apr/network_io/unix/sockaddr.c10
-rw-r--r--contrib/apr/network_io/unix/sockets.c34
-rw-r--r--contrib/apr/poll/unix/epoll.c45
-rw-r--r--contrib/apr/poll/unix/kqueue.c33
-rw-r--r--contrib/apr/poll/unix/poll.c30
-rw-r--r--contrib/apr/poll/unix/pollcb.c3
-rw-r--r--contrib/apr/poll/unix/port.c33
-rw-r--r--contrib/apr/poll/unix/z_asio.c13
-rw-r--r--contrib/apr/tables/apr_skiplist.c373
26 files changed, 605 insertions, 387 deletions
diff --git a/contrib/apr/CHANGES b/contrib/apr/CHANGES
index d04ad11..f300ec0 100644
--- a/contrib/apr/CHANGES
+++ b/contrib/apr/CHANGES
@@ -1,4 +1,63 @@
-*- coding: utf-8 -*-
+Changes for APR 1.5.2
+
+ *) SECURITY: CVE-2015-1829 (cve.mitre.org)
+ APR applications using APR named pipe support on Windows can be
+ vulnerable to a pipe squatting attack from a local process; the extent
+ of the vulnerability, when present, depends on the application.
+ Initial analysis and report was provided by John Hernandez of Casaba
+ Security via HP SSRT Security Alert. [Yann Ylavic]
+
+ *) apr_atomic: Fix errors when building on Visual Studio 2013 while
+ maintaining the ability to build on Visual Studio 6 with Windows
+ Server 2003 R2 SDK. PR 57191. [Gregg Smith]
+
+ *) Switch to generic atomics for early/unpatched Solaris 10 not exporting
+ some atomic functions. PR 55418. [Yann Ylavic]
+
+ *) apr_file_mktemp() on HP-UX: Remove limitation of 26 temporary files
+ per process. PR 57677. [Jeff Trawick]
+
+ *) apr_escape: Correctly calculate the size of the returned string in
+ apr_escape_path and set the correct return value in case we actually
+ escape the string. [<aduryagin gmail.com>] PR 57230.
+
+ *) pollcb on Windows: Handle calls with no file/socket descriptors.
+ Follow up to PR 49882. [Jeff Trawick, Yann Ylavic]
+
+ *) apr_poll(cb): fix error paths returned values and leaks. [Yann Ylavic]
+
+ *) apr_thread_cond_*wait() on BeOS: Fix broken logic. PR 45800.
+ [Jochen Voss (no e-mail)]
+
+ *) apr_skiplist: Optimize the number of allocations by reusing pooled or
+ malloc()ed nodes for the lifetime of the skiplist. [Yann Ylavic]
+
+ *) apr_skiplist: Fix possible multiple-free() on the same value in
+ apr_skiplist_remove_all(). [Yann Ylavic]
+
+ *) apr_pollset: On z/OS, threadsafe apr_pollset_poll() may return
+ "EDC8102I Operation would block" under load.
+ [Pat Odonnell <patod us.ibm.com>]
+
+ *) On z/OS, apr_sockaddr_info_get() with family == APR_UNSPEC was not
+ returning IPv4 addresses if any IPv6 addresses were returned.
+ [Eric Covener]
+
+ *) Windows cmake build: Fix an incompatibility with cmake 2.8.12 and
+ later. [Jeff Trawick]
+
+ *) apr_global_mutex/apr_proc_mutex: Resolve failures with the
+ POSIX sem implementation in environments which receive signals.
+ [Jeff Trawick]
+
+ *) apr_skiplist: Fix potential corruption of skiplists leading to
+ results or crashes. [Takashi Sato <takashi tks st>, Eric Covener]
+ PR 56654.
+
+ *) Improve platform detection by updating config.guess and config.sub.
+ [Rainer Jung]
+
Changes for APR 1.5.1
*) apr_os_proc_mutex_get() on Unix: Avoid segfault for cross-
@@ -37,8 +96,8 @@ Changes for APR 1.5.1
*) 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]
+ *) Improve platform detection by updating config.guess and config.sub.
+ [Rainer Jung]
Changes for APR 1.5.0
diff --git a/contrib/apr/CMakeLists.txt b/contrib/apr/CMakeLists.txt
index 04903f9..75f35c7 100644
--- a/contrib/apr/CMakeLists.txt
+++ b/contrib/apr/CMakeLists.txt
@@ -234,6 +234,7 @@ SET(APR_TEST_SOURCES
test/testprocmutex.c
test/testrand.c
test/testshm.c
+ test/testskiplist.c
test/testsleep.c
test/testsock.c
test/testsockets.c
@@ -252,7 +253,6 @@ SET(APR_TEST_SOURCES
SET(install_targets)
SET(install_bin_pdb)
-SET(install_lib_pdb)
# libapr-1 is shared, apr-1 is static
ADD_LIBRARY(libapr-1 SHARED ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED} libapr.rc)
@@ -264,7 +264,6 @@ 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;WINNT")
ADD_DEPENDENCIES(apr-1 test_char_header)
@@ -272,12 +271,10 @@ 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_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;WINNT")
IF(APR_BUILD_TESTAPR)
@@ -394,10 +391,6 @@ IF(INSTALL_PDB)
INSTALL(FILES ${install_bin_pdb}
DESTINATION bin
CONFIGURATIONS RelWithDebInfo Debug)
-
- INSTALL(FILES ${install_lib_pdb}
- DESTINATION lib
- CONFIGURATIONS RelWithDebInfo Debug)
ENDIF()
INSTALL(FILES ${APR_PUBLIC_HEADERS_STATIC} ${APR_PUBLIC_HEADERS_GENERATED} DESTINATION include)
diff --git a/contrib/apr/Makefile.in b/contrib/apr/Makefile.in
index 6f99733..a2a5194 100644
--- a/contrib/apr/Makefile.in
+++ b/contrib/apr/Makefile.in
@@ -129,11 +129,11 @@ check: $(TARGET_LIB)
etags:
etags `find . -name '*.[ch]'`
-make_tools_dir:
+OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
+tools/gen_test_char.lo: tools/gen_test_char.c
$(APR_MKDIR) tools
+ $(LT_COMPILE)
-OBJECTS_gen_test_char = tools/gen_test_char.lo $(LOCAL_LIBS)
-tools/gen_test_char.lo: make_tools_dir
tools/gen_test_char@EXEEXT@: $(OBJECTS_gen_test_char)
$(LINK_PROG) $(OBJECTS_gen_test_char) $(ALL_LIBS)
diff --git a/contrib/apr/NOTICE b/contrib/apr/NOTICE
index b16965b..cd3576d 100644
--- a/contrib/apr/NOTICE
+++ b/contrib/apr/NOTICE
@@ -1,5 +1,5 @@
Apache Portable Runtime
-Copyright (c) 2000-2014 The Apache Software Foundation.
+Copyright (c) 2000-2015 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
diff --git a/contrib/apr/NWGNUmakefile b/contrib/apr/NWGNUmakefile
index 3f789eb..db15c0d 100644
--- a/contrib/apr/NWGNUmakefile
+++ b/contrib/apr/NWGNUmakefile
@@ -50,6 +50,7 @@ include $(APR_WORK)/build/NWGNUhead.inc
#
XINCDIRS += \
$(APR)/include \
+ $(APR)/include/private \
$(APR)/include/arch/NetWare \
$(APR)/include/arch/unix \
$(APR)/memory/unix \
@@ -293,11 +294,13 @@ FILES_nlm_exports = \
FILES_lib_objs = \
$(OBJDIR)/apr_atomic.o \
$(OBJDIR)/apr_cpystrn.o \
+ $(OBJDIR)/apr_escape.o \
$(OBJDIR)/apr_fnmatch.o \
$(OBJDIR)/apr_getpass.o \
$(OBJDIR)/apr_hash.o \
$(OBJDIR)/apr_pools.o \
$(OBJDIR)/apr_random.o \
+ $(OBJDIR)/apr_skiplist.o \
$(OBJDIR)/apr_snprintf.o \
$(OBJDIR)/apr_strings.o \
$(OBJDIR)/apr_strnatcmp.o \
@@ -407,7 +410,7 @@ endif
vpath %.c atomic/netware:strings:tables:passwd:lib:time/unix
vpath %.c file_io/unix:locks/netware:misc/netware:misc/unix:threadproc/netware
vpath %.c poll/unix:shmem/unix:support/unix:random/unix
-vpath %.c dso/netware:memory/unix:mmap/unix:user/netware
+vpath %.c dso/netware:memory/unix:mmap/unix:user/netware:encoding
# Use the win32 network_io if Winsock is being used
ifndef USE_STDSOCKETS
diff --git a/contrib/apr/apr.dsp b/contrib/apr/apr.dsp
index bbba926..6e25437 100644
--- a/contrib/apr/apr.dsp
+++ b/contrib/apr/apr.dsp
@@ -907,69 +907,6 @@ SOURCE=.\include\apr_version.h
# Begin Source File
SOURCE=.\include\apr_want.h
-
-!IF "$(CFG)" == "apr - Win32 Release"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "apr - Win32 Debug"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "apr - Win32 Release9x"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\9x\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "apr - Win32 Debug9x"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\9x\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "apr - x64 Release"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\x64\LibR\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "apr - x64 Debug"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\x64\LibD\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ENDIF
-
# End Source File
# End Group
# End Target
diff --git a/contrib/apr/apr.spec b/contrib/apr/apr.spec
index b3db167..9761158 100644
--- a/contrib/apr/apr.spec
+++ b/contrib/apr/apr.spec
@@ -3,7 +3,7 @@
Summary: Apache Portable Runtime library
Name: apr
-Version: 1.5.1
+Version: 1.5.2
Release: 1
License: Apache Software License
Group: System Environment/Libraries
@@ -76,7 +76,7 @@ rm -rf $RPM_BUILD_ROOT
%defattr(-,root,root,-)
%doc docs/APRDesign.html docs/canonical_filenames.html
%doc docs/incomplete_types docs/non_apr_programs
-%doc --parents html
+%doc html
%{_bindir}/apr*config
%{_libdir}/libapr-%{aprver}.*a
%{_libdir}/libapr-%{aprver}.so
diff --git a/contrib/apr/build-outputs.mk b/contrib/apr/build-outputs.mk
index 526f179..275e3ec 100644
--- a/contrib/apr/build-outputs.mk
+++ b/contrib/apr/build-outputs.mk
@@ -251,7 +251,7 @@ file_io/win32/filestat.lo: file_io/win32/filestat.c .make.dirs include/apr_alloc
file_io/win32/filesys.lo: file_io/win32/filesys.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_want.h
file_io/win32/flock.lo: file_io/win32/flock.c .make.dirs
file_io/win32/open.lo: file_io/win32/open.c .make.dirs include/apr_allocator.h include/apr_dso.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_global_mutex.h include/apr_inherit.h include/apr_network_io.h include/apr_pools.h include/apr_portable.h include/apr_proc_mutex.h include/apr_shm.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_thread_proc.h include/apr_time.h include/apr_user.h include/apr_want.h
-file_io/win32/pipe.lo: file_io/win32/pipe.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
+file_io/win32/pipe.lo: file_io/win32/pipe.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_escape.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/readwrite.lo: file_io/win32/readwrite.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_lib.h include/apr_pools.h include/apr_strings.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
file_io/win32/seek.lo: file_io/win32/seek.c .make.dirs include/apr_allocator.h include/apr_errno.h include/apr_file_info.h include/apr_file_io.h include/apr_general.h include/apr_inherit.h include/apr_pools.h include/apr_tables.h include/apr_thread_mutex.h include/apr_time.h include/apr_user.h include/apr_want.h
diff --git a/contrib/apr/configure b/contrib/apr/configure
index 860c65b..449c884 100755
--- a/contrib/apr/configure
+++ b/contrib/apr/configure
@@ -6802,10 +6802,10 @@ if test "x$apr_preload_done" != "xyes" ; then
*-apple-darwin*)
if test "x$CPPFLAGS" = "x"; then
- test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp\""
- CPPFLAGS="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp"
+ test "x$silent" != "xyes" && echo " setting CPPFLAGS to \"-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK\""
+ CPPFLAGS="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
else
- apr_addto_bugger="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -no-cpp-precomp"
+ apr_addto_bugger="-DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK"
for i in $apr_addto_bugger; do
apr_addto_duplicate="0"
for j in $CPPFLAGS; do
@@ -18794,7 +18794,34 @@ if test "${enable_nonportable_atomics+set}" = set; then :
else
case $host_cpu in
i[456]86) force_generic_atomics=yes ;;
- *) force_generic_atomics=no ;;
+ *) force_generic_atomics=no
+ case $host in
+ *solaris2.10*)
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <atomic.h>
+int
+main ()
+{
+void *ptr = NULL; atomic_cas_ptr(&ptr, NULL, NULL);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ force_generic_atomics=yes
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test $force_generic_atomics = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: nonportable atomic support disabled, system needs Patch-ID 118884 or 118885" >&5
+$as_echo "$as_me: nonportable atomic support disabled, system needs Patch-ID 118884 or 118885" >&6;}
+ fi
+ ;;
+ esac
+ ;;
esac
fi
@@ -22292,7 +22319,7 @@ else
fi
done
-for ac_func in getpass getpassphrase gmtime_r localtime_r mkstemp
+for ac_func in getpass getpassphrase gmtime_r localtime_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -22304,6 +22331,23 @@ _ACEOF
fi
done
+case $host in
+ *-hp-hpux*)
+ ;;
+ *)
+ for ac_func in mkstemp
+do :
+ ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
+if test "x$ac_cv_func_mkstemp" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MKSTEMP 1
+_ACEOF
+
+fi
+done
+
+ ;;
+esac
@@ -23902,7 +23946,7 @@ _ACEOF
if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
# Enable LFS
aprlfs=1
- for ac_func in mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r
+ for ac_func in mmap64 sendfile64 sendfilev64 readdir64_r
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -23914,6 +23958,23 @@ _ACEOF
fi
done
+ case $host in
+ *-hp-hpux*)
+ ;;
+ *)
+ for ac_func in mkstemp64
+do :
+ ac_fn_c_check_func "$LINENO" "mkstemp64" "ac_cv_func_mkstemp64"
+if test "x$ac_cv_func_mkstemp64" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MKSTEMP64 1
+_ACEOF
+
+fi
+done
+
+ ;;
+ esac
elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then
# unsure of using -gt above is as portable, can can't forsee where
# off_t can legitimately be smaller than size_t
diff --git a/contrib/apr/configure.in b/contrib/apr/configure.in
index 2a37a30..e01774b 100644
--- a/contrib/apr/configure.in
+++ b/contrib/apr/configure.in
@@ -640,7 +640,20 @@ AC_ARG_ENABLE(nonportable-atomics,
],
[case $host_cpu in
i[[456]]86) force_generic_atomics=yes ;;
- *) force_generic_atomics=no ;;
+ *) force_generic_atomics=no
+ case $host in
+ *solaris2.10*)
+ AC_TRY_COMPILE(
+ [#include <atomic.h>],
+ [void *ptr = NULL; atomic_cas_ptr(&ptr, NULL, NULL);],,
+ [force_generic_atomics=yes]
+ )
+ if test $force_generic_atomics = yes; then
+ AC_MSG_NOTICE([nonportable atomic support disabled, system needs Patch-ID 118884 or 118885])
+ fi
+ ;;
+ esac
+ ;;
esac
])
@@ -1400,7 +1413,15 @@ if test "$native_mmap_emul" = "1"; then
mmap="1"
fi
AC_CHECK_FUNCS(memmove, [ have_memmove="1" ], [have_memmove="0" ])
-AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r mkstemp])
+AC_CHECK_FUNCS([getpass getpassphrase gmtime_r localtime_r])
+case $host in
+ *-hp-hpux*)
+ dnl mkstemp is limited to 26 temporary files (a-z); use APR replacement
+ ;;
+ *)
+ AC_CHECK_FUNCS(mkstemp)
+ ;;
+esac
AC_SUBST(fork)
AC_SUBST(have_inet_addr)
@@ -1801,7 +1822,15 @@ APR_CHECK_SIZEOF_EXTENDED([#include <sys/types.h>], off_t, 8)
if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
# Enable LFS
aprlfs=1
- AC_CHECK_FUNCS([mmap64 sendfile64 sendfilev64 mkstemp64 readdir64_r])
+ AC_CHECK_FUNCS([mmap64 sendfile64 sendfilev64 readdir64_r])
+ case $host in
+ *-hp-hpux*)
+ dnl mkstemp64 is limited to 26 temporary files (a-z); use APR replacement
+ ;;
+ *)
+ AC_CHECK_FUNCS(mkstemp64)
+ ;;
+ esac
elif test "${ac_cv_sizeof_off_t}" != "${ac_cv_sizeof_size_t}"; then
# unsure of using -gt above is as portable, can can't forsee where
# off_t can legitimately be smaller than size_t
diff --git a/contrib/apr/encoding/apr_escape.c b/contrib/apr/encoding/apr_escape.c
index 2bcfec4..702a941 100644
--- a/contrib/apr/encoding/apr_escape.c
+++ b/contrib/apr/encoding/apr_escape.c
@@ -436,6 +436,8 @@ APR_DECLARE(apr_status_t) apr_escape_path(char *escaped, const char *path,
while ((c = *s) && slen) {
if (TEST_CHAR(c, T_OS_ESCAPE_PATH)) {
d = c2x(c, '%', d);
+ size += 2;
+ found = 1;
}
else {
*d++ = c;
diff --git a/contrib/apr/include/apr_skiplist.h b/contrib/apr/include/apr_skiplist.h
index bc17efd..f56ff22 100644
--- a/contrib/apr/include/apr_skiplist.h
+++ b/contrib/apr/include/apr_skiplist.h
@@ -40,7 +40,9 @@ extern "C" {
/**
* 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
+ * order. A value <0 indicates placement after this node; a value of 0
+ * indicates collision with this exact node; a value >0 indicates placement
+ * before this node.
* */
typedef int (*apr_skiplist_compare) (void *, void *);
@@ -171,7 +173,8 @@ APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter)
APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **iter);
/**
- * Insert an element into the skip list using the specified comparison function.
+ * Insert an element into the skip list using the specified comparison function
+ * if it does not already exist.
* @param sl The skip list
* @param data The element to insert
* @param comp The comparison function to use for placement into the skip list
@@ -180,7 +183,8 @@ 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.
+ * Insert an element into the skip list using the existing comparison function
+ * if it does not already exist (as determined by the 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
@@ -190,7 +194,7 @@ 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.
+ * locating the element. In the case of duplicates, the 1st entry will be removed.
* @param sl The skip list
* @param data The element to remove
* @param myfree A function to be called for each removed element
@@ -203,7 +207,7 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sl, void *data,
/**
* Remove an element from the skip list using the existing comparison function for
- * locating the element.
+ * locating the element. In the case of duplicates, the 1st entry will be removed.
* @param sl The skip list
* @param data The element to remove
* @param myfree A function to be called for each removed element
@@ -229,7 +233,7 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefun
APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc myfree);
/**
- * Return the first element in the skip list, leaving the element in the skip list.
+ * Return the first element in the skip list, removing the element from 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
diff --git a/contrib/apr/include/apr_version.h b/contrib/apr/include/apr_version.h
index 2111053..c7cbb8f 100644
--- a/contrib/apr/include/apr_version.h
+++ b/contrib/apr/include/apr_version.h
@@ -38,7 +38,7 @@
*/
-#define APR_COPYRIGHT "Copyright (c) 2000-2014 The Apache Software " \
+#define APR_COPYRIGHT "Copyright (c) 2000-2015 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 1
+#define APR_PATCH_VERSION 2
/**
* The symbol APR_IS_DEV_VERSION is only defined for internal,
diff --git a/contrib/apr/libapr.dsp b/contrib/apr/libapr.dsp
index f121ef9..2678832 100644
--- a/contrib/apr/libapr.dsp
+++ b/contrib/apr/libapr.dsp
@@ -765,7 +765,7 @@ SOURCE=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Release\gen_test_char /Fe.\Release\gen_test_char.exe .\tools\gen_test_char.c
.\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -776,7 +776,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\Debug\gen_test_char /Fe.\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -787,7 +787,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\9x\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\9x\Release\gen_test_char /Fe.\9x\Release\gen_test_char.exe .\tools\gen_test_char.c
.\9x\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -798,7 +798,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\9x\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\9x\Debug\gen_test_char /Fe.\9x\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\9x\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -809,7 +809,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\x64\Release\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Release\gen_test_char /Fe.\x64\Release\gen_test_char.exe .\tools\gen_test_char.c
.\x64\Release\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -820,7 +820,7 @@ InputPath=.\include\apr_escape.h
# Begin Custom Build - Creating gen_test_char.exe and apr_escape_test_char.h
InputPath=.\include\apr_escape.h
-".\x64\Debug\gen_test_char.exe" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
cl.exe /nologo /W3 /EHsc /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /I ".\include" /Fo.\x64\Debug\gen_test_char /Fe.\x64\Debug\gen_test_char.exe .\tools\gen_test_char.c
.\x64\Debug\gen_test_char.exe > .\include\apr_escape_test_char.h
@@ -952,69 +952,6 @@ SOURCE=.\include\apr_version.h
# Begin Source File
SOURCE=.\include\apr_want.h
-
-!IF "$(CFG)" == "libapr - Win32 Release"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "libapr - Win32 Debug"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "libapr - Win32 Release9x"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "libapr - Win32 Debug9x"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "libapr - x64 Release"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ELSEIF "$(CFG)" == "libapr - x64 Debug"
-
-# Begin Custom Build
-InputPath=.\include\apr_want.h
-
-".\include\apr_escape_test_char.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
- type .\include\apr.hw > .\include\apr.h
-
-# End Custom Build
-
-!ENDIF
-
# End Source File
# End Group
# Begin Source File
diff --git a/contrib/apr/locks/unix/proc_mutex.c b/contrib/apr/locks/unix/proc_mutex.c
index fa8a872..32012a7 100644
--- a/contrib/apr/locks/unix/proc_mutex.c
+++ b/contrib/apr/locks/unix/proc_mutex.c
@@ -114,7 +114,9 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
usec = apr_time_usec(now);
apr_snprintf(semname, sizeof(semname), "/ApR.%lxZ%lx", sec, usec);
}
- psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+ do {
+ psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+ } while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
if (psem == (sem_t *)SEM_FAILED) {
if (errno == ENAMETOOLONG) {
/* Oh well, good try */
@@ -122,7 +124,9 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
} else {
return errno;
}
- psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+ do {
+ psem = sem_open(semname, O_CREAT | O_EXCL, 0644, 1);
+ } while (psem == (sem_t *)SEM_FAILED && errno == EINTR);
}
if (psem == (sem_t *)SEM_FAILED) {
@@ -140,7 +144,12 @@ static apr_status_t proc_mutex_posix_create(apr_proc_mutex_t *new_mutex,
static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
{
- if (sem_wait(mutex->psem_interproc) < 0) {
+ int rc;
+
+ do {
+ rc = sem_wait(mutex->psem_interproc);
+ } while (rc < 0 && errno == EINTR);
+ if (rc < 0) {
return errno;
}
mutex->curr_locked = 1;
@@ -149,7 +158,12 @@ static apr_status_t proc_mutex_posix_acquire(apr_proc_mutex_t *mutex)
static apr_status_t proc_mutex_posix_tryacquire(apr_proc_mutex_t *mutex)
{
- if (sem_trywait(mutex->psem_interproc) < 0) {
+ int rc;
+
+ do {
+ rc = sem_trywait(mutex->psem_interproc);
+ } while (rc < 0 && errno == EINTR);
+ if (rc < 0) {
if (errno == EAGAIN) {
return APR_EBUSY;
}
diff --git a/contrib/apr/memory/unix/apr_pools.c b/contrib/apr/memory/unix/apr_pools.c
index 5c1a1ff..20e4254 100644
--- a/contrib/apr/memory/unix/apr_pools.c
+++ b/contrib/apr/memory/unix/apr_pools.c
@@ -1135,21 +1135,12 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
* room to hold the NUL terminator.
*/
if (ps.node->first_avail == ps.node->endp) {
- if (psprintf_flush(&ps.vbuff) == -1) {
- if (pool->abort_fn) {
- pool->abort_fn(APR_ENOMEM);
- }
-
- return NULL;
- }
+ if (psprintf_flush(&ps.vbuff) == -1)
+ goto error;
}
- if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1) {
- if (pool->abort_fn)
- pool->abort_fn(APR_ENOMEM);
-
- return NULL;
- }
+ if (apr_vformatter(psprintf_flush, &ps.vbuff, fmt, ap) == -1)
+ goto error;
strp = ps.vbuff.curpos;
*strp++ = '\0';
@@ -1195,6 +1186,15 @@ APR_DECLARE(char *) apr_pvsprintf(apr_pool_t *pool, const char *fmt, va_list ap)
list_insert(active, node);
return strp;
+
+error:
+ if (pool->abort_fn)
+ pool->abort_fn(APR_ENOMEM);
+ if (ps.got_a_new_node) {
+ ps.node->next = ps.free;
+ allocator_free(pool->allocator, ps.node);
+ }
+ return NULL;
}
diff --git a/contrib/apr/misc/unix/errorcodes.c b/contrib/apr/misc/unix/errorcodes.c
index 75567c2..f553a37 100644
--- a/contrib/apr/misc/unix/errorcodes.c
+++ b/contrib/apr/misc/unix/errorcodes.c
@@ -39,6 +39,8 @@ static char *stuffbuffer(char *buf, apr_size_t bufsize, const char *s)
static char *apr_error_string(apr_status_t statcode)
{
switch (statcode) {
+ case APR_ENOSTAT:
+ return "Could not perform a stat on the file.";
case APR_ENOPOOL:
return "A new pool could not be created.";
case APR_EBADDATE:
@@ -73,7 +75,10 @@ static char *apr_error_string(apr_status_t statcode)
return "The specified IP address is invalid.";
case APR_EBADMASK:
return "The specified network mask is invalid.";
-
+ case APR_ESYMNOTFOUND:
+ return "Could not find the requested symbol.";
+ case APR_ENOTENOUGHENTROPY:
+ return "Not enough entropy to continue.";
case APR_INCHILD:
return
"Your code just forked, and you are currently executing in the "
@@ -128,10 +133,12 @@ static char *apr_error_string(apr_status_t statcode)
return "The given path is misformatted or contained invalid characters";
case APR_EPATHWILD:
return "The given path contained wildcard characters";
+ case APR_EBUSY:
+ return "The given lock was busy.";
case APR_EPROC_UNKNOWN:
return "The process is not recognized.";
case APR_EGENERAL:
- return "Internal error";
+ return "Internal error (specific information not available)";
default:
return "Error string not specified yet";
}
diff --git a/contrib/apr/network_io/unix/sockaddr.c b/contrib/apr/network_io/unix/sockaddr.c
index 0dd1a2d..e6d7e0b 100644
--- a/contrib/apr/network_io/unix/sockaddr.c
+++ b/contrib/apr/network_io/unix/sockaddr.c
@@ -325,6 +325,16 @@ static apr_status_t call_resolver(apr_sockaddr_t **sa,
hints.ai_flags = AI_ADDRCONFIG;
}
#endif
+
+#ifdef __MVS__
+ /* z/OS will not return IPv4 address under AF_UNSPEC if any IPv6 results
+ * are returned, w/o AI_ALL.
+ */
+ if (family == APR_UNSPEC) {
+ hints.ai_flags |= AI_ALL;
+ }
+#endif
+
if(hostname == NULL) {
#ifdef AI_PASSIVE
/* If hostname is NULL, assume we are trying to bind to all
diff --git a/contrib/apr/network_io/unix/sockets.c b/contrib/apr/network_io/unix/sockets.c
index 514edb1..b95794f 100644
--- a/contrib/apr/network_io/unix/sockets.c
+++ b/contrib/apr/network_io/unix/sockets.c
@@ -145,13 +145,22 @@ apr_status_t apr_socket_create(apr_socket_t **new, int ofamily, int type,
#ifndef HAVE_SOCK_CLOEXEC
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
}
#endif
@@ -306,13 +315,22 @@ apr_status_t apr_socket_accept(apr_socket_t **new, apr_socket_t *sock,
#ifndef HAVE_ACCEPT4
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl((*new)->socketdes, F_GETFD)) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl((*new)->socketdes, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl((*new)->socketdes, F_SETFD, flags) == -1) {
+ rv = errno;
+ close((*new)->socketdes);
+ (*new)->socketdes = -1;
+ return rv;
+ }
}
#endif
diff --git a/contrib/apr/poll/unix/epoll.c b/contrib/apr/poll/unix/epoll.c
index 326dac7..fe006db 100644
--- a/contrib/apr/poll/unix/epoll.c
+++ b/contrib/apr/poll/unix/epoll.c
@@ -104,14 +104,22 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
#ifndef HAVE_EPOLL_CREATE1
{
- int flags;
+ int fd_flags;
- if ((flags = fcntl(fd, F_GETFD)) == -1)
- return errno;
+ if ((fd_flags = fcntl(fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(fd);
+ pollset->p = NULL;
+ return rv;
+ }
- flags |= FD_CLOEXEC;
- if (fcntl(fd, F_SETFD, flags) == -1)
- return errno;
+ fd_flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, fd_flags) == -1) {
+ rv = errno;
+ close(fd);
+ pollset->p = NULL;
+ return rv;
+ }
}
#endif
@@ -122,11 +130,13 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
((rv = apr_thread_mutex_create(&pollset->p->ring_lock,
APR_THREAD_MUTEX_DEFAULT,
p)) != APR_SUCCESS)) {
+ close(fd);
pollset->p = NULL;
return rv;
}
#else
if (flags & APR_POLLSET_THREADSAFE) {
+ close(fd);
pollset->p = NULL;
return APR_ENOTIMPL;
}
@@ -345,14 +355,23 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
#ifndef HAVE_EPOLL_CREATE1
{
- int flags;
-
- if ((flags = fcntl(fd, F_GETFD)) == -1)
- return errno;
+ int fd_flags;
+ apr_status_t rv;
+
+ if ((fd_flags = fcntl(fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(fd);
+ pollcb->fd = -1;
+ return rv;
+ }
- flags |= FD_CLOEXEC;
- if (fcntl(fd, F_SETFD, flags) == -1)
- return errno;
+ fd_flags |= FD_CLOEXEC;
+ if (fcntl(fd, F_SETFD, fd_flags) == -1) {
+ rv = errno;
+ close(fd);
+ pollcb->fd = -1;
+ return rv;
+ }
}
#endif
diff --git a/contrib/apr/poll/unix/kqueue.c b/contrib/apr/poll/unix/kqueue.c
index dbe785a..efc5898 100644
--- a/contrib/apr/poll/unix/kqueue.c
+++ b/contrib/apr/poll/unix/kqueue.c
@@ -115,12 +115,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
{
int flags;
- if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl(pollset->p->kqueue_fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(pollset->p->kqueue_fd);
+ pollset->p = NULL;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl(pollset->p->kqueue_fd, F_SETFD, flags) == -1) {
+ rv = errno;
+ close(pollset->p->kqueue_fd);
+ pollset->p = NULL;
+ return rv;
+ }
}
pollset->p->result_set = apr_palloc(p, pollset->p->setsize * sizeof(apr_pollfd_t));
@@ -338,13 +346,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl(fd, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl(fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(fd);
+ pollcb->fd = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl(fd, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl(fd, F_SETFD, flags) == -1) {
+ rv = errno;
+ close(fd);
+ pollcb->fd = -1;
+ return rv;
+ }
}
pollcb->fd = fd;
diff --git a/contrib/apr/poll/unix/poll.c b/contrib/apr/poll/unix/poll.c
index 7d15736..d7a436f 100644
--- a/contrib/apr/poll/unix/poll.c
+++ b/contrib/apr/poll/unix/poll.c
@@ -240,26 +240,25 @@ static apr_status_t impl_pollset_poll(apr_pollset_t *pollset,
{
int ret;
apr_status_t rv = APR_SUCCESS;
-#ifdef WIN32
- apr_interval_time_t orig_timeout = timeout;
-#endif
- if (timeout > 0) {
- timeout /= 1000;
- }
#ifdef WIN32
/* WSAPoll() requires at least one socket. */
if (pollset->nelts == 0) {
*num = 0;
- if (orig_timeout > 0) {
- apr_sleep(orig_timeout);
+ if (timeout > 0) {
+ apr_sleep(timeout);
return APR_TIMEUP;
}
return APR_SUCCESS;
}
-
+ if (timeout > 0) {
+ timeout /= 1000;
+ }
ret = WSAPoll(pollset->p->pollset, pollset->nelts, (int)timeout);
#else
+ if (timeout > 0) {
+ timeout /= 1000;
+ }
ret = poll(pollset->p->pollset, pollset->nelts, timeout);
#endif
(*num) = ret;
@@ -398,12 +397,23 @@ static apr_status_t impl_pollcb_poll(apr_pollcb_t *pollcb,
apr_status_t rv = APR_SUCCESS;
apr_uint32_t i;
+#ifdef WIN32
+ /* WSAPoll() requires at least one socket. */
+ if (pollcb->nelts == 0) {
+ if (timeout > 0) {
+ apr_sleep(timeout);
+ return APR_TIMEUP;
+ }
+ return APR_SUCCESS;
+ }
if (timeout > 0) {
timeout /= 1000;
}
-#ifdef WIN32
ret = WSAPoll(pollcb->pollset.ps, pollcb->nelts, (int)timeout);
#else
+ if (timeout > 0) {
+ timeout /= 1000;
+ }
ret = poll(pollcb->pollset.ps, pollcb->nelts, timeout);
#endif
if (ret < 0) {
diff --git a/contrib/apr/poll/unix/pollcb.c b/contrib/apr/poll/unix/pollcb.c
index 24f8010..da12f01 100644
--- a/contrib/apr/poll/unix/pollcb.c
+++ b/contrib/apr/poll/unix/pollcb.c
@@ -136,6 +136,9 @@ APR_DECLARE(apr_status_t) apr_pollcb_create_ex(apr_pollcb_t **ret_pollcb,
}
pollcb->provider = provider;
}
+ else if (rv != APR_SUCCESS) {
+ return rv;
+ }
*ret_pollcb = pollcb;
return APR_SUCCESS;
diff --git a/contrib/apr/poll/unix/port.c b/contrib/apr/poll/unix/port.c
index 7a31c46..5002dfd 100644
--- a/contrib/apr/poll/unix/port.c
+++ b/contrib/apr/poll/unix/port.c
@@ -188,12 +188,20 @@ static apr_status_t impl_pollset_create(apr_pollset_t *pollset,
{
int flags;
- if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl(pollset->p->port_fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(pollset->p->port_fd);
+ pollset->p = NULL;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl(pollset->p->port_fd, F_SETFD, flags) == -1) {
+ rv = errno;
+ close(pollset->p->port_fd);
+ pollset->p = NULL;
+ return rv;
+ }
}
pollset->p->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
@@ -478,13 +486,22 @@ static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
{
int flags;
+ apr_status_t rv;
- if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1)
- return errno;
+ if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1) {
+ rv = errno;
+ close(pollcb->fd);
+ pollcb->fd = -1;
+ return rv;
+ }
flags |= FD_CLOEXEC;
- if (fcntl(pollcb->fd, F_SETFD, flags) == -1)
- return errno;
+ if (fcntl(pollcb->fd, F_SETFD, flags) == -1) {
+ rv = errno;
+ close(pollcb->fd);
+ pollcb->fd = -1;
+ return rv;
+ }
}
pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
diff --git a/contrib/apr/poll/unix/z_asio.c b/contrib/apr/poll/unix/z_asio.c
index ce158d3..7e0fd89 100644
--- a/contrib/apr/poll/unix/z_asio.c
+++ b/contrib/apr/poll/unix/z_asio.c
@@ -272,7 +272,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
APR_THREAD_MUTEX_DEFAULT,
p) != APR_SUCCESS) {
DBG1(1, "apr_thread_mutex_create returned %d\n", rv);
- pollset = NULL;
+ pollset->p = NULL;
return rv;
}
rv = msgget(IPC_PRIVATE, S_IWUSR+S_IRUSR); /* user r/w perms */
@@ -280,7 +280,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
#if DEBUG
perror(__FUNCTION__ " msgget returned < 0 ");
#endif
- pollset = NULL;
+ pollset->p = NULL;
return rv;
}
@@ -292,7 +292,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
APR_RING_INIT(&priv->prior_ready_ring, asio_elem_t, link);
#else /* APR doesn't have threads but caller wants a threadsafe pollset */
- pollset = NULL;
+ pollset->p = NULL;
return APR_ENOTIMPL;
#endif
@@ -304,6 +304,7 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
priv->query_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
if ((!priv->pollset) || (!priv->query_set)) {
+ pollset->p = NULL;
return APR_ENOMEM;
}
}
@@ -314,6 +315,10 @@ static apr_status_t asio_pollset_create(apr_pollset_t *pollset,
priv->size = size;
priv->result_set = apr_palloc(p, size * sizeof(apr_pollfd_t));
if (!priv->result_set) {
+ if (flags & APR_POLLSET_THREADSAFE) {
+ msgctl(priv->msg_q, IPC_RMID, NULL);
+ }
+ pollset->p = NULL;
return APR_ENOMEM;
}
@@ -379,6 +384,7 @@ static apr_status_t asio_pollset_add(apr_pollset_t *pollset,
APR_RING_REMOVE(elem, link);
DBG1(3, "used recycled memory at %08p\n", elem);
elem->state = ASIO_INIT;
+ elem->a.aio_cflags = 0;
}
else {
elem = (asio_elem_t *) apr_pcalloc(pollset->pool, sizeof(asio_elem_t));
@@ -659,6 +665,7 @@ static apr_status_t asio_pollset_poll(apr_pollset_t *pollset,
if (ret == 1) {
DBG(4, "asyncio() completed inline\n");
/* it's ready now */
+ elem->state = ASIO_COMPLETE;
APR_RING_INSERT_TAIL(&(priv->ready_ring), elem, asio_elem_t,
link);
}
diff --git a/contrib/apr/tables/apr_skiplist.c b/contrib/apr/tables/apr_skiplist.c
index effcf60..b4696bd 100644
--- a/contrib/apr/tables/apr_skiplist.c
+++ b/contrib/apr/tables/apr_skiplist.c
@@ -25,12 +25,18 @@
#include "apr_skiplist.h"
+typedef struct {
+ apr_skiplistnode **data;
+ size_t size, pos;
+ apr_pool_t *p;
+} apr_skiplist_q;
+
struct apr_skiplist {
apr_skiplist_compare compare;
apr_skiplist_compare comparek;
int height;
int preheight;
- int size;
+ size_t size;
apr_skiplistnode *top;
apr_skiplistnode *bottom;
/* These two are needed for appending */
@@ -38,6 +44,8 @@ struct apr_skiplist {
apr_skiplistnode *bottomend;
apr_skiplist *index;
apr_array_header_t *memlist;
+ apr_skiplist_q nodes_q,
+ stack_q;
apr_pool_t *pool;
};
@@ -52,20 +60,15 @@ struct apr_skiplistnode {
apr_skiplist *sl;
};
-#ifndef MIN
-#define MIN(a,b) ((a<b)?(a):(b))
-#endif
-
static int get_b_rand(void)
{
static int ph = 32; /* More bits than we will ever use */
- static apr_uint32_t randseq;
+ static int randseq;
if (ph > 31) { /* Num bits in return of rand() */
ph = 0;
- randseq = (apr_uint32_t) rand();
+ randseq = rand();
}
- ph++;
- return ((randseq & (1 << (ph - 1))) >> (ph - 1));
+ return randseq & (1 << ph++);
}
typedef struct {
@@ -103,7 +106,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(apr_skiplist *sl, size_t size)
memlist++;
}
/* no free chunks */
- ptr = apr_pcalloc(sl->pool, size);
+ ptr = apr_palloc(sl->pool, size);
if (!ptr) {
return ptr;
}
@@ -122,7 +125,7 @@ APR_DECLARE(void *) apr_skiplist_alloc(apr_skiplist *sl, size_t size)
return ptr;
}
else {
- return calloc(1, size);
+ return malloc(size);
}
}
@@ -149,27 +152,73 @@ APR_DECLARE(void) apr_skiplist_free(apr_skiplist *sl, void *mem)
}
}
+static apr_status_t skiplist_qpush(apr_skiplist_q *q, apr_skiplistnode *m)
+{
+ if (q->pos >= q->size) {
+ apr_skiplistnode **data;
+ size_t size = (q->pos) ? q->pos * 2 : 32;
+ if (q->p) {
+ data = apr_palloc(q->p, size * sizeof(*data));
+ if (data) {
+ memcpy(data, q->data, q->pos * sizeof(*data));
+ }
+ }
+ else {
+ data = realloc(q->data, size * sizeof(*data));
+ }
+ if (!data) {
+ return APR_ENOMEM;
+ }
+ q->data = data;
+ q->size = size;
+ }
+ q->data[q->pos++] = m;
+ return APR_SUCCESS;
+}
+
+static APR_INLINE apr_skiplistnode *skiplist_qpop(apr_skiplist_q *q)
+{
+ return (q->pos > 0) ? q->data[--q->pos] : NULL;
+}
+
+static APR_INLINE void skiplist_qclear(apr_skiplist_q *q)
+{
+ q->pos = 0;
+}
+
+static apr_skiplistnode *skiplist_new_node(apr_skiplist *sl)
+{
+ apr_skiplistnode *m = skiplist_qpop(&sl->nodes_q);
+ if (!m) {
+ if (sl->pool) {
+ m = apr_palloc(sl->pool, sizeof *m);
+ }
+ else {
+ m = malloc(sizeof *m);
+ }
+ }
+ return m;
+}
+
+static apr_status_t skiplist_free_node(apr_skiplist *sl, apr_skiplistnode *m)
+{
+ return skiplist_qpush(&sl->nodes_q, m);
+}
+
static apr_status_t skiplisti_init(apr_skiplist **s, apr_pool_t *p)
{
apr_skiplist *sl;
if (p) {
sl = apr_pcalloc(p, sizeof(apr_skiplist));
sl->memlist = apr_array_make(p, 20, sizeof(memlist_t));
+ sl->pool = sl->nodes_q.p = sl->stack_q.p = p;
}
else {
sl = calloc(1, sizeof(apr_skiplist));
+ if (!sl) {
+ return APR_ENOMEM;
+ }
}
-#if 0
- sl->compare = (apr_skiplist_compare) NULL;
- sl->comparek = (apr_skiplist_compare) NULL;
- sl->height = 0;
- sl->preheight = 0;
- sl->size = 0;
- sl->top = NULL;
- sl->bottom = NULL;
- sl->index = NULL;
-#endif
- sl->pool = p;
*s = sl;
return APR_SUCCESS;
}
@@ -248,56 +297,32 @@ APR_DECLARE(void) apr_skiplist_add_index(apr_skiplist *sl,
}
}
-APR_DECLARE(apr_skiplistnode *) apr_skiplist_getlist(apr_skiplist *sl)
-{
- if (!sl->bottom) {
- return NULL;
- }
- return sl->bottom->next;
-}
-
-APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter)
-{
- void *ret;
- apr_skiplistnode *aiter;
- if (!sl->compare) {
- return 0;
- }
- if (iter) {
- ret = apr_skiplist_find_compare(sl, data, iter, sl->compare);
- }
- else {
- ret = apr_skiplist_find_compare(sl, data, &aiter, sl->compare);
- }
- return ret;
-}
-
static int skiplisti_find_compare(apr_skiplist *sl, void *data,
apr_skiplistnode **ret,
apr_skiplist_compare comp)
{
- apr_skiplistnode *m = NULL;
int count = 0;
+ apr_skiplistnode *m;
m = sl->top;
while (m) {
- int compared;
- compared = (m->next) ? comp(data, m->next->data) : -1;
- if (compared == 0) {
- m = m->next;
- while (m->down) {
- m = m->down;
+ if (m->next) {
+ int compared = comp(data, m->next->data);
+ if (compared == 0) {
+ m = m->next;
+ while (m->down) {
+ m = m->down;
+ }
+ *ret = m;
+ return count;
+ }
+ if (compared > 0) {
+ m = m->next;
+ count++;
+ continue;
}
- *ret = m;
- return count;
- }
- if ((m->next == NULL) || (compared < 0)) {
- m = m->down;
- count++;
- }
- else {
- m = m->next;
- count++;
}
+ m = m->down;
+ count++;
}
*ret = NULL;
return count;
@@ -307,19 +332,47 @@ APR_DECLARE(void *) apr_skiplist_find_compare(apr_skiplist *sli, void *data,
apr_skiplistnode **iter,
apr_skiplist_compare comp)
{
- apr_skiplistnode *m = NULL;
+ apr_skiplistnode *m;
apr_skiplist *sl;
+ if (!comp) {
+ if (iter) {
+ *iter = NULL;
+ }
+ return NULL;
+ }
if (comp == sli->compare || !sli->index) {
sl = sli;
}
else {
apr_skiplist_find(sli->index, (void *)comp, &m);
+ if (!m) {
+ if (iter) {
+ *iter = NULL;
+ }
+ return NULL;
+ }
sl = (apr_skiplist *) m->data;
}
- skiplisti_find_compare(sl, data, iter, sl->comparek);
- return (iter && *iter) ? ((*iter)->data) : NULL;
+ skiplisti_find_compare(sl, data, &m, sl->comparek);
+ if (iter) {
+ *iter = m;
+ }
+ return (m) ? m->data : NULL;
}
+APR_DECLARE(void *) apr_skiplist_find(apr_skiplist *sl, void *data, apr_skiplistnode **iter)
+{
+ return apr_skiplist_find_compare(sl, data, iter, sl->compare);
+}
+
+
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_getlist(apr_skiplist *sl)
+{
+ if (!sl->bottom) {
+ return NULL;
+ }
+ return sl->bottom->next;
+}
APR_DECLARE(void *) apr_skiplist_next(apr_skiplist *sl, apr_skiplistnode **iter)
{
@@ -339,98 +392,74 @@ APR_DECLARE(void *) apr_skiplist_previous(apr_skiplist *sl, apr_skiplistnode **i
return (*iter) ? ((*iter)->data) : NULL;
}
-APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void *data)
+static APR_INLINE int skiplist_height(const apr_skiplist *sl)
{
- if (!sl->compare) {
- return 0;
- }
- return apr_skiplist_insert_compare(sl, data, sl->compare);
+ /* Skiplists (even empty) always have a top node, although this
+ * implementation defers its creation until the first insert, or
+ * deletes it with the last remove. We want the real height here.
+ */
+ return sl->height ? sl->height : 1;
}
APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, void *data,
apr_skiplist_compare comp)
{
- apr_skiplistnode *m, *p, *tmp, *ret = NULL, **stack;
- int nh = 1, ch, stacki;
- if (!sl->top) {
- sl->height = 1;
- sl->topend = sl->bottomend = sl->top = sl->bottom =
- (apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
-#if 0
- sl->top->next = (apr_skiplistnode *)NULL;
- sl->top->data = (apr_skiplistnode *)NULL;
- sl->top->prev = (apr_skiplistnode *)NULL;
- sl->top->up = (apr_skiplistnode *)NULL;
- sl->top->down = (apr_skiplistnode *)NULL;
- sl->top->nextindex = (apr_skiplistnode *)NULL;
- sl->top->previndex = (apr_skiplistnode *)NULL;
-#endif
- sl->top->sl = sl;
+ apr_skiplistnode *m, *p, *tmp, *ret = NULL;
+ int ch, nh = 1;
+
+ if (!comp) {
+ return NULL;
}
+
+ ch = skiplist_height(sl);
if (sl->preheight) {
while (nh < sl->preheight && get_b_rand()) {
nh++;
}
}
else {
- while (nh <= sl->height && get_b_rand()) {
+ while (nh <= ch && get_b_rand()) {
nh++;
}
}
- /* Now we have the new height at which we wish to insert our new node */
- /*
- * Let us make sure that our tree is a least that tall (grow if
- * necessary)
+
+ /* Now we have in nh the height at which we wish to insert our new node,
+ * and in ch the current height: don't create skip paths to the inserted
+ * element until the walk down through the tree (which decrements ch)
+ * reaches nh. From there, any walk down pushes the current node on a
+ * stack (the node(s) after which we would insert) to pop back through
+ * for insertion later.
*/
- for (; sl->height < nh; sl->height++) {
- sl->top->up =
- (apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
- sl->top->up->down = sl->top;
- sl->top = sl->topend = sl->top->up;
-#if 0
- sl->top->prev = sl->top->next = sl->top->nextindex =
- sl->top->previndex = sl->top->up = NULL;
- sl->top->data = NULL;
-#endif
- sl->top->sl = sl;
- }
- ch = sl->height;
- /* Find the node (or node after which we would insert) */
- /* Keep a stack to pop back through for insertion */
- /* malloc() is OK since we free the temp stack */
m = sl->top;
- stack = (apr_skiplistnode **)malloc(sizeof(apr_skiplistnode *) * (nh));
- stacki = 0;
while (m) {
- int compared = -1;
if (m->next) {
- compared = comp(data, m->next->data);
- }
- if (compared == 0) {
- free(stack); /* OK. was malloc'ed */
- return 0;
- }
- if ((m->next == NULL) || (compared < 0)) {
- if (ch <= nh) {
- /* push on stack */
- stack[stacki++] = m;
+ int compared = comp(data, m->next->data);
+ if (compared == 0) {
+ /* Keep the existing element(s) */
+ skiplist_qclear(&sl->stack_q);
+ return NULL;
+ }
+ if (compared > 0) {
+ m = m->next;
+ continue;
}
- m = m->down;
- ch--;
}
- else {
- m = m->next;
+ if (ch <= nh) {
+ /* push on stack */
+ skiplist_qpush(&sl->stack_q, m);
}
+ m = m->down;
+ ch--;
}
/* Pop the stack and insert nodes */
p = NULL;
- for (; stacki > 0; stacki--) {
- m = stack[stacki - 1];
- tmp = (apr_skiplistnode *)apr_skiplist_alloc(sl, sizeof(apr_skiplistnode));
+ while ((m = skiplist_qpop(&sl->stack_q))) {
+ tmp = skiplist_new_node(sl);
tmp->next = m->next;
if (m->next) {
m->next->prev = tmp;
}
+ m->next = tmp;
tmp->prev = m;
tmp->up = NULL;
tmp->nextindex = tmp->previndex = NULL;
@@ -438,17 +467,44 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, vo
if (p) {
p->up = tmp;
}
+ else {
+ /* This sets ret to the bottom-most node we are inserting */
+ ret = tmp;
+ }
tmp->data = data;
tmp->sl = sl;
+ p = tmp;
+ }
+
+ /* Now we are sure the node is inserted, grow our tree to 'nh' tall */
+ for (; sl->height < nh; sl->height++) {
+ m = skiplist_new_node(sl);
+ tmp = skiplist_new_node(sl);
+ m->up = m->prev = m->nextindex = m->previndex = NULL;
m->next = tmp;
- /* This sets ret to the bottom-most node we are inserting */
- if (!p) {
+ m->down = sl->top;
+ m->data = NULL;
+ m->sl = sl;
+ if (sl->top) {
+ sl->top->up = m;
+ }
+ else {
+ sl->bottom = sl->bottomend = m;
+ }
+ sl->top = sl->topend = tmp->prev = m;
+ tmp->up = tmp->next = tmp->nextindex = tmp->previndex = NULL;
+ tmp->down = p;
+ tmp->data = data;
+ tmp->sl = sl;
+ if (p) {
+ p->up = tmp;
+ }
+ else {
+ /* This sets ret to the bottom-most node we are inserting */
ret = tmp;
- sl->size++; /* this seems to go here got each element to be counted */
}
p = tmp;
}
- free(stack); /* OK. was malloc'ed */
if (sl->index != NULL) {
/*
* this is a external insertion, we must insert into each index as
@@ -457,25 +513,20 @@ APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert_compare(apr_skiplist *sl, vo
apr_skiplistnode *ni, *li;
li = ret;
for (p = apr_skiplist_getlist(sl->index); p; apr_skiplist_next(sl->index, &p)) {
- ni = apr_skiplist_insert((apr_skiplist *) p->data, ret->data);
+ apr_skiplist *sli = (apr_skiplist *)p->data;
+ ni = apr_skiplist_insert_compare(sli, ret->data, sli->compare);
li->nextindex = ni;
ni->previndex = li;
li = ni;
}
}
- else {
- /* sl->size++; */
- }
sl->size++;
return ret;
}
-APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, apr_skiplist_freefunc myfree)
+APR_DECLARE(apr_skiplistnode *) apr_skiplist_insert(apr_skiplist *sl, void *data)
{
- if (!sl->compare) {
- return 0;
- }
- return apr_skiplist_remove_compare(sl, data, myfree, sl->comparek);
+ return apr_skiplist_insert_compare(sl, data, sl->compare);
}
#if 0
@@ -520,7 +571,7 @@ static int skiplisti_remove(apr_skiplist *sl, apr_skiplistnode *m, apr_skiplist_
if (!m && myfree && p->data) {
myfree(p->data);
}
- apr_skiplist_free(sl, p);
+ skiplist_free_node(sl, p);
}
sl->size--;
while (sl->top && sl->top->next == NULL) {
@@ -530,13 +581,14 @@ static int skiplisti_remove(apr_skiplist *sl, apr_skiplistnode *m, apr_skiplist_
if (sl->top) {
sl->top->up = NULL; /* Make it think its the top */
}
- apr_skiplist_free(sl, p);
+ skiplist_free_node(sl, p);
sl->height--;
}
if (!sl->top) {
- sl->bottom = NULL;
+ sl->bottom = sl->bottomend = NULL;
+ sl->topend = NULL;
}
- return sl->height; /* return 1; ?? */
+ return skiplist_height(sl);
}
APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
@@ -545,11 +597,17 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
{
apr_skiplistnode *m;
apr_skiplist *sl;
+ if (!comp) {
+ return 0;
+ }
if (comp == sli->comparek || !sli->index) {
sl = sli;
}
else {
apr_skiplist_find(sli->index, (void *)comp, &m);
+ if (!m) {
+ return 0;
+ }
sl = (apr_skiplist *) m->data;
}
skiplisti_find_compare(sl, data, &m, comp);
@@ -562,6 +620,11 @@ APR_DECLARE(int) apr_skiplist_remove_compare(apr_skiplist *sli,
return skiplisti_remove(sl, m, myfree);
}
+APR_DECLARE(int) apr_skiplist_remove(apr_skiplist *sl, void *data, apr_skiplist_freefunc myfree)
+{
+ return apr_skiplist_remove_compare(sl, data, myfree, sl->comparek);
+}
+
APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefunc myfree)
{
/*
@@ -573,16 +636,18 @@ APR_DECLARE(void) apr_skiplist_remove_all(apr_skiplist *sl, apr_skiplist_freefun
m = sl->bottom;
while (m) {
p = m->next;
- if (p && myfree && p->data)
+ if (myfree && p && p->data) {
myfree(p->data);
- while (m) {
+ }
+ do {
u = m->up;
- apr_skiplist_free(sl, p);
+ skiplist_free_node(sl, m);
m = u;
- }
+ } while (m);
m = p;
}
sl->top = sl->bottom = NULL;
+ sl->topend = sl->bottomend = NULL;
sl->height = 0;
sl->size = 0;
}
@@ -611,8 +676,7 @@ APR_DECLARE(void *) apr_skiplist_peek(apr_skiplist *a)
static void skiplisti_destroy(void *vsl)
{
- apr_skiplist_destroy((apr_skiplist *) vsl, NULL);
- apr_skiplist_free((apr_skiplist *) vsl, vsl);
+ apr_skiplist_destroy(vsl, NULL);
}
APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc myfree)
@@ -620,6 +684,13 @@ APR_DECLARE(void) apr_skiplist_destroy(apr_skiplist *sl, apr_skiplist_freefunc m
while (apr_skiplist_pop(sl->index, skiplisti_destroy) != NULL)
;
apr_skiplist_remove_all(sl, myfree);
+ if (!sl->pool) {
+ while (sl->nodes_q.pos)
+ free(sl->nodes_q.data[--sl->nodes_q.pos]);
+ free(sl->nodes_q.data);
+ free(sl->stack_q.data);
+ free(sl);
+ }
}
APR_DECLARE(apr_skiplist *) apr_skiplist_merge(apr_skiplist *sl1, apr_skiplist *sl2)
OpenPOWER on IntegriCloud