Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

sync

  • Loading branch information...
commit 7f5acbc66a70115a337f75eb18fbc55dca6ee8b7 1 parent 3c6a6f4
@stefanocasazza authored
Showing with 1,006 additions and 8,873 deletions.
  1. +8 −8 README.md
  2. +25 −28 ULib.m4
  3. +17 −6 ULib.spec.in
  4. +49 −4 configure
  5. +10 −4 configure.in
  6. +1 −1  examples/uclient/uclient.cpp
  7. +8 −8 examples/userver/userver.cfg.default
  8. +7 −4 examples/userver/userver.cpp
  9. +3 −0  include/ulib/internal/config.h.in
  10. +2 −1  include/ulib/net/server/server.h
  11. +0 −2  include/ulib/notifier.h
  12. +59 −78 include/ulib/thread.h
  13. +0 −2  include/ulib/timer.h
  14. +12 −12 rpm.sh
  15. +12 −12 rpm.sh.in
  16. +5 −1 src/ulib/Makefile.am
  17. +121 −119 src/ulib/Makefile.in
  18. +4 −0 src/ulib/all_cpp.cpp
  19. +1 −3 src/ulib/net/ipaddress.cpp
  20. +1 −1  src/ulib/net/server/client_image.cpp
  21. +1 −1  src/ulib/net/server/plugin/mod_http.cpp
  22. +2 −0  src/ulib/net/server/server.cpp
  23. +1 −1  src/ulib/notifier.cpp
  24. +354 −94 src/ulib/thread.cpp
  25. +0 −6 src/ulib/timer.cpp
  26. +12 −12 src/ulib/utility/interrupt.cpp
  27. +1 −1  src/ulib/utility/services.cpp
  28. +0 −7 tests/examples/IR/WEB/form/it/result.doc
  29. +0 −2  tests/examples/IR/WEB/form/it/result.pag
  30. +0 −4 tests/examples/IR/WEB/form/it/result.top
  31. +0 −53 tests/examples/IR/WEB/form/it/seek.hlp
  32. +0 −74 tests/examples/IR/WEB/form/it/seek.tmpl
  33. +0 −7 tests/examples/IR/WEB/form/it/seek.top
  34. +0 −19 tests/examples/RA/RA/mail/card-generation.tmpl
  35. +0 −63 tests/examples/RA/RA/mail/mail-business.tmpl
  36. +0 −71 tests/examples/RA/RA/mail/mail-cpe.tmpl
  37. +0 −22 tests/examples/RA/RA/www/admin/cgi-bin/.admin
  38. +0 −172 tests/examples/RA/RA/www/admin/cgi-bin/.base
  39. +0 −9 tests/examples/RA/RA/www/admin/cgi-bin/.env
  40. +0 −17 tests/examples/RA/RA/www/admin/cgi-bin/card-generation.bash
  41. +0 −77 tests/examples/RA/RA/www/admin/form/en/card-generation.tmpl
  42. +0 −77 tests/examples/RA/RA/www/admin/form/it/card-generation.tmpl
  43. +0 −172 tests/examples/RA/RA/www/ra-station/cgi-bin/.base
  44. +0 −9 tests/examples/RA/RA/www/ra-station/cgi-bin/.env
  45. +0 −589 tests/examples/RA/RA/www/ra-station/cgi-bin/.registrazione
  46. +0 −60 tests/examples/RA/RA/www/ra-station/cgi-bin/registrazione-business.bash
  47. +0 −60 tests/examples/RA/RA/www/ra-station/cgi-bin/registrazione-residenziale-con-cpe.bash
  48. +0 −596 tests/examples/RA/RA/www/ra-station/css/style.css
  49. +0 −15 tests/examples/RA/RA/www/ra-station/form/en/contratto-bottoni.tmpl
  50. +0 −110 tests/examples/RA/RA/www/ra-station/form/en/contratto-informativa.html
  51. +0 −221 tests/examples/RA/RA/www/ra-station/form/en/contratto-privacy.html
  52. +0 −529 tests/examples/RA/RA/www/ra-station/form/en/contratto-registrazione-business.tmpl
  53. +0 −605 tests/examples/RA/RA/www/ra-station/form/en/contratto-registrazione-residenziale-con-cpe.tmpl
  54. +0 −52 tests/examples/RA/RA/www/ra-station/form/en/error.tmpl
  55. +0 −367 tests/examples/RA/RA/www/ra-station/form/en/registrazione-business.tmpl
  56. +0 −449 tests/examples/RA/RA/www/ra-station/form/en/registrazione-residenziale-con-cpe.tmpl
  57. +0 −7 tests/examples/RA/RA/www/ra-station/form/en/rid-bottoni.tmpl
  58. +0 −553 tests/examples/RA/RA/www/ra-station/form/en/rid.tmpl
  59. +0 −20 tests/examples/RA/RA/www/ra-station/form/en/stampa.js
  60. +0 −31 tests/examples/RA/RA/www/ra-station/form/en/view.tmpl
  61. +0 −15 tests/examples/RA/RA/www/ra-station/form/it/contratto-bottoni.tmpl
  62. +0 −110 tests/examples/RA/RA/www/ra-station/form/it/contratto-informativa.html
  63. +0 −221 tests/examples/RA/RA/www/ra-station/form/it/contratto-privacy.html
  64. +0 −529 tests/examples/RA/RA/www/ra-station/form/it/contratto-registrazione-business.tmpl
  65. +0 −605 tests/examples/RA/RA/www/ra-station/form/it/contratto-registrazione-residenziale-con-cpe.tmpl
  66. +0 −52 tests/examples/RA/RA/www/ra-station/form/it/error.tmpl
  67. +0 −365 tests/examples/RA/RA/www/ra-station/form/it/registrazione-business.tmpl
  68. +0 −447 tests/examples/RA/RA/www/ra-station/form/it/registrazione-residenziale-con-cpe.tmpl
  69. +0 −7 tests/examples/RA/RA/www/ra-station/form/it/rid-bottoni.tmpl
  70. +0 −553 tests/examples/RA/RA/www/ra-station/form/it/rid.tmpl
  71. +0 −20 tests/examples/RA/RA/www/ra-station/form/it/stampa.js
  72. +0 −32 tests/examples/RA/RA/www/ra-station/form/it/view.tmpl
  73. BIN  tests/examples/RA/RA/www/ra-station/images/dx-logo.png
  74. BIN  tests/examples/RA/RA/www/ra-station/images/sx-logo.jpg
  75. +0 −38 tests/examples/RA/RA/www/ra-station/index.html
  76. +0 −4 tests/examples/RA/RA/www/ra-station/js/livevalidation_standalone.js
  77. +0 −61 tests/examples/RA/userver/bin/RA
  78. +0 −61 tests/examples/RA/userver/bin/RA.5
  79. +0 −117 tests/examples/RA/userver/bin/RA.6
  80. +1 −1  tests/examples/TSA/CA/tsaserial
  81. +7 −2 tests/ulib/Makefile.am
  82. +66 −60 tests/ulib/Makefile.in
  83. BIN  tests/ulib/inp/test.db
  84. +12 −0 tests/ulib/ok/ldap.ok
  85. +49 −0 tests/ulib/ok/thread.ok
  86. +154 −45 tests/ulib/test_thread.cpp
  87. +1 −0  tests/ulib/thread.test
View
16 README.md
@@ -35,11 +35,11 @@ The current version offers the following features :
* Support for [JSONRequest](http://json.org/JSONRequest.html).
* Accept HTTP uploads up to 4 GB without increasing memory usage.
* Support for upload progress via USP (ULib Servlet Page).
+ * General [CGI](http://it.wikipedia.org/wiki/Common_Gateway_Interface) support (run any CGI script) with automatic output compression (using deflate method).
* CGI support for shell script processes (with automatic management of form and cookie).
- * General CGI support (run any CGI script) with automatic output compression (using deflate method).
* CGI support for the X-Sendfile feature and also supports X-Accel-Redirect headers transparently.
* Support for minify HTML CGI output with wrapping [google page speed SDK](http://code.google.com/speed/page-speed/download.html#pagespeed-sdk).
- * Web Socket support (experimental).
+ * [Web Socket](http://dev.w3.org/html5/websockets) support (experimental).
* Support for Windows (without preforking).
* Requests cut in phases for modular architecture (apache-like).
* Configuration file with dedicated section.
@@ -49,13 +49,13 @@ The current version offers the following features :
* mod_http : core features, static file handler and dynamic page (ULib Servlet Page).
* mod_ssi : [Server Side Includes]( http://en.wikipedia.org/wiki/Server_Side_Include) support with enhanced #set, direct include and #exec usp (ULib Servlet Page).
* mod_nocat : [captive portal](http://nocat.net/) implementation.
- * mod_tsa : server side Time Stamp support.
- * mod_soap : generic SOAP server services support.
- * mod_fcgi : third-party applications support thru FastCGI interface.
- * mod_scgi : module that implements the client side of the SCGI protocol (experimental).
- * mod_shib : web single sign-on support (experimental).
+ * mod_tsa : server side [Time Stamp](http://www.opentsa.org) support.
+ * mod_soap : generic [SOAP](http://java.sun.com/developer/technicalArticles/xml/webservices) server services support.
+ * mod_fcgi : third-party applications support thru [FastCGI](http://www.fastcgi.com/drupal) interface.
+ * mod_scgi : module that implements the client side of the [SCGI](http://www.mems-exchange.org/software/scgi) protocol (experimental).
+ * mod_shib : [web single sign-on support](http://shibboleth.internet2.edu) (experimental).
* mod_proxy : proxy support (experimental).
- * mod_geoip : geolocation support (experimental).
+ * mod_geoip : [geolocation support](http://www.maxmind.com/geoip/api/c.shtml) (experimental).
* mod_stream : simple streaming support (experimental).
* mod_socket : web sockets application framework (experimental).
View
53 ULib.m4
@@ -8,30 +8,26 @@ dnl This macro tries to find the ULib library and header files.
dnl
dnl We define the following configure script flags:
dnl
-dnl --with-ULib: Give prefix for both library and headers, and try
-dnl to guess subdirectory names for each.
-dnl --with-ULib-lib: Similar to --with-ULib, but for library only.
-dnl --with-ULib-include: Similar to --with-ULib, but for headers only.
+dnl --with-ulib: Give prefix for both library and headers, and try to guess subdirectory names for each.
+dnl
+dnl --with-ulib-lib: Similar to --with-ulib, but for library only.
+dnl --with-ulib-include: Similar to --with-ulib, but for headers only.
-AC_DEFUN([AC_ULIB],
-[
-AC_CACHE_CHECK([for ULib library stuff], ac_cv_ULib,
-[
- #
- # Set up configure script macros
- #
- AC_ARG_WITH(ULib,
- [ --with-ULib=<path> path containing ULib header and library subdirs],
- [ULIB_lib_check="$with_ULib/lib $with_ULib/lib/ULib"
- ULIB_inc_check="$with_ULib/include $with_ULib/include/ULib"],
- [ULIB_lib_check="/usr/local/ULib/lib /usr/local/lib/ULib /opt/ULib/lib /usr/lib/ULib /usr/local/lib /usr/lib"
- ULIB_inc_check="/usr/local/ULib/include /usr/local/include/ULib /opt/ULib/include /usr/local/include/ULib /usr/local/include /usr/include/ULib /usr/include"])
- AC_ARG_WITH(ULib-lib,
- [ --with-ULib-lib=<path> directory path of ULib library],
- [ULIB_lib_check="$with_ULib_lib $with_ULib_lib/lib $with_ULib_lib/lib/ULib"])
- AC_ARG_WITH(ULib-include,
- [ --with-ULib-include=<path> directory path of ULib headers],
- [ULIB_inc_check="$with_ULib_include $with_ULib_include/include $with_ULib_include/include/ULib"])
+AC_DEFUN([AC_ULIB],[
+AC_CACHE_CHECK([for ULib library stuff], ac_cv_ulib,
+[ # Set up configure script macros
+ AC_ARG_WITH(ulib,
+ [ --with-ulib=<path> path containing ULib header and library subdirs],
+ [ULIB_lib_check="$with_ulib/lib $with_ulib/lib/ulib"
+ ULIB_inc_check="$with_ulib/include $with_ulib/include/ulib"],
+ [ULIB_lib_check="/usr/local/ulib/lib /usr/local/lib/ulib /opt/ulib/lib /usr/lib/ulib /usr/local/lib /usr/lib"
+ ULIB_inc_check="/usr/local/ulib/include /usr/local/include/ulib /opt/ulib/include /usr/local/include/ulib /usr/local/include /usr/include/ulib /usr/include"])
+ AC_ARG_WITH(ulib-lib,
+ [ --with-ulib-lib=<path> directory path of ULib library],
+ [ULIB_lib_check="$with_ulib_lib $with_ulib_lib/lib $with_ulib_lib/lib/ulib"])
+ AC_ARG_WITH(ulib-include,
+ [ --with-ulib-include=<path> directory path of ULib headers],
+ [ULIB_inc_check="$with_ulib_include $with_ulib_include/include $with_ulib_include/include/ulib"])
#
# Look for ULib library
@@ -55,7 +51,7 @@ AC_CACHE_CHECK([for ULib library stuff], ac_cv_ULib,
case "$ULIB_libdir" in
/* ) ;;
- * ) AC_MSG_ERROR([The ULib library directory ($ULIB_libdir) must be an absolute path.]) ;;
+ * ) AC_MSG_ERROR([The ULib library directory ($ULIB_libdir) must be an absolute path.]) ;;
esac
AC_MSG_RESULT([lib in $ULIB_libdir])
@@ -65,7 +61,6 @@ AC_CACHE_CHECK([for ULib library stuff], ac_cv_ULib,
*) LDFLAGS="$LDFLAGS -L${ULIB_libdir}" ;;
esac
-
#
# Look for ULib headers
#
@@ -87,7 +82,7 @@ AC_CACHE_CHECK([for ULib library stuff], ac_cv_ULib,
case "$ULIB_incdir" in
/* ) ;;
- * ) AC_MSG_ERROR([The ULib header directory ($ULIB_incdir) must be an absolute path.]) ;;
+ * ) AC_MSG_ERROR([The ULib header directory ($ULIB_incdir) must be an absolute path.]) ;;
esac
AC_MSG_RESULT([$ULIB_incdir])
@@ -98,7 +93,9 @@ AC_CACHE_CHECK([for ULib library stuff], ac_cv_ULib,
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <all.h>],
[UString s; s.c_str();])],
- ac_cv_ULib=yes,
+ ac_cv_ulib=yes,
AC_MSG_ERROR(no))
-])]) dnl End ULIB
+])
+])
+dnl End ULIB
View
23 ULib.spec.in
@@ -1,4 +1,4 @@
-Name: ULib
+Name: ulib
Summary: ULib C++ library - A package for creating small and fast C++ programs
Version: @VERSION@
Release: 1
@@ -9,7 +9,7 @@ URL: http://www.unirel.com
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: ULib
-Packager: Stefano Casazza <stefano.casazza@unirel.com>
+Packager: Stefano Casazza <stefano.casazza@gmail.com>
@RPM_REQUIRE@
@@ -36,8 +36,9 @@ make LDFLAGS="-s"
%install
rm -rf %{buildroot}
%makeinstall
-mkdir -p %{buildroot}/usr/libexec/ulib
+mkdir -p %{_sysconfdir}/ulib
mkdir -p %{buildroot}/usr/share/aclocal
+mkdir -p %{buildroot}/usr/libexec/ulib/usp
%clean
rm -rf %{buildroot}
@@ -45,15 +46,22 @@ rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%doc AUTHORS COPYING NEWS README TODO ChangeLog
+%{_bindir}/uclient
+%{_bindir}/userver_*
%{_libdir}/*.so.*
-%{_libexecdir}/ulib/mod_*.so
-%dir %{_libexecdir}/ulib
+%{_sysconfdir}/*.cfg*
+%{_libexecdir}/ulib/mod_*.*
+%{_libexecdir}/ulib/usp/*.*
+%dir %{_libexecdir}/ulib/usp
%files devel
%defattr(-,root,root,-)
+%{_bindir}/uclient
+%{_bindir}/userver_*
%{_libdir}/*.a
%{_libdir}/*.so
%{_libdir}/*.la
+%{_sysconfdir}/*.cfg*
%dir %{_includedir}/ulib
%{_includedir}/ulib/*.h
%{_includedir}/ulib/README
@@ -69,7 +77,10 @@ rm -rf %{buildroot}
%{_libexecdir}/ulib/mod_*.a
%{_libexecdir}/ulib/mod_*.so
%{_libexecdir}/ulib/mod_*.la
-%dir %{_libexecdir}/ulib
+%{_libexecdir}/ulib/usp/*.a
+%{_libexecdir}/ulib/usp/*.so
+%{_libexecdir}/ulib/usp/*.la
+%dir %{_libexecdir}/ulib/usp
%post -p /sbin/ldconfig
View
53 configure
@@ -705,6 +705,8 @@ THREAD_FLAGS
thrprefix
SEMAPHORE_FALSE
SEMAPHORE_TRUE
+PTHREAD_FALSE
+PTHREAD_TRUE
PLUGIN_FALSE
PLUGIN_TRUE
PAGE_SPEED_FALSE
@@ -22537,6 +22539,14 @@ fi
fi
if true; then
+ PTHREAD_TRUE=
+ PTHREAD_FALSE='#'
+else
+ PTHREAD_TRUE='#'
+ PTHREAD_FALSE=
+fi
+
+ if true; then
SEMAPHORE_TRUE=
SEMAPHORE_FALSE='#'
else
@@ -24677,6 +24687,14 @@ $as_echo "#define COMMON_AIX_FIXES 1" >>confdefs.h
if true; then
+ PTHREAD_TRUE=
+ PTHREAD_FALSE='#'
+else
+ PTHREAD_TRUE='#'
+ PTHREAD_FALSE=
+fi
+
+ if true; then
SEMAPHORE_TRUE=
SEMAPHORE_FALSE='#'
else
@@ -24686,6 +24704,14 @@ fi
LIBS_SAVE="${LIBS_SAVE} -l$ost_cv_thread_library";
else
+ if false; then
+ PTHREAD_TRUE=
+ PTHREAD_FALSE='#'
+else
+ PTHREAD_TRUE='#'
+ PTHREAD_FALSE=
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sem_init in -lrt" >&5
$as_echo_n "checking for sem_init in -lrt... " >&6; }
if ${ac_cv_lib_rt_sem_init+:} false; then :
@@ -27381,17 +27407,23 @@ _ACEOF
if test "$prefix" = "NONE"; then
prefix="/usr/local"
- pkglibexecdir="/usr/local/libexec/ulib"
-else
- pkglibexecdir="$prefix/libexec/ulib"
fi
-# pkugin dir
+sysconfdir="$prefix/etc/ulib"
+pkglibexecdir="$prefix/libexec/ulib"
+
+# plugin dir
cat >>confdefs.h <<_ACEOF
#define U_LIBEXECDIR "${pkglibexecdir}"
_ACEOF
+# config dir
+
+cat >>confdefs.h <<_ACEOF
+#define U_SYSCONFDIR "${sysconfdir}"
+_ACEOF
+
echo \
"------------------------------------------------------------------------
@@ -27401,6 +27433,7 @@ configure: Configured to build src/ulib/libulib:
Host setup: ${host}
Install prefix: ${prefix}
Install plugin: ${pkglibexecdir}
+ Configuration data: ${sysconfdir}
Operating System: $os_version
C++ Compiler: ${CXX} ( $gcc_version )
C Flags: ${CFLAGS}
@@ -27826,14 +27859,26 @@ if test -z "${PLUGIN_TRUE}" && test -z "${PLUGIN_FALSE}"; then
as_fn_error $? "conditional \"PLUGIN\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${PTHREAD_TRUE}" && test -z "${PTHREAD_FALSE}"; then
+ as_fn_error $? "conditional \"PTHREAD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${SEMAPHORE_TRUE}" && test -z "${SEMAPHORE_FALSE}"; then
as_fn_error $? "conditional \"SEMAPHORE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${PTHREAD_TRUE}" && test -z "${PTHREAD_FALSE}"; then
+ as_fn_error $? "conditional \"PTHREAD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${SEMAPHORE_TRUE}" && test -z "${SEMAPHORE_FALSE}"; then
as_fn_error $? "conditional \"SEMAPHORE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
+if test -z "${PTHREAD_TRUE}" && test -z "${PTHREAD_FALSE}"; then
+ as_fn_error $? "conditional \"PTHREAD\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
if test -z "${SEMAPHORE_TRUE}" && test -z "${SEMAPHORE_FALSE}"; then
as_fn_error $? "conditional \"SEMAPHORE\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
View
14 configure.in
@@ -531,15 +531,18 @@ case "$target_os" in
else
AM_CONDITIONAL(PLUGIN, false)
fi
+ AM_CONDITIONAL(PTHREAD, true)
AM_CONDITIONAL(SEMAPHORE, true)
;;
*)
AC_CHECK_LIB(pthread,sem_init)
if test "$ac_cv_lib_pthread_sem_init" = "yes"; then
OST_LIB_PTHREAD
+ AM_CONDITIONAL(PTHREAD, true)
AM_CONDITIONAL(SEMAPHORE, true)
LIBS_SAVE="${LIBS_SAVE} -l$ost_cv_thread_library";
else
+ AM_CONDITIONAL(PTHREAD, false)
AC_CHECK_LIB(rt,sem_init)
if test "$ac_cv_lib_rt_sem_init" = "yes"; then
LIBS_SAVE="${LIBS_SAVE} -lrt";
@@ -1032,13 +1035,15 @@ AC_COMPILATION_ENVIRONMENT
if test "$prefix" = "NONE"; then
prefix="/usr/local"
- pkglibexecdir="/usr/local/libexec/ulib"
-else
- pkglibexecdir="$prefix/libexec/ulib"
fi
-# pkugin dir
+sysconfdir="$prefix/etc/ulib"
+pkglibexecdir="$prefix/libexec/ulib"
+
+# plugin dir
AC_DEFINE_UNQUOTED(U_LIBEXECDIR, "${pkglibexecdir}", [install directory for plugins])
+# config dir
+AC_DEFINE_UNQUOTED(U_SYSCONFDIR, "${sysconfdir}", [install directory for configuration data])
echo \
"------------------------------------------------------------------------
@@ -1048,6 +1053,7 @@ configure: Configured to build src/ulib/libulib:
Host setup: ${host}
Install prefix: ${prefix}
Install plugin: ${pkglibexecdir}
+ Configuration data: ${sysconfdir}
Operating System: $os_version
C++ Compiler: ${CXX} ( $gcc_version )
C Flags: ${CFLAGS}
View
2  examples/uclient/uclient.cpp
@@ -54,7 +54,7 @@ class Application : public UApplication {
// manage file configuration
- if (cfg_str.empty()) cfg_str = U_STRING_FROM_CONSTANT("/etc/uclient.cfg");
+ if (cfg_str.empty()) cfg_str = U_STRING_FROM_CONSTANT(U_SYSCONFDIR "/uclient.cfg");
// ----------------------------------------------------------------------------------------------------------------------------------
// uclient - configuration parameters
View
16 examples/userver/userver.cfg.default
@@ -62,7 +62,7 @@ userver {
# IP_ADDRESS 10.30.1.131
# ALLOWED_IP 127.0.0.1,10.30.0.0/16
- LISTEN_BACKLOG 512
+# LISTEN_BACKLOG 512
USE_TCP_OPTIMIZATION yes
PID_FILE /var/run/userver.pid
@@ -146,8 +146,8 @@ mod_http {
# ^/(.*?)(\?|$)(.*) /sapphire/main.php?url=$1&$3
# ]
-# ENABLE_INOTIFY yes
-# CACHE_FILE_MASK *.css|*.js|*.gif|*.png|*.jpg|*.*html
+# ENABLE_INOTIFY yes
+ CACHE_FILE_MASK *.css|*.js|*.gif|*.png|*.jpg|*.*html
# VIRTUAL_HOST yes
# DIGEST_AUTHENTICATION yes
@@ -237,7 +237,7 @@ mod_http {
#
# mod_scgi {
#
-# SCGI_URI_MASK *.php
+# SCGI_URI_MASK *.py
#
# SOCKET_NAME tmp/scgi.socket
#
@@ -300,7 +300,7 @@ mod_http {
# mod_stream {
-# ENVIRONMENT "\"UTRACE=0 5M 0\""
+# ENVIRONMENT "'UTRACE=0 5M 0'"
# COMMAND my_stream.sh
# URI_PATH /my/stream
@@ -320,7 +320,7 @@ mod_http {
#
# mod_socket {
#
-# ENVIRONMENT "\"UTRACE=0 5M 0\""
+# ENVIRONMENT "'UTRACE=0 5M 0'"
# COMMAND my_websocket.sh
#
# USE_SIZE_PREAMBLE yes
@@ -441,8 +441,8 @@ mod_http {
# ENVIRONMENT environment for command to execute
# RESPONSE_TYPE output type of the command (yes = response for client, no = request to server)
# FOLLOW_REDIRECTS if yes manage to automatically follow redirects from server
-# USER if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: user
-# PASSWORD if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: password
+# USER if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: user
+# PASSWORD if manage to follow redirects, in response to a HTTP_UNAUTHORISED response from the HTTP server: password
# ---------------------------------------------------------------------------------------------------------------------------------
# mod_proxy {
View
11 examples/userver/userver.cpp
@@ -21,7 +21,7 @@
# define U_NO_SSL
# endif
#else
-# error "you must define the socket type... (U_SSL_SOCKET | U_TCP_SOCKET | U_UNIX_SOCKET)"
+# error "you must define the socket type (U_SSL_SOCKET | U_TCP_SOCKET | U_UNIX_SOCKET)"
#endif
#include <ulib/net/server/server.h>
@@ -32,7 +32,7 @@
#define ARGS ""
#define U_OPTIONS \
-"purpose 'application server by ULib...'\n" \
+"purpose 'application server by ULib' \n" \
"option c config 1 'path of configuration file' ''\n"
#include <ulib/application.h>
@@ -63,17 +63,19 @@ class Application : public UApplication {
// manage file configuration
- if (cfg_str.empty()) cfg_str = U_STRING_FROM_CONSTANT("/etc/userver.cfg");
+ if (cfg_str.empty()) cfg_str = U_STRING_FROM_CONSTANT(U_SYSCONFDIR "/userver.cfg");
// ---------------------------------------------------------------------------------------------------------------------------------------
// userver - configuration parameters
// ---------------------------------------------------------------------------------------------------------------------------------------
// USE_IPV6 flag to indicate use of ipv6
+ // SERVER host name or ip address for the listening socket
// PORT port number for the listening socket
// SOCKET_NAME file name for the listening socket
// IP_ADDRESS public ip address of host for the interface connected to the Internet (autodetected if not specified)
// ALLOWED_IP list of comma separated client address for IP-based access control (IPADDR[/MASK])
//
+ // LISTEN_BACKLOG max number of ready to be delivered connections to accept()
// USE_TCP_OPTIMIZATION flag indicating the use of TCP/IP options to optimize data transmission (TCP_CORK, TCP_DEFER_ACCEPT, TCP_QUICKACK)
// PID_FILE write pid on file indicated
@@ -92,8 +94,9 @@ class Application : public UApplication {
// CGI_TIMEOUT timeout for cgi execution
//
// MAX_KEEP_ALIVE Specifies the maximum number of requests that can be served through a Keep-Alive (Persistent) session.
- // (Value <= 1 will disable Keep-Alive)
+ // (Value <= 1 will disable Keep-Alive) (default 256)
//
+ // DH_FILE DH param
// CERT_FILE certificate of server
// KEY_FILE private key of server
// PASSWORD password for private key of server
View
3  include/ulib/internal/config.h.in
@@ -885,6 +885,9 @@ typedef unsigned long long uint64;
/* STATIC_HANDLER_TSA */
#undef U_STATIC_HANDLER_TSA
+/* install directory for configuration data */
+#undef U_SYSCONFDIR
+
/* Define if we have zlib with this function */
#undef U_ZLIB_DEFLATE_WORKSPACESIZE
View
3  include/ulib/net/server/server.h
@@ -266,7 +266,8 @@ class U_EXPORT UServer_Base : public UEventFd {
U_INTERNAL_DUMP("preforked_num_kids = %d", preforked_num_kids)
- bool result = (preforked_num_kids == 1);
+ bool result = (preforked_num_kids == 1 ||
+ preforked_num_kids == -1);
U_RETURN(result);
}
View
2  include/ulib/notifier.h
@@ -82,8 +82,6 @@ class U_EXPORT UNotifier {
for (UNotifier* item = first; item; item = item->next)
{
- PREFETCH_ATTRIBUTE(item->next, 0)
-
if (item->handler_event_fd == handler_event) U_RETURN(true);
}
View
137 include/ulib/thread.h
@@ -34,16 +34,15 @@ class U_EXPORT UThread {
cancelDisabled /* ignore cancellation */
};
- enum Suspend {
- suspendEnable, /* suspend enabled */
- suspendDisable /* suspend disabled, Suspend do nothing */
- };
-
// COSTRUTTORI
- UThread();
+ UThread(bool __suspendEnable = false);
virtual ~UThread();
+ // SERVICES
+
+ static void sleep(time_t timeoutMS);
+
/**
* All threads execute by deriving the run method of UThread.
* This method is called after initial to begin normal operation
@@ -51,31 +50,7 @@ class U_EXPORT UThread {
* also terminate.
*/
- virtual void run() = 0;
-
- /**
- * The initial method is called by a newly created thread when it
- * starts execution. This method is ran with deferred cancellation
- * disabled by default. The Initial method is given a separate
- * handler so that it can create temporary objects on it's own
- * stack frame, rather than having objects created on run() that
- * are only needed by startup and yet continue to consume stack space.
- */
-
- virtual void initial() {}
-
- /**
- * A thread that is self terminating, either by invoking exit() or
- * leaving it's run(), will have this method called. It can be used
- * to self delete the current object assuming the object was created
- * with new on the heap rather than stack local, hence one may often
- * see final defined as "delete this" in a derived thread class. A
- * final method, while running, cannot be terminated or cancelled by
- * another thread. Final is called for all cancellation type (even
- * immediate).
- */
-
- virtual void final() {}
+ virtual void run() {}
/**
* When a new thread is created, it does not begin immediate
@@ -85,56 +60,33 @@ class U_EXPORT UThread {
* combinations. It can be started directly after the constructor
* completes by calling the start() method.
*
- * @return error code if execution fails.
+ * @return false if execution fails.
*/
- int start();
+ bool start();
+ void stop();
/**
- * Yields the current thread's CPU time slice to allow another thread to
- * begin immediate execution.
- */
-
- void yield();
-
- // SERVICES
-
- void sleep(time_t timeout);
-
- void setCancel(int mode);
-
- /**
- * Used to retrieve the cancellation mode in effect for the
- * selected thread.
- *
- * @return cancellation mode constant.
- */
-
- int getCancel() { return _cancel; }
-
- /**
- * This is used to help build wrapper functions in libraries
- * around system calls that should behave as cancellation
- * points but don't.
+ * Start a new thread as "detached". This is an alternative
+ * start() method that resolves some issues with later glibc
+ * implimentations which incorrectly impliment self-detach.
*
- * @return saved cancel type.
+ * @return false if execution fails.
*/
- int enterCancel();
+ bool detach();
/**
- * This is used to restore a cancel block.
- *
- * @param cancel type that was saved.
+ * Yields the current thread's CPU time slice to allow another thread to
+ * begin immediate execution.
*/
- void exitCancel(int cancel);
+ void yield();
/**
* Suspends execution of the selected thread. Pthreads do not
* normally support suspendable threads, so the behavior is
- * simulated with signals. On systems such as Linux that
- * define threads as processes, SIGSTOP and SIGCONT may be used.
+ * simulated with signals.
*/
void suspend();
@@ -153,34 +105,63 @@ class U_EXPORT UThread {
bool isDetached() const;
+ /**
+ * Each time a thread receives a signal, it stores the
+ * signal number locally.
+ */
+
+ void signal(int signo);
+
+ // Cancellation
+
+ void setCancel(int mode);
+
/**
- * Sets the thread's ability to be suspended from execution. The
- * thread may either have suspend enabled (suspendEnable) or
- * disabled (suspendDisable).
+ * This is used to help build wrapper functions in libraries
+ * around system calls that should behave as cancellation
+ * points but don't.
*
- * @param mode for suspend.
+ * @return saved cancel type.
*/
- void setSuspend(Suspend mode);
+ int enterCancel();
+
+ /**
+ * This is used to restore a cancel block.
+ *
+ * @param cancel type that was saved.
+ */
+
+ void exitCancel(int cancel);
#ifdef DEBUG
const char* dump(bool reset) const;
#endif
protected:
- int _cancel;
- pthread_t _tid;
- pthread_attr_t _attr;
- volatile bool _suspendEnable:1;
+ UThread* next;
+
+ static UThread* first;
+ static pthread_cond_t cond;
+ static pthread_mutex_t lock;
void close(); // close current thread, free all
+ void sigInstall(int signo);
+
+ static void sigHandler(int signo);
+ static void execHandler(UThread* th);
+ static void threadCleanup(UThread* th);
- static void execHandler(UThread* th) __noreturn;
- static void threadCleanup(UThread* th) { th->close(); }
+ // A special global function, getThread(), is provided to identify the thread object that represents the current
+ // execution context you are running under. This is sometimes needed to deliver signals to the correct thread.
- static sigset_t* blockedSignals(sigset_t* sig);
+ static UThread* getThread();
private:
+ // private data
+ class UThreadImpl* priv;
+ friend class UThreadImpl;
+
UThread(const UThread&) {}
UThread& operator=(const UThread&) { return *this; }
};
View
2  include/ulib/timer.h
@@ -75,8 +75,6 @@ class U_EXPORT UTimer {
for (UTimer* item = first; item; item = item->next)
{
- PREFETCH_ATTRIBUTE(item->next, 0)
-
if (item->alarm == _alarm) U_RETURN(true);
}
View
24 rpm.sh
@@ -7,28 +7,28 @@ VERSION=1.1.0
run_build() {
- mv ULib-$VERSION $1-$VERSION
+ mv ulib-$VERSION $1-$VERSION
tar czf $PACKAGE/SOURCES/$1-$VERSION.tar.gz $1-$VERSION
cp $1-$VERSION/examples/$2/$3.spec $PACKAGE/SPECS/
rpmbuild -ba --clean --rmsource $1-$VERSION/examples/$2/$3.spec >>rpm.log 2>&1
- mv $1-$VERSION ULib-$VERSION
+ mv $1-$VERSION ulib-$VERSION
}
-ULIB_TO_REMOVE=`ls -d ULib-*`
+ULIB_TO_REMOVE=`ls -d ulib-*`
if [ -n "$ULIB_TO_REMOVE" ]; then
for i in "$ULIB_TO_REMOVE"; do
- if [ "$i" != "ULib-$VERSION.tar.gz" ]; then
+ if [ "$i" != "ulib-$VERSION.tar.gz" ]; then
rm -rf $i
fi
done
fi
-tar xzf ULib-$VERSION.tar.gz
-cd ULib-$VERSION
+tar xzf ulib-$VERSION.tar.gz
+cd ulib-$VERSION
#------------------------------------
# SUSE
@@ -39,15 +39,15 @@ cd ULib-$VERSION
./configure -C --enable-static --enable-shared
cd ..
-tar czf ULib-$VERSION.tar.gz ULib-$VERSION
+tar czf ulib-$VERSION.tar.gz ulib-$VERSION
-cp ULib-$VERSION.tar.gz $PACKAGE/SOURCES/
+cp ulib-$VERSION.tar.gz $PACKAGE/SOURCES/
-cp ULib-$VERSION/ULib.spec $PACKAGE/SPECS/
-cp ULib-$VERSION/examples/*/*.start $PACKAGE/SOURCES/
-
-rpmbuild -ba --clean --rmsource ULib-$VERSION/ULib.spec >rpm.log 2>&1
+cp ulib-$VERSION/ULib.spec $PACKAGE/SPECS/
+cp ulib-$VERSION/examples/*/*.start $PACKAGE/SOURCES/
+rpmbuild -ba --clean --rmsource ulib-$VERSION/ULib.spec >rpm.log 2>&1
+exit 0
run_build lcsp lcsp lcsp
run_build lcsp_rpc lcsp lcsp_rpc
run_build cspserver userver cspserver
View
24 rpm.sh.in
@@ -7,28 +7,28 @@ VERSION=@VERSION@
run_build() {
- mv ULib-$VERSION $1-$VERSION
+ mv ulib-$VERSION $1-$VERSION
tar czf $PACKAGE/SOURCES/$1-$VERSION.tar.gz $1-$VERSION
cp $1-$VERSION/examples/$2/$3.spec $PACKAGE/SPECS/
rpmbuild -ba --clean --rmsource $1-$VERSION/examples/$2/$3.spec >>rpm.log 2>&1
- mv $1-$VERSION ULib-$VERSION
+ mv $1-$VERSION ulib-$VERSION
}
-ULIB_TO_REMOVE=`ls -d ULib-*`
+ULIB_TO_REMOVE=`ls -d ulib-*`
if [ -n "$ULIB_TO_REMOVE" ]; then
for i in "$ULIB_TO_REMOVE"; do
- if [ "$i" != "ULib-$VERSION.tar.gz" ]; then
+ if [ "$i" != "ulib-$VERSION.tar.gz" ]; then
rm -rf $i
fi
done
fi
-tar xzf ULib-$VERSION.tar.gz
-cd ULib-$VERSION
+tar xzf ulib-$VERSION.tar.gz
+cd ulib-$VERSION
#------------------------------------
# SUSE
@@ -39,15 +39,15 @@ cd ULib-$VERSION
./configure -C --enable-static --enable-shared
cd ..
-tar czf ULib-$VERSION.tar.gz ULib-$VERSION
+tar czf ulib-$VERSION.tar.gz ulib-$VERSION
-cp ULib-$VERSION.tar.gz $PACKAGE/SOURCES/
+cp ulib-$VERSION.tar.gz $PACKAGE/SOURCES/
-cp ULib-$VERSION/ULib.spec $PACKAGE/SPECS/
-cp ULib-$VERSION/examples/*/*.start $PACKAGE/SOURCES/
-
-rpmbuild -ba --clean --rmsource ULib-$VERSION/ULib.spec >rpm.log 2>&1
+cp ulib-$VERSION/ULib.spec $PACKAGE/SPECS/
+cp ulib-$VERSION/examples/*/*.start $PACKAGE/SOURCES/
+rpmbuild -ba --clean --rmsource ulib-$VERSION/ULib.spec >rpm.log 2>&1
+exit 0
run_build lcsp lcsp lcsp
run_build lcsp_rpc lcsp lcsp_rpc
run_build cspserver userver cspserver
View
6 src/ulib/Makefile.am
@@ -37,7 +37,11 @@ SRC_CPP = internal/common.cpp internal/objectIO.cpp \
json/value.cpp \
query/query_parser.cpp event/event_time.cpp \
timeval.cpp timer.cpp notifier.cpp string.cpp file.cpp process.cpp file_config.cpp log.cpp \
- options.cpp application.cpp cache.cpp date.cpp url.cpp tokenizer.cpp command.cpp thread.cpp
+ options.cpp application.cpp cache.cpp date.cpp url.cpp tokenizer.cpp command.cpp
+
+if PTHREAD
+SRC_CPP += thread.cpp
+endif
if DEBUG
SRC_C += base/base_trace.c
View
240 src/ulib/Makefile.in
@@ -36,69 +36,70 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
-@DEBUG_TRUE@am__append_1 = base/base_trace.c
-@DEBUG_TRUE@am__append_2 = debug/trace.cpp debug/debug_common.cpp debug/error.cpp debug/error_memory.cpp \
+@PTHREAD_TRUE@am__append_1 = thread.cpp
+@DEBUG_TRUE@am__append_2 = base/base_trace.c
+@DEBUG_TRUE@am__append_3 = debug/trace.cpp debug/debug_common.cpp debug/error.cpp debug/error_memory.cpp \
@DEBUG_TRUE@ debug/error_simulation.cpp debug/objectDB.cpp
-@GETOPT_LONG_FALSE@am__append_3 = replace/getopt_long.c
-@MREMAP_FALSE@am__append_4 = replace/mremap.c
-@NANOSLEEP_FALSE@am__append_5 = replace/nanosleep.c
-@SENDFILE_FALSE@am__append_6 = replace/sendfile.c
-@STRNDUP_FALSE@am__append_7 = replace/strndup.c
-@SEMAPHORE_FALSE@am__append_8 = replace/sem.c
-@STRPTIME_FALSE@am__append_9 = replace/strptime.c
-@MKDTEMP_FALSE@am__append_10 = replace/mkdtemp.c
-@MEMRCHR_FALSE@am__append_11 = replace/memrchr.c
-@GMTIME_R_FALSE@am__append_12 = replace/gmtime.c
-@TIMEGM_FALSE@am__append_13 = replace/timegm.c
-@FNMATCH_FALSE@am__append_14 = replace/fnmatch.c
-@FALLOCATE_FALSE@am__append_15 = replace/fallocate.c
-@FALLOCATE64_FALSE@am__append_16 = replace/fallocate64.c
-@PREAD_FALSE@am__append_17 = replace/pread.c
-@ASSERT_FALSE@am__append_18 = replace/assert.c
-@MEMORY_POOL_TRUE@am__append_19 = internal/memory_pool.cpp
-@ZIP_TRUE@am__append_20 = base/zip/inflate.c base/zip/dostime.c base/zip/pushback.c base/zip/ziptool.c
-@ZIP_TRUE@am__append_21 = zip/zip.cpp
-@LIBZ_TRUE@am__append_22 = base/coder/cgzio.c
-@USE_PARSER_TRUE@am__append_23 = flex/flexer.cpp flex/bison.cpp
-@PCRE_TRUE@am__append_24 = pcre/pcre.cpp
-@SSL_TRUE@am__append_25 = base/ssl/des3.c base/ssl/dgst.c
-@SSL_TRUE@am__append_26 = ssl/certificate.cpp ssl/pkcs7.cpp ssl/crl.cpp ssl/pkcs10.cpp \
+@GETOPT_LONG_FALSE@am__append_4 = replace/getopt_long.c
+@MREMAP_FALSE@am__append_5 = replace/mremap.c
+@NANOSLEEP_FALSE@am__append_6 = replace/nanosleep.c
+@SENDFILE_FALSE@am__append_7 = replace/sendfile.c
+@STRNDUP_FALSE@am__append_8 = replace/strndup.c
+@SEMAPHORE_FALSE@am__append_9 = replace/sem.c
+@STRPTIME_FALSE@am__append_10 = replace/strptime.c
+@MKDTEMP_FALSE@am__append_11 = replace/mkdtemp.c
+@MEMRCHR_FALSE@am__append_12 = replace/memrchr.c
+@GMTIME_R_FALSE@am__append_13 = replace/gmtime.c
+@TIMEGM_FALSE@am__append_14 = replace/timegm.c
+@FNMATCH_FALSE@am__append_15 = replace/fnmatch.c
+@FALLOCATE_FALSE@am__append_16 = replace/fallocate.c
+@FALLOCATE64_FALSE@am__append_17 = replace/fallocate64.c
+@PREAD_FALSE@am__append_18 = replace/pread.c
+@ASSERT_FALSE@am__append_19 = replace/assert.c
+@MEMORY_POOL_TRUE@am__append_20 = internal/memory_pool.cpp
+@ZIP_TRUE@am__append_21 = base/zip/inflate.c base/zip/dostime.c base/zip/pushback.c base/zip/ziptool.c
+@ZIP_TRUE@am__append_22 = zip/zip.cpp
+@LIBZ_TRUE@am__append_23 = base/coder/cgzio.c
+@USE_PARSER_TRUE@am__append_24 = flex/flexer.cpp flex/bison.cpp
+@PCRE_TRUE@am__append_25 = pcre/pcre.cpp
+@SSL_TRUE@am__append_26 = base/ssl/des3.c base/ssl/dgst.c
+@SSL_TRUE@am__append_27 = ssl/certificate.cpp ssl/pkcs7.cpp ssl/crl.cpp ssl/pkcs10.cpp \
@SSL_TRUE@ ssl/mime/mime_pkcs7.cpp ssl/net/sslsocket.cpp
-@SSL_TRUE@@SSL_TS_TRUE@am__append_27 = ssl/timestamp.cpp
-@SSH_TRUE@am__append_28 = ssh/net/sshsocket.cpp
-@LDAP_TRUE@am__append_29 = ldap/ldap.cpp
-@CURL_TRUE@am__append_30 = curl/curl.cpp
-@EXPAT_TRUE@am__append_31 = xml/expat/attribute.cpp xml/expat/element.cpp xml/expat/xml_parser.cpp \
+@SSL_TRUE@@SSL_TS_TRUE@am__append_28 = ssl/timestamp.cpp
+@SSH_TRUE@am__append_29 = ssh/net/sshsocket.cpp
+@LDAP_TRUE@am__append_30 = ldap/ldap.cpp
+@CURL_TRUE@am__append_31 = curl/curl.cpp
+@EXPAT_TRUE@am__append_32 = xml/expat/attribute.cpp xml/expat/element.cpp xml/expat/xml_parser.cpp \
@EXPAT_TRUE@ xml/soap/soap_fault.cpp xml/soap/soap_gen_method.cpp xml/soap/soap_parser.cpp xml/soap/soap_encoder.cpp
-@LIBXML2_TRUE@am__append_32 = xml/libxml2/node.cpp xml/libxml2/document.cpp xml/libxml2/schema.cpp
-@MAGIC_TRUE@am__append_33 = magic/magic.cpp
-@MYSQL_TRUE@am__append_34 = mysql/mysql.cpp
-@DBI_TRUE@am__append_35 = dbi/dbi.cpp
-@LIBEVENT_TRUE@am__append_36 = libevent/event.cpp
-@MINGW_TRUE@am__append_37 = base/win32/mingw32.c
-@MINGW_FALSE@am__append_38 = net/unixsocket.cpp
+@LIBXML2_TRUE@am__append_33 = xml/libxml2/node.cpp xml/libxml2/document.cpp xml/libxml2/schema.cpp
+@MAGIC_TRUE@am__append_34 = magic/magic.cpp
+@MYSQL_TRUE@am__append_35 = mysql/mysql.cpp
+@DBI_TRUE@am__append_36 = dbi/dbi.cpp
+@LIBEVENT_TRUE@am__append_37 = libevent/event.cpp
+@MINGW_TRUE@am__append_38 = base/win32/mingw32.c
+@MINGW_FALSE@am__append_39 = net/unixsocket.cpp
# Handler static plugin
-@STATIC_HANDLER_RPC_TRUE@am__append_39 = net/server/plugin/mod_rpc.cpp
-@MOD_SHIB_TRUE@@STATIC_HANDLER_SHIB_TRUE@am__append_40 = net/server/plugin/mod_shib/mod_shib.cpp net/server/plugin/mod_proxy_service.cpp
-@STATIC_HANDLER_STREAM_TRUE@am__append_41 = net/server/plugin/mod_stream.cpp
-@STATIC_HANDLER_NOCAT_TRUE@am__append_42 = net/server/plugin/mod_nocat.cpp
-@STATIC_HANDLER_SOCKET_TRUE@am__append_43 = net/server/plugin/mod_socket.cpp
-@STATIC_HANDLER_SCGI_TRUE@am__append_44 = net/server/plugin/mod_scgi.cpp
-@STATIC_HANDLER_FCGI_TRUE@am__append_45 = net/server/plugin/mod_fcgi.cpp
-@GEOIP_TRUE@@STATIC_HANDLER_GEOIP_TRUE@am__append_46 = net/server/plugin/mod_geoip/mod_geoip.cpp
-@PCRE_TRUE@@STATIC_HANDLER_PROXY_TRUE@am__append_47 = net/server/plugin/mod_proxy.cpp net/server/plugin/mod_proxy_service.cpp
-@EXPAT_TRUE@@STATIC_HANDLER_SOAP_TRUE@am__append_48 = net/server/plugin/mod_soap.cpp
-@STATIC_HANDLER_SSI_TRUE@am__append_49 = net/server/plugin/mod_ssi.cpp
-@STATIC_HANDLER_TSA_TRUE@am__append_50 = net/server/plugin/mod_tsa.cpp
-@STATIC_HANDLER_HTTP_TRUE@am__append_51 = net/server/plugin/mod_http.cpp
-@STATIC_HANDLER_ECHO_TRUE@am__append_52 = net/server/plugin/mod_echo.cpp
+@STATIC_HANDLER_RPC_TRUE@am__append_40 = net/server/plugin/mod_rpc.cpp
+@MOD_SHIB_TRUE@@STATIC_HANDLER_SHIB_TRUE@am__append_41 = net/server/plugin/mod_shib/mod_shib.cpp net/server/plugin/mod_proxy_service.cpp
+@STATIC_HANDLER_STREAM_TRUE@am__append_42 = net/server/plugin/mod_stream.cpp
+@STATIC_HANDLER_NOCAT_TRUE@am__append_43 = net/server/plugin/mod_nocat.cpp
+@STATIC_HANDLER_SOCKET_TRUE@am__append_44 = net/server/plugin/mod_socket.cpp
+@STATIC_HANDLER_SCGI_TRUE@am__append_45 = net/server/plugin/mod_scgi.cpp
+@STATIC_HANDLER_FCGI_TRUE@am__append_46 = net/server/plugin/mod_fcgi.cpp
+@GEOIP_TRUE@@STATIC_HANDLER_GEOIP_TRUE@am__append_47 = net/server/plugin/mod_geoip/mod_geoip.cpp
+@PCRE_TRUE@@STATIC_HANDLER_PROXY_TRUE@am__append_48 = net/server/plugin/mod_proxy.cpp net/server/plugin/mod_proxy_service.cpp
+@EXPAT_TRUE@@STATIC_HANDLER_SOAP_TRUE@am__append_49 = net/server/plugin/mod_soap.cpp
+@STATIC_HANDLER_SSI_TRUE@am__append_50 = net/server/plugin/mod_ssi.cpp
+@STATIC_HANDLER_TSA_TRUE@am__append_51 = net/server/plugin/mod_tsa.cpp
+@STATIC_HANDLER_HTTP_TRUE@am__append_52 = net/server/plugin/mod_http.cpp
+@STATIC_HANDLER_ECHO_TRUE@am__append_53 = net/server/plugin/mod_echo.cpp
# ---------- Win32 stuff ----------
-@MINGW_TRUE@am__append_53 = -export-symbols $(srcdir)/@ULIB@.def -no-undefined -Wl,ULib-win32-res.o
+@MINGW_TRUE@am__append_54 = -export-symbols $(srcdir)/@ULIB@.def -no-undefined -Wl,ULib-win32-res.o
subdir = src/ulib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/ULib.pc.in $(srcdir)/ULib.rc.in
@@ -245,44 +246,45 @@ am__objects_22 = base.lo base_error.lo hash.lo utility.lo minilzo.lo \
$(am__objects_13) $(am__objects_14) $(am__objects_15) \
$(am__objects_16) $(am__objects_17) $(am__objects_18) \
$(am__objects_19) $(am__objects_20) $(am__objects_21)
-@DEBUG_TRUE@am__objects_23 = trace.lo debug_common.lo error.lo \
+@PTHREAD_TRUE@am__objects_23 = thread.lo
+@DEBUG_TRUE@am__objects_24 = trace.lo debug_common.lo error.lo \
@DEBUG_TRUE@ error_memory.lo error_simulation.lo objectDB.lo
-@MEMORY_POOL_TRUE@am__objects_24 = memory_pool.lo
-@ZIP_TRUE@am__objects_25 = zip.lo
-@USE_PARSER_TRUE@am__objects_26 = flexer.lo bison.lo
-@PCRE_TRUE@am__objects_27 = pcre.lo
-@SSL_TRUE@am__objects_28 = certificate.lo pkcs7.lo crl.lo pkcs10.lo \
+@MEMORY_POOL_TRUE@am__objects_25 = memory_pool.lo
+@ZIP_TRUE@am__objects_26 = zip.lo
+@USE_PARSER_TRUE@am__objects_27 = flexer.lo bison.lo
+@PCRE_TRUE@am__objects_28 = pcre.lo
+@SSL_TRUE@am__objects_29 = certificate.lo pkcs7.lo crl.lo pkcs10.lo \
@SSL_TRUE@ mime_pkcs7.lo sslsocket.lo
-@SSL_TRUE@@SSL_TS_TRUE@am__objects_29 = timestamp.lo
-@SSH_TRUE@am__objects_30 = sshsocket.lo
-@LDAP_TRUE@am__objects_31 = ldap.lo
-@CURL_TRUE@am__objects_32 = curl.lo
-@EXPAT_TRUE@am__objects_33 = attribute.lo element.lo xml_parser.lo \
+@SSL_TRUE@@SSL_TS_TRUE@am__objects_30 = timestamp.lo
+@SSH_TRUE@am__objects_31 = sshsocket.lo
+@LDAP_TRUE@am__objects_32 = ldap.lo
+@CURL_TRUE@am__objects_33 = curl.lo
+@EXPAT_TRUE@am__objects_34 = attribute.lo element.lo xml_parser.lo \
@EXPAT_TRUE@ soap_fault.lo soap_gen_method.lo soap_parser.lo \
@EXPAT_TRUE@ soap_encoder.lo
-@LIBXML2_TRUE@am__objects_34 = node.lo document.lo schema.lo
-@MAGIC_TRUE@am__objects_35 = magic.lo
-@MYSQL_TRUE@am__objects_36 = mysql.lo
-@DBI_TRUE@am__objects_37 = dbi.lo
-@LIBEVENT_TRUE@am__objects_38 = event.lo
-@MINGW_FALSE@am__objects_39 = unixsocket.lo
-@STATIC_HANDLER_RPC_TRUE@am__objects_40 = mod_rpc.lo
-@MOD_SHIB_TRUE@@STATIC_HANDLER_SHIB_TRUE@am__objects_41 = mod_shib.lo \
+@LIBXML2_TRUE@am__objects_35 = node.lo document.lo schema.lo
+@MAGIC_TRUE@am__objects_36 = magic.lo
+@MYSQL_TRUE@am__objects_37 = mysql.lo
+@DBI_TRUE@am__objects_38 = dbi.lo
+@LIBEVENT_TRUE@am__objects_39 = event.lo
+@MINGW_FALSE@am__objects_40 = unixsocket.lo
+@STATIC_HANDLER_RPC_TRUE@am__objects_41 = mod_rpc.lo
+@MOD_SHIB_TRUE@@STATIC_HANDLER_SHIB_TRUE@am__objects_42 = mod_shib.lo \
@MOD_SHIB_TRUE@@STATIC_HANDLER_SHIB_TRUE@ mod_proxy_service.lo
-@STATIC_HANDLER_STREAM_TRUE@am__objects_42 = mod_stream.lo
-@STATIC_HANDLER_NOCAT_TRUE@am__objects_43 = mod_nocat.lo
-@STATIC_HANDLER_SOCKET_TRUE@am__objects_44 = mod_socket.lo
-@STATIC_HANDLER_SCGI_TRUE@am__objects_45 = mod_scgi.lo
-@STATIC_HANDLER_FCGI_TRUE@am__objects_46 = mod_fcgi.lo
-@GEOIP_TRUE@@STATIC_HANDLER_GEOIP_TRUE@am__objects_47 = mod_geoip.lo
-@PCRE_TRUE@@STATIC_HANDLER_PROXY_TRUE@am__objects_48 = mod_proxy.lo \
+@STATIC_HANDLER_STREAM_TRUE@am__objects_43 = mod_stream.lo
+@STATIC_HANDLER_NOCAT_TRUE@am__objects_44 = mod_nocat.lo
+@STATIC_HANDLER_SOCKET_TRUE@am__objects_45 = mod_socket.lo
+@STATIC_HANDLER_SCGI_TRUE@am__objects_46 = mod_scgi.lo
+@STATIC_HANDLER_FCGI_TRUE@am__objects_47 = mod_fcgi.lo
+@GEOIP_TRUE@@STATIC_HANDLER_GEOIP_TRUE@am__objects_48 = mod_geoip.lo
+@PCRE_TRUE@@STATIC_HANDLER_PROXY_TRUE@am__objects_49 = mod_proxy.lo \
@PCRE_TRUE@@STATIC_HANDLER_PROXY_TRUE@ mod_proxy_service.lo
-@EXPAT_TRUE@@STATIC_HANDLER_SOAP_TRUE@am__objects_49 = mod_soap.lo
-@STATIC_HANDLER_SSI_TRUE@am__objects_50 = mod_ssi.lo
-@STATIC_HANDLER_TSA_TRUE@am__objects_51 = mod_tsa.lo
-@STATIC_HANDLER_HTTP_TRUE@am__objects_52 = mod_http.lo
-@STATIC_HANDLER_ECHO_TRUE@am__objects_53 = mod_echo.lo
-am__objects_54 = common.lo objectIO.lo dialog.lo cdb.lo rdb.lo \
+@EXPAT_TRUE@@STATIC_HANDLER_SOAP_TRUE@am__objects_50 = mod_soap.lo
+@STATIC_HANDLER_SSI_TRUE@am__objects_51 = mod_ssi.lo
+@STATIC_HANDLER_TSA_TRUE@am__objects_52 = mod_tsa.lo
+@STATIC_HANDLER_HTTP_TRUE@am__objects_53 = mod_http.lo
+@STATIC_HANDLER_ECHO_TRUE@am__objects_54 = mod_echo.lo
+am__objects_55 = common.lo objectIO.lo dialog.lo cdb.lo rdb.lo \
dynamic.lo plugin.lo header.lo entity.lo multipart.lo \
vector.lo hash_map.lo tree.lo interrupt.lo compress.lo \
services.lo semaphore.lo base64.lo lock.lo string_ext.lo \
@@ -295,20 +297,20 @@ am__objects_54 = common.lo objectIO.lo dialog.lo cdb.lo rdb.lo \
ipt_ACCOUNT.lo value.lo query_parser.lo event_time.lo \
timeval.lo timer.lo notifier.lo string.lo file.lo process.lo \
file_config.lo log.lo options.lo application.lo cache.lo \
- date.lo url.lo tokenizer.lo command.lo thread.lo \
- $(am__objects_23) $(am__objects_24) $(am__objects_25) \
- $(am__objects_26) $(am__objects_27) $(am__objects_28) \
- $(am__objects_29) $(am__objects_30) $(am__objects_31) \
- $(am__objects_32) $(am__objects_33) $(am__objects_34) \
- $(am__objects_35) $(am__objects_36) $(am__objects_37) \
- $(am__objects_38) $(am__objects_39) $(am__objects_40) \
- $(am__objects_41) $(am__objects_42) $(am__objects_43) \
- $(am__objects_44) $(am__objects_45) $(am__objects_46) \
- $(am__objects_47) $(am__objects_48) $(am__objects_49) \
- $(am__objects_50) $(am__objects_51) $(am__objects_52) \
- $(am__objects_53)
+ date.lo url.lo tokenizer.lo command.lo $(am__objects_23) \
+ $(am__objects_24) $(am__objects_25) $(am__objects_26) \
+ $(am__objects_27) $(am__objects_28) $(am__objects_29) \
+ $(am__objects_30) $(am__objects_31) $(am__objects_32) \
+ $(am__objects_33) $(am__objects_34) $(am__objects_35) \
+ $(am__objects_36) $(am__objects_37) $(am__objects_38) \
+ $(am__objects_39) $(am__objects_40) $(am__objects_41) \
+ $(am__objects_42) $(am__objects_43) $(am__objects_44) \
+ $(am__objects_45) $(am__objects_46) $(am__objects_47) \
+ $(am__objects_48) $(am__objects_49) $(am__objects_50) \
+ $(am__objects_51) $(am__objects_52) $(am__objects_53) \
+ $(am__objects_54)
@FINAL_FALSE@am_lib@ULIB@_la_OBJECTS = $(am__objects_22) \
-@FINAL_FALSE@ $(am__objects_54)
+@FINAL_FALSE@ $(am__objects_55)
@FINAL_TRUE@am_lib@ULIB@_la_OBJECTS = all_c.lo all_cpp.lo
lib@ULIB@_la_OBJECTS = $(am_lib@ULIB@_la_OBJECTS)
lib@ULIB@_la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \
@@ -524,14 +526,14 @@ pkgconfig_DATA = ULib.pc
SRC_C = base/base.c base/base_error.c base/hash.c base/utility.c \
base/lzo/minilzo.c base/coder/cbase64.c \
base/coder/cquoted_printable.c base/coder/curl_coder.c \
- base/coder/cxml_coder.c base/coder/cescape.c $(am__append_1) \
- $(am__append_3) $(am__append_4) $(am__append_5) \
- $(am__append_6) $(am__append_7) $(am__append_8) \
- $(am__append_9) $(am__append_10) $(am__append_11) \
- $(am__append_12) $(am__append_13) $(am__append_14) \
- $(am__append_15) $(am__append_16) $(am__append_17) \
- $(am__append_18) $(am__append_20) $(am__append_22) \
- $(am__append_25) $(am__append_37)
+ base/coder/cxml_coder.c base/coder/cescape.c $(am__append_2) \
+ $(am__append_4) $(am__append_5) $(am__append_6) \
+ $(am__append_7) $(am__append_8) $(am__append_9) \
+ $(am__append_10) $(am__append_11) $(am__append_12) \
+ $(am__append_13) $(am__append_14) $(am__append_15) \
+ $(am__append_16) $(am__append_17) $(am__append_18) \
+ $(am__append_19) $(am__append_21) $(am__append_23) \
+ $(am__append_26) $(am__append_38)
SRC_CPP = internal/common.cpp internal/objectIO.cpp ui/dialog.cpp \
db/cdb.cpp db/rdb.cpp dynamic/dynamic.cpp dynamic/plugin.cpp \
mime/header.cpp mime/entity.cpp mime/multipart.cpp \
@@ -553,21 +555,21 @@ SRC_CPP = internal/common.cpp internal/objectIO.cpp ui/dialog.cpp \
query/query_parser.cpp event/event_time.cpp timeval.cpp \
timer.cpp notifier.cpp string.cpp file.cpp process.cpp \
file_config.cpp log.cpp options.cpp application.cpp cache.cpp \
- date.cpp url.cpp tokenizer.cpp command.cpp thread.cpp \
- $(am__append_2) $(am__append_19) $(am__append_21) \
- $(am__append_23) $(am__append_24) $(am__append_26) \
- $(am__append_27) $(am__append_28) $(am__append_29) \
- $(am__append_30) $(am__append_31) $(am__append_32) \
- $(am__append_33) $(am__append_34) $(am__append_35) \
- $(am__append_36) $(am__append_38) $(am__append_39) \
- $(am__append_40) $(am__append_41) $(am__append_42) \
- $(am__append_43) $(am__append_44) $(am__append_45) \
- $(am__append_46) $(am__append_47) $(am__append_48) \
- $(am__append_49) $(am__append_50) $(am__append_51) \
- $(am__append_52)
+ date.cpp url.cpp tokenizer.cpp command.cpp $(am__append_1) \
+ $(am__append_3) $(am__append_20) $(am__append_22) \
+ $(am__append_24) $(am__append_25) $(am__append_27) \
+ $(am__append_28) $(am__append_29) $(am__append_30) \
+ $(am__append_31) $(am__append_32) $(am__append_33) \
+ $(am__append_34) $(am__append_35) $(am__append_36) \
+ $(am__append_37) $(am__append_39) $(am__append_40) \
+ $(am__append_41) $(am__append_42) $(am__append_43) \
+ $(am__append_44) $(am__append_45) $(am__append_46) \
+ $(am__append_47) $(am__append_48) $(am__append_49) \
+ $(am__append_50) $(am__append_51) $(am__append_52) \
+ $(am__append_53)
@FINAL_FALSE@lib@ULIB@_la_SOURCES = $(SRC_C) $(SRC_CPP)
@FINAL_TRUE@lib@ULIB@_la_SOURCES = all_c.c all_cpp.cpp
-lib@ULIB@_la_LDFLAGS = $(LIBRARY_LIBTOOL_OPTIONS) $(am__append_53)
+lib@ULIB@_la_LDFLAGS = $(LIBRARY_LIBTOOL_OPTIONS) $(am__append_54)
lib_LTLIBRARIES = lib@ULIB@.la
@MINGW_TRUE@lib@ULIB@_la_DEPENDENCIES = ULib-win32-res.o
@MS_LIB_AVAILABLE_TRUE@noinst_DATA = @ULIB@-$(VERSION).lib
View
4 src/ulib/all_cpp.cpp
@@ -84,6 +84,10 @@
# include "net/unixsocket.cpp"
#endif
+#ifdef HAVE_PTHREAD_H
+# include "thread.cpp"
+#endif
+
#ifdef HAVE_ZIP
# include "zip/zip.cpp"
#endif
View
4 src/ulib/net/ipaddress.cpp
@@ -14,9 +14,7 @@
#include <ulib/net/ipaddress.h>
#include <ulib/container/vector.h>
-#if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO)
-# include "socket_address.cpp"
-#endif
+#include "socket_address.cpp"
const UString* UIPAddress::str_localhost;
View
2  src/ulib/net/server/client_image.cpp
@@ -285,7 +285,7 @@ void UClientImage_Base::run()
U_INTERNAL_DUMP("UClientImage_Base::run() flag_loop = %b", UServer_Base::flag_loop)
if (UServer_Base::flag_loop == false &&
- UServer_Base::preforked_num_kids == 0 &&
+ UServer_Base::preforked_num_kids <= 0 &&
UServer_Base::proc->child())
{
U_EXIT(0);
View
2  src/ulib/net/server/plugin/mod_http.cpp
@@ -357,7 +357,7 @@ int UHttpPlugIn::handlerRequest()
{
// NB: if server no preforked (ex: nodog) process the HTTP CGI request with fork....
- bool async = (UServer_Base::preforked_num_kids == 0 && UClientImage_Base::isPipeline() == false);
+ bool async = (UServer_Base::preforked_num_kids <= 0 && UClientImage_Base::isPipeline() == false);
if (UHTTP::processCGIRequest((UCommand*)0, 0, async, true) == false)
{
View
2  src/ulib/net/server/server.cpp
@@ -1297,6 +1297,8 @@ void UServer_Base::run()
if (isPreForked())
{
+ U_INTERNAL_ASSERT_MAJOR(preforked_num_kids,0)
+
UTimeVal to_sleep(0L, 500 * 1000L);
int pid, status, nkids = 0, n = max_Keep_Alive / preforked_num_kids;
View
2  src/ulib/notifier.cpp
@@ -995,8 +995,8 @@ const char* UNotifier::dump(bool reset) const
UObjectIO::os->put('\n');
*UObjectIO::os << "pool (UNotifier " << (void*)pool << ")\n"
- << "first (UNotifier " << (void*)first << ")\n"
<< "next (UNotifier " << (void*)next << ")\n"
+ << "first (UNotifier " << (void*)first << ")\n"
<< "handler_event_fd (UEventFd " << (void*)handler_event_fd << ')';
if (reset)
View
448 src/ulib/thread.cpp
@@ -18,65 +18,188 @@
typedef void* (*exec_t)(void*);
typedef void (*cleanup_t)(void*);
+#define U_SIGSTOP SIGRTMIN+1
+#define U_SIGCONT SIGRTMIN+2
+
#ifndef HAVE_NANOSLEEP
extern "C" { int nanosleep (const struct timespec* requested_time,
struct timespec* remaining); }
#endif
-#define CCXX_SIG_THREAD_SUSPEND SIGSTOP
-#define CCXX_SIG_THREAD_RESUME SIGCONT
+UThread* UThread::first;
+pthread_cond_t UThread::cond = PTHREAD_COND_INITIALIZER;
+pthread_mutex_t UThread::lock = PTHREAD_MUTEX_INITIALIZER;
+
+class UThreadImpl {
+public:
+ // Check for memory error
+ U_MEMORY_TEST
+
+ // Allocator e Deallocator
+ U_MEMORY_ALLOCATOR
+ U_MEMORY_DEALLOCATOR
+
+ UThreadImpl(bool __suspendEnable)
+ {
+ U_TRACE_REGISTER_OBJECT(0, UThreadImpl, "%b", __suspendEnable)
+
+ _tid = 0;
+ _signal = 0;
+ _cancel = 0;
+ _suspendCount = 0;
+ _suspendEnable = __suspendEnable;
+
+ (void) U_SYSCALL(pthread_attr_init, "%p", &_attr);
+ }
+
+ ~UThreadImpl()
+ {
+ U_TRACE_UNREGISTER_OBJECT(0, UThreadImpl)
+
+ (void) U_SYSCALL(pthread_attr_destroy, "%p", &_attr);
+ }
+
+#ifdef DEBUG
+ const char* dump(bool reset) const;
+#endif
+
+private:
+ pthread_t _tid;
+ pthread_attr_t _attr;
+ int _cancel, _signal, _suspendCount;
+ bool _suspendEnable;
+
+ // derived class copy constructor creates new instance, so base
+ // copy constructor of ThreadImpl should do nothing...
+
+ UThreadImpl(const UThreadImpl& copy) {}
+ UThreadImpl& operator=(const UThreadImpl& copy) { return *this; }
-UThread::UThread()
+ friend class UThread;
+};
+
+UThread::UThread(bool __suspendEnable)
{
- U_TRACE_REGISTER_OBJECT(0, UThread, "")
+ U_TRACE_REGISTER_OBJECT(0, UThread, "%b", __suspendEnable)
- _tid = 0;
- _cancel = cancelInitial;
- _suspendEnable = true;
+ priv = U_NEW(UThreadImpl(__suspendEnable));
+ next = first;
+ first = this;
- (void) U_SYSCALL(pthread_attr_init, "%p", &_attr);
+ U_INTERNAL_DUMP("first = %p next = %p", first, next)
}
UThread::~UThread()
{
U_TRACE_UNREGISTER_OBJECT(0, UThread)
- (void) U_SYSCALL(pthread_attr_destroy, "%p", &_attr);
+ if (priv) stop();
+
+ U_INTERNAL_DUMP("first = %p next = %p", first, next)
+
+ if (next) delete next;
+}
+
+UThread* UThread::getThread()
+{
+ U_TRACE(1, "UThread::getThread()")
+
+ U_INTERNAL_DUMP("first = %p", first)
+
+ pthread_t _tid = U_SYSCALL_NO_PARAM(pthread_self);
+
+ for (UThread* obj = first; obj; obj = obj->next)
+ {
+ if (U_SYSCALL(pthread_equal, "%p,%p", _tid, obj->priv->_tid)) U_RETURN_POINTER(obj, UThread);
+ }
+
+ U_RETURN_POINTER(0, UThread);
+}
+
+void UThread::stop()
+{
+ U_TRACE(1, "UThread::stop()")
+
+ U_INTERNAL_ASSERT_POINTER(priv)
+
+ (void) U_SYSCALL(pthread_mutex_unlock, "%p", &lock);
+
+ (void) U_SYSCALL(pthread_cancel, "%p", priv->_tid);
+
+ if (isDetached() == false) (void) U_SYSCALL(pthread_join, "%p,%p", priv->_tid, 0);
+ else
+ {
+# ifdef HAVE_PTHREAD_YIELD
+ (void) U_SYSCALL_NO_PARAM(pthread_yield);
+# endif
+ }
}
-sigset_t* UThread::blockedSignals(sigset_t* sig)
+void UThread::close()
{
- U_TRACE(0, "UThread::blockedSignals(%p)", sig)
+ U_TRACE(1, "UThread::close()")
+
+ U_INTERNAL_ASSERT_POINTER(priv)
+
+ UThread* obj = first;
+ UThread** ptr = &first;
+
+ while ((obj = *ptr))
+ {
+ U_INTERNAL_ASSERT_POINTER(obj)
- sigemptyset(sig);
+ if (U_SYSCALL(pthread_equal, "%p,%p", priv->_tid, obj->priv->_tid))
+ {
+ *ptr = obj->next;
+ obj->next = 0;
- sigaddset(sig, SIGINT);
- sigaddset(sig, SIGKILL);
- sigaddset(sig, SIGHUP);
- sigaddset(sig, SIGABRT);
- sigaddset(sig, SIGALRM);
- sigaddset(sig, SIGPIPE);
+ break;
+ }
+
+ ptr = &(*ptr)->next;
+ }
+
+ delete priv;
+ priv = 0;
+}
+
+void UThread::threadCleanup(UThread* th)
+{
+ U_TRACE(0, "UThread::threadCleanup(%p)", th)
- return sig;
+ th->close();
}
void UThread::yield()
{
U_TRACE(1, "UThread::yield()")
-#ifdef CCXX_SIG_THREAD_CANCEL
- sigset_t cancel, old;
+ // Yields the current thread's CPU time slice to allow another thread to begin immediate execution.
- sigemptyset(&cancel);
- sigaddset(&cancel, CCXX_SIG_THREAD_CANCEL);
+ U_INTERNAL_DUMP("_cancel = %d", priv->_cancel)
- if (th->_cancel != cancelDisabled &&
- th->_cancel != cancelInitial)
+#ifndef CCXX_SIG_THREAD_CANCEL
+ U_SYSCALL_VOID_NO_PARAM(pthread_testcancel);
+#else
+ sigset_t cancel, old;
+ bool bcancel = (priv->_cancel != cancelDisabled && priv->_cancel != cancelInitial);
+
+ if (bcancel)
{
+# ifdef sigemptyset
+ sigemptyset(&cancel);
+# else
+ (void) U_SYSCALL(sigemptyset, "%p", &cancel);
+# endif
+
+# ifdef sigaddset
+ sigaddset(&cancel, CCXX_SIG_THREAD_CANCEL);
+# else
+ (void) U_SYSCALL(sigaddset, "%p,%d", &cancel, CCXX_SIG_THREAD_CANCEL);
+# endif
+
(void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_UNBLOCK, &cancel, &old);
}
-#else
- U_SYSCALL_VOID_NO_PARAM(pthread_testcancel);
#endif
#ifdef HAVE_PTHREAD_YIELD
@@ -84,124 +207,224 @@ void UThread::yield()
#endif
#ifdef CCXX_SIG_THREAD_CANCEL
- if (th->_cancel != cancelDisabled &&
- th->_cancel != cancelInitial)
- {
- (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_SETMASK, &old, 0);
- }
+ if (bcancel) (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_SETMASK, &old, 0);
#endif
}
bool UThread::isDetached() const
{
- U_TRACE(1, "UThread::close()")
+ U_TRACE(1, "UThread::isDetached()")
- if (_tid)
- {
- int state;
+ U_INTERNAL_ASSERT_POINTER(priv->_tid)
- (void) U_SYSCALL(pthread_attr_getdetachstate, "%p,%p", &_attr, &state);
+ int state;
- if (state == PTHREAD_CREATE_DETACHED) U_RETURN(true);
- }
+ (void) U_SYSCALL(pthread_attr_getdetachstate, "%p,%p", &(priv->_attr), &state);
+
+ if (state == PTHREAD_CREATE_DETACHED) U_RETURN(true);
U_RETURN(false);
}
-void UThread::close()
+void UThread::sigInstall(int signo)
{
- U_TRACE(1, "UThread::close()")
+ U_TRACE(1, "UThread::sigInstall(%d)", signo)
- bool detached = isDetached();
+ struct sigaction sa;
- setCancel(cancelDisabled);
-
- // final can call destructor (that call Terminate)
+# ifdef sigemptyset
+ sigemptyset(&sa.sa_mask);
+# else
+ (void) U_SYSCALL(sigemptyset, "%p", &sa.sa_mask);
+# endif
- final();
+#ifdef SA_RESTART
+ sa.sa_flags = SA_RESTART;
+#else
+ s.sa_flags = 0;
+#endif
- // see if detached, and hence self deleting
+#ifdef SA_INTERRUPT
+ sa.sa_flags |= SA_INTERRUPT;
+#endif
+ sa.sa_handler = sigHandler;
- if (detached) delete this;
+ (void) U_SYSCALL(sigaction, "%d,%p,%p", signo, &sa, 0);
}
-void UThread::setSuspend(Suspend mode)
+void UThread::sigHandler(int signo)
{
- U_TRACE(1, "UThread::setSuspend(%d)", mode)
+ U_TRACE(1, "UThread::sigHandler(%d)", signo)
+
+ (void) U_SYSCALL(pthread_mutex_lock, "%p", &lock);
+
+ UThread* th = getThread();
+
+ U_INTERNAL_DUMP("_signal = %d _suspendCount = %d", th->priv->_signal, th->priv->_suspendCount)
+
+ th->priv->_signal = signo;
- if (_tid)
+ if (signo == U_SIGSTOP &&
+ th->priv->_suspendCount++ == 0)
{
- _suspendEnable = (mode == suspendEnable);
+ U_INTERNAL_DUMP("SUSPEND: start(%6D)")
-#ifndef HAVE_PTHREAD_SUSPEND
-# ifdef CCXX_SIG_THREAD_SUSPEND
- sigset_t mask;
+ (void) U_SYSCALL(pthread_cond_wait, "%p,%p", &cond, &lock);
- sigemptyset(&mask);
- sigaddset(&mask, CCXX_SIG_THREAD_SUSPEND);
+ U_INTERNAL_DUMP("SUSPEND: end(%6D)")
+ }
+ else if (signo == U_SIGCONT &&
+ th->priv->_suspendCount > 0 &&
+ th->priv->_suspendCount-- == 1)
+ {
+ (void) U_SYSCALL(pthread_cond_signal, "%p", &cond);
+ }
- switch(mode)
- {
- case suspendEnable: (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_UNBLOCK, &mask, 0); break;
- case suspendDisable: (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_BLOCK, &mask, 0); break;
- }
-# endif
-#endif
+ (void) U_SYSCALL(pthread_mutex_unlock, "%p", &lock);
+}
+
+void UThread::signal(int signo)
+{
+ U_TRACE(1, "UThread::signal(%d)", signo)
+
+ // set the _signal variable to the given value. Can only be
+ // done if called from the process that the thread is associated
+ // with. If called from a different process, the given signal
+ // is sent to the process.
+
+ pthread_t _tid = U_SYSCALL_NO_PARAM(pthread_self);
+
+ if (U_SYSCALL(pthread_equal, "%p,%p", _tid, priv->_tid)) sigHandler(signo);
+ else
+ {
+ (void) U_SYSCALL(pthread_kill, "%p,%d", priv->_tid, signo);
+
+ yield(); // give the signal a time to kick in
}
}
+/* You can't kill or stop just one thread from another process. You can send a signal to a particular thread,
+ * but the stop/abort action that is taken by the signal affects the whole process. In the earlier implementation
+ * of Linux threads, it was possible to stop a single thread with SIGSTOP, but this behaviour has now been fixed
+ * to conform to the Posix standard (so it stops all threads in the process).
+ */
+
void UThread::suspend()
{
U_TRACE(1, "UThread::suspend()")
- if (_tid) (void) U_SYSCALL(pthread_kill, "%d,%d", _tid, CCXX_SIG_THREAD_SUSPEND);
+ U_INTERNAL_ASSERT_POINTER(priv->_tid)
+
+ if (priv->_suspendEnable) signal(U_SIGSTOP);
}
void UThread::resume()
{
U_TRACE(1, "UThread::resume()")
- if (_tid) (void) U_SYSCALL(pthread_kill, "%d,%d", _tid, CCXX_SIG_THREAD_RESUME);
+ U_INTERNAL_ASSERT_POINTER(priv->_tid)
+
+ if (priv->_suspendEnable) signal(U_SIGCONT);
}
-__noreturn void UThread::execHandler(UThread* th)
+void UThread::execHandler(UThread* th)
{
U_TRACE(1, "UThread::execHandler(%p)", th)
sigset_t mask;
- (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_BLOCK, blockedSignals(&mask), 0);
+# ifdef sigemptyset
+ sigemptyset(&mask);
+# else
+ (void) U_SYSCALL(sigemptyset, "%p", &mask);
+# endif
- th->_tid = U_SYSCALL_NO_PARAM(pthread_self);
+# ifdef sigaddset
+ sigaddset(&mask, SIGHUP);
+ sigaddset(&mask, SIGINT);
+ sigaddset(&mask, SIGABRT);
+ sigaddset(&mask, SIGPIPE);
+ sigaddset(&mask, SIGALRM);
+# else
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, SIGHUP);
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, SIGINT);
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, SIGABRT);
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, SIGPIPE);
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, SIGALRM);
+# endif
- th->setSuspend(suspendEnable);
+ (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_BLOCK, &mask, 0);
- th->yield();
+ if (th->priv->_suspendEnable)
+ {
+# ifndef HAVE_PTHREAD_SUSPEND
+ // You can't kill or stop just one thread from another process. You can send a signal to a particular thread,
+ // but the stop/abort action that is taken by the signal affects the whole process. In the earlier implementation
+ // of Linux threads, it was possible to stop a single thread with SIGSTOP, but this behaviour has now been fixed
+ // to conform to the Posix standard (so it stops all threads in the process).
+ //
+
+# ifdef sigemptyset
+ sigemptyset(&mask);
+# else
+ (void) U_SYSCALL(sigemptyset, "%p", &mask);
+# endif
+
+# ifdef sigaddset
+ sigaddset(&mask, U_SIGSTOP);
+ sigaddset(&mask, U_SIGCONT);
+# else
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, U_SIGSTOP);
+ (void) U_SYSCALL(sigaddset, "%p,%d", &mask, U_SIGCONT);
+# endif
+
+ (void) U_SYSCALL(pthread_sigmask, "%d,%p,%p", SIG_UNBLOCK, &mask, 0);
+
+ th->sigInstall(U_SIGSTOP);
+ th->sigInstall(U_SIGCONT);
+# endif
+ }
- pthread_cleanup_push((cleanup_t)threadCleanup, th);
+ th->priv->_tid = U_SYSCALL_NO_PARAM(pthread_self);
- th->initial();
+ U_INTERNAL_DUMP("_tid = %p", th->priv->_tid)
- if (th->getCancel() == cancelInitial) th->setCancel(cancelDeferred);
+ pthread_cleanup_push((cleanup_t)UThread::threadCleanup, th);
- th->run();
+ th->setCancel(cancelDeferred);
- th->setCancel(cancelDisabled);
+ th->run();
pthread_cleanup_pop(0);
th->close();
-
- U_SYSCALL_VOID(pthread_exit, "%p", 0);
}
-int UThread::start()
+bool UThread::start()
{
U_TRACE(1, "UThread::start()")
- int result = (_tid ? -1 : U_SYSCALL(pthread_create, "%p,%p,%p,%p", &_tid, &_attr, (exec_t)execHandler, this));
+ U_INTERNAL_ASSERT_EQUALS(priv->_tid, 0)
+
+ if (U_SYSCALL(pthread_create, "%p,%p,%p,%p", &(priv->_tid), &(priv->_attr), (exec_t)execHandler, this) == 0) U_RETURN(true);
+
+ U_RETURN(false);
+}
+
+bool UThread::detach()
+{
+ U_TRACE(1, "UThread::detach()")
+
+ if (priv->_tid)
+ {
+ if (U_SYSCALL(pthread_detach, "%p", priv->_tid)) U_RETURN(false);
+ }
+ else
+ {
+ if (U_SYSCALL(pthread_attr_setdetachstate, "%p,%d", &(priv->_attr), PTHREAD_CREATE_DETACHED)) U_RETURN(false);
+ }
- U_RETURN(result);
+ U_RETURN(true);
}
void UThread::setCancel(int mode)
@@ -227,14 +450,18 @@ void UThread::setCancel(int mode)
break;
}
- _cancel = mode;
+ priv->_cancel = mode;
+
+ U_INTERNAL_DUMP("_cancel = %d", priv->_cancel)
}
int UThread::enterCancel()
{
U_TRACE(1, "UThread::enterCancel()")
- int old = _cancel;
+ U_INTERNAL_DUMP("_cancel = %d", priv->_cancel)
+
+ int old = priv->_cancel;
if (old != cancelDisabled &&
old != cancelImmediate)
@@ -251,7 +478,9 @@ void UThread::exitCancel(int old)
{
U_TRACE(1, "UThread::exitCancel(%d)", old)
- if (old != _cancel)
+ U_INTERNAL_DUMP("_cancel = %d", priv->_cancel)
+
+ if (old != priv->_cancel)
{
U_SYSCALL_VOID_NO_PARAM(pthread_testcancel);
@@ -259,29 +488,60 @@ void UThread::exitCancel(int old)
}
}
-void UThread::sleep(time_t timeout)
+void UThread::sleep(time_t timeoutMS)
{
- U_TRACE(1, "UThread::sleep(%ld)", timeout)
+ U_TRACE(1+256, "UThread::sleep(%ld)", timeoutMS)
+
+#ifdef CCXX_SIG_THREAD_CANCEL
+ UThread* th = getThread();
+
+ int old = th->enterCancel();
+#endif
+ struct timespec ts = { timeoutMS / 1000L, (timeoutMS % 1000L) * 1000000L };
- struct timespec ts;
- int old = enterCancel();
+ U_INTERNAL_ASSERT(ts.tv_sec >= 0L)
+ U_INTERNAL_ASSERT_RANGE(0L, ts.tv_nsec, 999999999L)
- ts.tv_sec = timeout / 1000;
- ts.tv_nsec = (timeout % 1000) * 1000000;
+#ifdef HAVE_PTHREAD_DELAY
+ pthread_delay(&ts);
+#else
+ U_INTERNAL_DUMP("Call nanosleep(%2D)")
(void) U_SYSCALL(nanosleep, "%p,%p", &ts, 0);
- exitCancel(old);
+ U_INTERNAL_DUMP("Return nanosleep(%2D)")
+#endif
+
+#ifdef CCXX_SIG_THREAD_CANCEL
+ th->exitCancel(old);
+#endif
}
#ifdef DEBUG
# include <ulib/internal/objectIO.h>
+const char* UThreadImpl::dump(bool reset) const
+{
+ *UObjectIO::os << "_tid " << _tid << '\n'
+ << "_cancel " << _cancel << '\n'
+ << "_signal " << _signal << '\n'
+ << "_suspendCount " << _suspendCount << '\n'
+ << "_suspendEnable " << _suspendEnable << ')';
+
+ if (reset)
+ {
+ UObjectIO::output();
+
+ return UObjectIO::buffer_output;
+ }
+
+ return 0;
+}
+
const char* UThread::dump(bool reset) const
{
- *UObjectIO::os << "_tid " << _tid << '\n'
- << "_cancel " << _cancel << '\n'
- << "_suspendEnable " << _suspendEnable;
+ *UObjectIO::os << "next (UThread " << (void*)next << ")\n"
+ << "first (UThread " << (void*)first << ')';
if (reset)
{
View
6 src/ulib/timer.cpp
@@ -59,8 +59,6 @@ U_NO_EXPORT void UTimer::insertEntry()
while (*ptr)
{
- PREFETCH_ATTRIBUTE(&(*ptr)->next, 1)
-
if (*this < **ptr) break;
ptr = &(*ptr)->next;
@@ -275,8 +273,6 @@ U_EXPORT ostream& operator<<(ostream& os, const UTimer& t)
for (UTimer* item = t.next; item; item = item->next)
{
- PREFETCH_ATTRIBUTE(item->next, 0)
-
os.put(' ');
if (item->alarm) os << *item->alarm;
@@ -298,8 +294,6 @@ bool UTimer::invariant()
{
for (UTimer* item = first; item->next; item = item->next)
{
- PREFETCH_ATTRIBUTE(item->next, 0)
-
U_INTERNAL_ASSERT_MINOR(*item,*(item->next))
}
}
View
24 src/ulib/utility/interrupt.cpp
@@ -213,17 +213,17 @@ void UInterrupt::setMaskInterrupt(sigset_t* mask, int signo)
if (mask)
{
-# ifdef sigemptyset
+# ifdef sigemptyset
sigemptyset(mask);
-# else
+# else
(void) U_SYSCALL(sigemptyset, "%p", mask);
-# endif
+# endif
-# ifdef sigaddset
+# ifdef sigaddset
sigaddset(mask, signo);
-# else
+# else
(void) U_SYSCALL(sigaddset, "%p,%d", mask, signo);
-# endif
+# endif
}
else
{
@@ -231,23 +231,23 @@ void UInterrupt::setMaskInterrupt(sigset_t* mask, int signo)
mask_interrupt = new sigset_t;
-# ifdef sigemptyset
+# ifdef sigemptyset
sigemptyset(mask_interrupt);
-# else
+# else
(void) U_SYSCALL(sigemptyset, "%p", mask_interrupt);
-# endif
+# endif
-# ifdef sigaddset
+# ifdef sigaddset
sigaddset(mask_interrupt, SIGUSR1); // 10
sigaddset(mask_interrupt, SIGUSR2); // 12
sigaddset(mask_interrupt, SIGALRM); // 14
sigaddset(mask_interrupt, SIGCHLD); // 17
-# else
+# else
(void) U_SYSCALL(sigaddset, "%p,%d", mask_interrupt, SIGUSR1); // 10
(void) U_SYSCALL(sigaddset, "%p,%d", mask_interrupt, SIGUSR2); // 12
(void) U_SYSCALL(sigaddset, "%p,%d", mask_interrupt, SIGALRM); // 14
(void) U_SYSCALL(sigaddset, "%p,%d", mask_interrupt, SIGCHLD); // 17
-# endif
+# endif
}
}
View
2  src/ulib/utility/services.cpp
@@ -77,7 +77,7 @@ bool UServices::isSetuidRoot()
{
U_TRACE(1, "UServices::isSetuidRoot()")
- U_INTERNAL_DUMP("u_ser_name = %.*S", u_user_name_len, u_user_name)
+ U_INTERNAL_DUMP("u_user_name = %.*S", u_user_name_len, u_user_name)
bool i_am_root = (u_user_name_len == 4 && (uid_t) U_SYSCALL_NO_PARAM(getuid) == 0);
View
7 tests/examples/IR/WEB/form/it/result.doc
@@ -1,7 +0,0 @@
- <dl class="doc">
- <dt><a href="%s" class="doc_title">%s</a></dt>
-
- <dd class="doc_text">%s <code class="delim">...</code></dd>
-
- <dd class="doc_navi"><span class="doc_link">file://%s</span></dd>
- </dl>
View
2  tests/examples/IR/WEB/form/it/result.pag
@@ -1,2 +0,0 @@
- <div class="paging">%s</div>
- </div>
View
4 tests/examples/IR/WEB/form/it/result.top
@@ -1,4 +0,0 @@
- <div id="estresult" class="estresult">
- <div class="resinfo">
- Results of <strong>%u</strong> - <strong>%u</strong> of about <strong>%u</strong> for <strong>%s</strong> (%s sec.)
- </div>
View
53 tests/examples/IR/WEB/form/it/seek.hlp
@@ -1,53 +0,0 @@
- <div class="help">
- <h1 class="title">Help</h1>
-
- <h2>What is This?</h2>
-
- <p>This is a full-text search system. You can search for documents including some specified words.</p>
-
- <h2>How to Use</h2>
-
- <p>Input search phrase into the field at the top of the page. For example, if you search for documents including "computer", input the
- following.</p>
- <pre>computer</pre>
-
- <p>If you search for documents including both of "network" and "socket", input the following.</p>
- <pre>network socket</pre>
-
- <p>It is the same as the following.</p>
- <pre>network AND socket</pre>
-
- <p>If you search for documents including "network" followed by "socket", input the following.</p>
- <pre>"network socket"</pre>
-
- <p>If you search for documents including one or both of "network" and "socket", input the following.</p>
- <pre>network OR socket</pre>
-
- <p>If you search for documents including "network" but without "socket", input the following.</p>
- <pre>network AND NOT socket</pre>
-
- <p>For more complex query, you can use "<code>(</code>". Note that the priority of "<code>(</code>" is higher than that of "<code>AND</code>",
- "<code>OR</code>" and "<code>NOT</code>". So, the following is to search for documents including one of "F1", "F-1", "Formula One", and including
- one of "champion" and "victory".</p>
- <pre>(F1 OR F-1 OR "Formula One") AND (champion OR victory)</pre>
-
- <h2>You can use DOS wildcard characters</h2>
-
- <p>If you search for documents including some words beginning with "inter", input the following.</p>
- <pre>inter*</pre>
-
- <p>If you search for documents including some words ending with "sphere", input the following.</p>
- <pre>*sphere</pre>
-
- <p>If you search for documents matching some words matching "?n*able" (unable, unavoidable, inevitable, ...), input the following.</p>
- <pre>?n*able</pre>
-
- <h2>Other Faculties</h2>
-
- <p>"<code>[...] per page</code>" specifies the number of shown documents per page. If documents over one page correspond, you can move to another
- page via anchors of "<code>PREV</code>" and "<code>NEXT</code>" at the bottom of the page.</p>
-
- <h2>Information</h2>
-
- <p>See <a href="http://www.unirel.com/">the project site</a> for more detail.</p>
- </div>
View
74 tests/examples/IR/WEB/form/it/seek.tmpl
@@ -1,74 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-<head>
- <meta name="generator" content="HTML Tidy for Linux (vers 14 June 2007), see www.w3.org">
- <meta content="text/html; charset=utf-8" http-equiv="content-type">
-
- <title>ULib search engine: a full-text search system for communities</title>
- <link title="Services" rel="stylesheet" href="/IR/WEB/css/ir.css" type="text/css">
-</head>
-
-<body>
- <div id="estform" class="estform">
- <form action="seek.%s" method="post" id="form_self" name="form_self">
- <div class="form_navi">
- <a href="%s" class="navilink">help</a>
- </div>
-
- <div class="form_basic">
- <input type="text" name="phrase" value="" size="80" id="phrase" class="text" tabindex="1" accesskey="0"> <input type="submit" value="Search"
- id="search" class="submit" tabindex="2" accesskey="1">
- </div>
-
- <div class="form_extension">
- <select name="perpage" id="perpage" tabindex="3">
- <option value="10" selected="selected">
- 10
- </option>
-
- <option value="20">
- 20
- </option>
-
- <option value="30">
- 30
- </option>
-
- <option value="40">
- 40
- </option>
-
- <option value="50">
- 50
- </option>
-
- <option value="60">
- 60
- </option>
-
- <option value="70">
- 70
- </option>
-
- <option value="80">
- 80
- </option>