From: Rainer Jung Date: Sat, 12 Nov 2011 06:35:58 +0000 (+0000) Subject: Pre GA removal ob components that will not be included: X-Git-Tag: 2.3.16~180 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bbc0450240cd356e8f9dc322e7cdd06c76248b2c;p=apache Pre GA removal ob components that will not be included: Part 2: Remove mod_serf. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1201210 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/Apache-apr2.dsw b/Apache-apr2.dsw index f2c9bf1d28..579149a3f0 100644 --- a/Apache-apr2.dsw +++ b/Apache-apr2.dsw @@ -2394,27 +2394,6 @@ Package=<4> ############################################################################### -Project: "mod_serf"=.\modules\proxy\mod_serf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency - Begin Project Dependency - Project_Dep_Name libhttpd - End Project Dependency - Begin Project Dependency - Project_Dep_Name mod_proxy - End Project Dependency -}}} - -############################################################################### - Project: "mod_session"=.\modules\session\mod_session.dsp - Package Owner=<4> Package=<5> diff --git a/Apache.dsw b/Apache.dsw index 9db05632af..ebfb3b3a98 100644 --- a/Apache.dsw +++ b/Apache.dsw @@ -2813,30 +2813,6 @@ Package=<4> ############################################################################### -Project: "mod_serf"=.\modules\proxy\mod_serf.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name libapr - End Project Dependency - Begin Project Dependency - Project_Dep_Name libaprutil - End Project Dependency - Begin Project Dependency - Project_Dep_Name libhttpd - End Project Dependency - Begin Project Dependency - Project_Dep_Name mod_proxy - End Project Dependency -}}} - -############################################################################### - Project: "mod_session"=.\modules\session\mod_session.dsp - Package Owner=<4> Package=<5> diff --git a/BuildBin.dsp b/BuildBin.dsp index 0a557ea74a..08d4762b65 100644 --- a/BuildBin.dsp +++ b/BuildBin.dsp @@ -39,7 +39,7 @@ CFG=BuildBin - Win32 Debug # PROP Use_Debug_Libraries 0 # PROP Output_Dir "" # PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /f makefile.win INSTDIR="\Apache2" LONG=Release _trydb _trylua _tryxml _tryssl _tryzlib _tryserf _dummy" +# PROP Cmd_Line "NMAKE /f makefile.win INSTDIR="\Apache2" LONG=Release _trydb _trylua _tryxml _tryssl _tryzlib _dummy" # PROP Rebuild_Opt "" # PROP Target_File "\Apache2\bin\httpd.exe" # PROP Bsc_Name ".\Browse\httpd.bsc" @@ -58,7 +58,7 @@ CFG=BuildBin - Win32 Debug # PROP Use_Debug_Libraries 1 # PROP Output_Dir "" # PROP Intermediate_Dir "" -# PROP Cmd_Line "NMAKE /f makefile.win INSTDIR="\Apache2" LONG=Debug _trydb _trylua _tryxml _tryssl _tryzlib _tryserf _dummy" +# PROP Cmd_Line "NMAKE /f makefile.win INSTDIR="\Apache2" LONG=Debug _trydb _trylua _tryxml _tryssl _tryzlib _dummy" # PROP Rebuild_Opt "" # PROP Target_File "\Apache2\bin\httpd.exe" # PROP Bsc_Name ".\Browse\httpd.bsc" diff --git a/CHANGES b/CHANGES index 1754568f9c..2acf4c0f14 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ Changes with Apache 2.4.0 *) Pre GA removal ob components that will not be included: - mod_noloris was superseded by mod_reqtimeout. + - mod_serf [Rainer Jung] *) core: Set MaxMemFree 2048 by default. [Stefan Fritsch] diff --git a/Makefile.in b/Makefile.in index e5d75c8ac2..9b11141d79 100644 --- a/Makefile.in +++ b/Makefile.in @@ -202,7 +202,6 @@ INSTALL_HEADERS = \ $(srcdir)/modules/loggers/mod_log_config.h \ $(srcdir)/modules/mappers/mod_rewrite.h \ $(srcdir)/modules/proxy/mod_proxy.h \ - $(srcdir)/modules/proxy/mod_serf.h \ $(srcdir)/modules/session/mod_session.h \ $(srcdir)/modules/ssl/mod_ssl.h \ $(srcdir)/os/$(OS_DIR)/*.h diff --git a/Makefile.win b/Makefile.win index 1a54237f97..3051e5f77b 100644 --- a/Makefile.win +++ b/Makefile.win @@ -136,32 +136,6 @@ _tryssl: !ENDIF # NOT EXIST("srclib\openssl") -!IF EXIST("srclib\serf") - -_tryserf: -!IF $(USEMAK) == 1 - cd modules\proxy - $(MAKE) $(MAKEOPT) -f mod_serf.mak CFG="mod_serf - Win32 $(LONG)" RECURSE=0 $(CTARGET) - cd ..\.. -!ELSEIF $(USESLN) == 1 - devenv $(TLP).sln /useenv $(CTARGET) $(LONG) /project mod_serf -!ELSE - @msdev $(TLP).dsw /USEENV /MAKE \ - "mod_serf - Win32 $(LONG)" /NORECURSE $(CTARGET) -!ENDIF - -!ELSE -# NOT EXIST("srclib\serf") - -_tryserf: - @echo ----- - @echo mod_serf will not build unless libserf.dll is built in srclib\serf - @echo For purposes of alpha, libserf release 0.3.0 works, but only with - @echo http://people.apache.org/~wrowe/fixserf-win32-0.3.0.patch - -!ENDIF -# NOT EXIST("srclib\serf") - !IF EXIST("srclib\zlib") _tryzlib: @@ -548,9 +522,6 @@ _build: $(MAKE) $(MAKEOPT) -f mod_proxy_ftp.mak CFG="mod_proxy_ftp - Win32 $(LONG)" RECURSE=0 $(CTARGET) $(MAKE) $(MAKEOPT) -f mod_proxy_http.mak CFG="mod_proxy_http - Win32 $(LONG)" RECURSE=0 $(CTARGET) $(MAKE) $(MAKEOPT) -f mod_proxy_scgi.mak CFG="mod_proxy_scgi - Win32 $(LONG)" RECURSE=0 $(CTARGET) -!IF EXIST("srclib\serf") - $(MAKE) $(MAKEOPT) -f mod_serf.mak CFG="mod_serf - Win32 $(LONG)" RECURSE=0 $(CTARGET) -!ENDIF cd ..\.. cd modules\proxy\balancers $(MAKE) $(MAKEOPT) -f mod_lbmethod_bybusyness.mak CFG="mod_lbmethod_bybusyness - Win32 $(LONG)" RECURSE=0 $(CTARGET) @@ -692,9 +663,6 @@ _copybin: for %d in ($(DBM_LIST) x) do if not %d == x ( \ copy srclib\$(UTILDIR)\dbm\$(LONG)\apr_dbm_%d-1.$(src_dll) "$(inst_dll)" <.y \ ) -!IF EXIST("srclib\serf") - copy srclib\serf\$(LONG)\libserf.$(src_dll) "$(inst_dll)" <.y -!ENDIF copy srclib\pcre\pcre.$(src_dll) "$(inst_dll)" <.y copy modules\aaa\$(LONG)\mod_access_compat.$(src_so) "$(inst_so)" <.y copy modules\aaa\$(LONG)\mod_auth_basic.$(src_so) "$(inst_so)" <.y @@ -811,9 +779,6 @@ _copybin: copy modules\proxy\$(LONG)\mod_proxy_ftp.$(src_so) "$(inst_so)" <.y copy modules\proxy\$(LONG)\mod_proxy_http.$(src_so) "$(inst_so)" <.y copy modules\proxy\$(LONG)\mod_proxy_scgi.$(src_so) "$(inst_so)" <.y -!IF EXIST("srclib\serf") - copy modules\proxy\$(LONG)\mod_serf.$(src_so) "$(inst_so)" <.y -!ENDIF copy modules\proxy\balancers\$(LONG)\mod_lbmethod_bybusyness.$(src_so) "$(inst_so)" <.y copy modules\proxy\balancers\$(LONG)\mod_lbmethod_byrequests.$(src_so) "$(inst_so)" <.y copy modules\proxy\balancers\$(LONG)\mod_lbmethod_bytraffic.$(src_so) "$(inst_so)" <.y @@ -1059,9 +1024,6 @@ BEGIN { srclib\apr-util\xml\expat\lib\expat.h \ srclib\apr\include\*.h \ srclib\apr-util\include\*.h \ -!IF EXIST("srclib\serf") - srclib\serf\*.h \ -!ENDIF include\*.h \ os\win32\os.h \ modules\cache\mod_cache.h \ @@ -1075,7 +1037,6 @@ BEGIN { modules\loggers\mod_log_config.h \ modules\mappers\mod_rewrite.h \ modules\proxy\mod_proxy.h \ - modules\proxy\mod_serf.h \ modules\ssl\mod_ssl.h \ ) do \ @copy %f "$(INSTDIR)\include" < .y > nul @@ -1098,10 +1059,6 @@ BEGIN { copy srclib\expat\win32\$(LONG)\libexpat.lib "$(INSTDIR)\lib" <.y copy srclib\expat\win32\$(LONG)\libexpat.exp "$(INSTDIR)\lib" <.y copy srclib\expat\win32\$(LONG)\libexpat.dll "$(INSTDIR)\bin" <.y -!ENDIF -!IF EXIST("srclib\serf") - copy srclib\serf\$(LONG)\libserf.lib "$(INSTDIR)\lib" <.y - copy srclib\serf\$(LONG)\libserf.exp "$(INSTDIR)\lib" <.y !ENDIF copy $(LONG)\libhttpd.exp "$(INSTDIR)\lib" <.y copy $(LONG)\libhttpd.lib "$(INSTDIR)\lib" <.y diff --git a/NWGNUmakefile b/NWGNUmakefile index 732935bce4..2ae2087f9f 100644 --- a/NWGNUmakefile +++ b/NWGNUmakefile @@ -439,7 +439,6 @@ installdev :: FORCE $(call COPY,$(STDMOD)/loggers/mod_log_config.h, $(INSTALLBASE)/include/) $(call COPY,$(STDMOD)/mappers/mod_rewrite.h, $(INSTALLBASE)/include/) $(call COPY,$(STDMOD)/proxy/mod_proxy.h, $(INSTALLBASE)/include/) - $(call COPY,$(STDMOD)/proxy/mod_serf.h, $(INSTALLBASE)/include/) $(call COPY,$(STDMOD)/session/mod_session.h, $(INSTALLBASE)/include/) $(call COPY,$(STDMOD)/ssl/mod_ssl.h, $(INSTALLBASE)/include/) $(call COPY,$(APR)/*.imp, $(INSTALLBASE)/lib/) diff --git a/STATUS b/STATUS index aaec13adfe..3bf1d5a8bb 100644 --- a/STATUS +++ b/STATUS @@ -80,9 +80,7 @@ RELEASE SHOWSTOPPERS: If anyone disagrees, please comment. - MPM simple (unfinished; buggy) - - mod_serf (which is optimal for async httpd anyways; didn't work - with MPM event last time sf tested it) - + See https://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/STATUS under 'modules docs' for a more comprehensive list of undocumented modules. diff --git a/acinclude.m4 b/acinclude.m4 index 2911fba1aa..b9d3fdf724 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -552,48 +552,6 @@ AC_DEFUN(APACHE_CHECK_OPENSSL,[ fi ]) -dnl -dnl APACHE_CHECK_SERF -dnl -dnl Configure for the detected libserf, giving preference to -dnl "--with-serf=" if it was specified. -dnl -AC_DEFUN([APACHE_CHECK_SERF], [ - AC_CACHE_CHECK([for libserf], [ac_cv_serf], [ - ac_cv_serf=no - serf_prefix=/usr - SERF_LIBS="" - AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX], - [Serf client library]), - [ - if test "$withval" = "yes" ; then - serf_prefix=/usr - else - serf_prefix=$withval - fi - ]) - - if test "$serf_prefix" != "no" ; then - save_cppflags="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0" - AC_CHECK_HEADERS(serf.h,[ - save_ldflags="$LDFLAGS" - LDFLAGS="$LDFLAGS -L$serf_prefix/lib" - AC_CHECK_LIB(serf-0, serf_context_create,[ac_cv_serf="yes"]) - LDFLAGS="$save_ldflags"]) - CPPFLAGS="$save_cppflags" - fi - ]) - - APACHE_SUBST(SERF_LIBS) - if test "$ac_cv_serf" = "yes"; then - AC_DEFINE(HAVE_SERF, 1, [Define if libserf is available]) - APR_SETVAR(SERF_LIBS, [-L$serf_prefix/lib -lserf-0]) - APR_ADDTO(INCLUDES, [-I$serf_prefix/include/serf-0]) - fi -]) - - dnl dnl APACHE_EXPORT_ARGUMENTS dnl Export (via APACHE_SUBST) the various path-related variables that diff --git a/docs/STATUS b/docs/STATUS index c2446f69a1..855aae71b2 100644 --- a/docs/STATUS +++ b/docs/STATUS @@ -57,7 +57,6 @@ To Do List - modules docs - the follwing modules added since 2.2 lack documentation - - mod_serf - mod_watchdog - mod_heartbeat - mod_heartmonitor diff --git a/modules/proxy/NWGNUmakefile b/modules/proxy/NWGNUmakefile index 2e7f877212..fe491c13d4 100644 --- a/modules/proxy/NWGNUmakefile +++ b/modules/proxy/NWGNUmakefile @@ -167,17 +167,6 @@ TARGET_nlm = \ $(OBJDIR)/proxylbm_traf.nlm \ $(EOLIST) -# If WITH_MOD_SERF and SERFSRC have been defined then build the mod_serf module -ifdef WITH_MOD_SERF -ifneq "$(SERFSRC)" "" -ifneq "$(ZLIBSDK)" "" -TARGET_nlm += \ - $(OBJDIR)/serf.nlm \ - $(EOLIST) -endif -endif -endif - # # If there is an LIB target, put it here # diff --git a/modules/proxy/NWGNUserf b/modules/proxy/NWGNUserf deleted file mode 100644 index c9ba6a4fc5..0000000000 --- a/modules/proxy/NWGNUserf +++ /dev/null @@ -1,321 +0,0 @@ -# -# Make sure all needed macro's are defined -# - -OSSLINC = $(OSSLSDK)/outinc_nw_libc -OSSLLIB = $(OSSLSDK)/out_nw_libc -OSSLAPP = $(OSSLSDK)/apps - -# -# Get the 'head' of the build environment if necessary. This includes default -# targets and paths to tools -# - -ifndef EnvironmentDefined -include $(AP_WORK)/build/NWGNUhead.inc -endif - -V_PATH = \ - $(SERFSRC) \ - $(SERFSRC)/buckets \ - $(ZLIBSDK) \ - $(EOLIST) -# -# These directories will be at the beginning of the include list, followed by -# INCDIRS -# -XINCDIRS += \ - $(V_PATH) \ - $(OSSLINC) \ - $(OSSLINC)/openssl \ - $(APR)/include \ - $(APRUTIL)/include \ - $(AP_WORK)/include \ - $(AP_WORK)/modules/http \ - $(AP_WORK)/modules/generators \ - $(AP_WORK)/modules/ssl \ - $(NWOS) \ - $(EOLIST) - -# -# These flags will come after CFLAGS -# -XCFLAGS += \ - -relax_pointers \ - $(EOLIST) - -# -# These defines will come after DEFINES -# -XDEFINES += \ - -DHAVE_SERF_H \ - -DHAVE_OPENSSL \ - $(EOLIST) - -# -# These flags will be added to the link.opt file -# -XLFLAGS += \ - -l $(OSSLLIB) \ - $(EOLIST) - -# -# These values will be appended to the correct variables based on the value of -# RELEASE -# -ifeq "$(RELEASE)" "debug" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "noopt" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -ifeq "$(RELEASE)" "release" -XINCDIRS += \ - $(EOLIST) - -XCFLAGS += \ - $(EOLIST) - -XDEFINES += \ - $(EOLIST) - -XLFLAGS += \ - $(EOLIST) -endif - -# -# These are used by the link target if an NLM is being generated -# This is used by the link 'name' directive to name the nlm. If left blank -# TARGET_nlm (see below) will be used. -# -NLM_NAME = serf - -# -# This is used by the link '-desc ' directive. -# If left blank, NLM_NAME will be used. -# -NLM_DESCRIPTION = Apache $(VERSION_STR) Serf Module - -# -# This is used by the '-threadname' directive. If left blank, -# NLM_NAME Thread will be used. -# -NLM_THREAD_NAME = Serf Module - -# -# If this is specified, it will override VERSION value in -# $(AP_WORK)/build/NWGNUenvironment.inc -# -NLM_VERSION = - -# -# If this is specified, it will override the default of 64K -# -NLM_STACK_SIZE = 8192 - - -# -# If this is specified it will be used by the link '-entry' directive -# -NLM_ENTRY_SYM = - -# -# If this is specified it will be used by the link '-exit' directive -# -NLM_EXIT_SYM = - -# -# If this is specified it will be used by the link '-check' directive -# -NLM_CHECK_SYM = - -# -# If these are specified it will be used by the link '-flags' directive -# -NLM_FLAGS = - -# -# If this is specified it will be linked in with the XDCData option in the def -# file instead of the default of $(NWOS)/apache.xdc. XDCData can be disabled -# by setting APACHE_UNIPROC in the environment -# -XDCDATA = - -# -# If there is an NLM target, put it here -# -TARGET_nlm = \ - $(OBJDIR)/$(NLM_NAME).nlm \ - $(EOLIST) - -# -# If there is an LIB target, put it here -# -TARGET_lib = \ - $(EOLIST) - -# -# These are the OBJ files needed to create the NLM target above. -# Paths must all use the '/' character -# -FILES_nlm_objs = \ - $(OBJDIR)/mod_serf.o \ - $(EOLIST) - -# Build serf from source -FILES_nlm_objs += \ - $(OBJDIR)/context.o \ - $(OBJDIR)/aggregate_buckets.o \ - $(OBJDIR)/allocator.o \ - $(OBJDIR)/barrier_buckets.o \ - $(OBJDIR)/buckets.o \ - $(OBJDIR)/chunk_buckets.o \ - $(OBJDIR)/dechunk_buckets.o \ - $(OBJDIR)/deflate_buckets.o \ - $(OBJDIR)/file_buckets.o \ - $(OBJDIR)/headers_buckets.o \ - $(OBJDIR)/limit_buckets.o \ - $(OBJDIR)/mmap_buckets.o \ - $(OBJDIR)/request_buckets.o \ - $(OBJDIR)/response_buckets.o \ - $(OBJDIR)/simple_buckets.o \ - $(OBJDIR)/socket_buckets.o \ - $(OBJDIR)/ssl_buckets.o \ - $(EOLIST) - -# Build zlib from source -FILES_nlm_objs += \ - $(OBJDIR)/adler32.o \ - $(OBJDIR)/crc32.o \ - $(OBJDIR)/deflate.o \ - $(OBJDIR)/inflate.o \ - $(OBJDIR)/inffast.o \ - $(OBJDIR)/inftrees.o \ - $(OBJDIR)/trees.o \ - $(OBJDIR)/zutil.o \ - $(EOLIST) - -ifeq "$(wildcard $(ZLIBSDK)/infblock.c)" "$(ZLIBSDK)/infblock.c" -FILES_nlm_objs += \ - $(OBJDIR)/infblock.o \ - $(OBJDIR)/infcodes.o \ - $(OBJDIR)/infutil.o \ - $(EOLIST) -endif - -# -# These are the LIB files needed to create the NLM target above. -# These will be added as a library command in the link.opt file. -# -FILES_nlm_libs = \ - $(OSSLLIB)/crypto.lib \ - $(OSSLLIB)/ssl.lib \ - $(PRELUDE) \ - $(EOLIST) - -# -# These are the modules that the above NLM target depends on to load. -# These will be added as a module command in the link.opt file. -# -FILES_nlm_modules = \ - aprlib \ - libc \ - $(EOLIST) - -# -# If the nlm has a msg file, put it's path here -# -FILE_nlm_msg = - -# -# If the nlm has a hlp file put it's path here -# -FILE_nlm_hlp = - -# -# If this is specified, it will override $(NWOS)\copyright.txt. -# -FILE_nlm_copyright = - -# -# Any additional imports go here -# -FILES_nlm_Ximports = \ - @aprlib.imp \ - @httpd.imp \ - @libc.imp \ - GetProcessSwitchCount \ - RunningProcess \ - GetSuperHighResolutionTimer \ - $(EOLIST) - -# Don't link with Winsock if standard sockets are being used -ifndef USE_STDSOCKETS -FILES_nlm_Ximports += @ws2nlm.imp \ - $(EOLIST) -endif - -# -# Any symbols exported to here -# -FILES_nlm_exports = \ - serf_module \ - $(EOLIST) - -# -# These are the OBJ files needed to create the LIB target above. -# Paths must all use the '/' character -# -FILES_lib_objs = \ - $(EOLIST) - -# -# implement targets and dependancies (leave this section alone) -# - -libs :: $(OBJDIR) $(TARGET_lib) - -nlms :: libs $(TARGET_nlm) - -# -# Updated this target to create necessary directories and copy files to the -# correct place. (See $(AP_WORK)/build/NWGNUhead.inc for examples) -# -install :: nlms FORCE - -# -# Any specialized rules here -# - -vpath %.c $(V_PATH) - -# -# Include the 'tail' makefile that has targets that depend on variables defined -# in this makefile -# - -include $(APBUILD)/NWGNUtail.inc - - diff --git a/modules/proxy/config.m4 b/modules/proxy/config.m4 index 53144e8066..8e05c3add0 100644 --- a/modules/proxy/config.m4 +++ b/modules/proxy/config.m4 @@ -55,15 +55,6 @@ APACHE_MODULE(proxy_fdpass, Apache proxy to Unix Daemon Socket module. Requires APACHE_MODULE(proxy_ajp, Apache proxy AJP module. Requires and is enabled by --enable-proxy., $proxy_ajp_objs, , $proxy_mods_enable) APACHE_MODULE(proxy_balancer, Apache proxy BALANCER module. Requires and is enabled by --enable-proxy., $proxy_balancer_objs, , $proxy_mods_enable) -APACHE_MODULE(serf, [Reverse proxy module using Serf], , , no, [ - APACHE_CHECK_SERF - if test "$ac_cv_serf" = "yes" ; then - APR_ADDTO(MOD_SERF_LDADD, [\$(SERF_LIBS)]) - else - enable_serf=no - fi -]) - APACHE_MODULE(proxy_express, mass reverse-proxy module. Requires --enable-proxy., , , $proxy_mods_enable) APR_ADDTO(INCLUDES, [-I\$(top_srcdir)/$modpath_current]) diff --git a/modules/proxy/mod_serf.c b/modules/proxy/mod_serf.c deleted file mode 100644 index 3f899e2887..0000000000 --- a/modules/proxy/mod_serf.c +++ /dev/null @@ -1,1126 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "mod_serf.h" - -#include "httpd.h" -#include "http_core.h" -#include "http_config.h" -#include "http_protocol.h" -#include "http_request.h" -#include "http_log.h" - -#include "serf.h" -#include "apr_uri.h" -#include "apr_strings.h" -#include "apr_version.h" -#include "ap_mpm.h" - -module AP_MODULE_DECLARE_DATA serf_module; -static int mpm_supprts_serf = 0; - -typedef struct { - int on; - int preservehost; - apr_uri_t url; -} serf_config_t; - -typedef struct { - const char *name; - const char *provider; - apr_table_t *params; -} serf_cluster_t; - -typedef struct { - /* name -> serf_cluster_t* */ - apr_hash_t *clusters; -} serf_server_config_t; - -typedef struct { - int rstatus; - int want_ssl; - int done_headers; - int keep_reading; - request_rec *r; - apr_pool_t *serf_pool; - apr_bucket_brigade *tmpbb; - serf_config_t *conf; - serf_ssl_context_t *ssl_ctx; - serf_bucket_alloc_t *bkt_alloc; - serf_bucket_t *body_bkt; -} s_baton_t; - -#if !APR_VERSION_AT_LEAST(1,4,0) -#define apr_time_from_msec(x) (x * 1000) -#endif - -/** - * This works right now because all timers are invoked in the single listener - * thread in the Event MPM -- the same thread that serf callbacks are made - * from, so we don't technically need a mutex yet, but with the Simple MPM, - * invocations are made from worker threads, and we need to figure out locking - */ -static void timed_cleanup_callback(void *baton) -{ - s_baton_t *ctx = baton; - - /* Causes all serf connections to unregister from the event mpm */ - if (ctx->rstatus) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, ctx->rstatus, ctx->r, - "serf: request returned: %d", ctx->rstatus); - ctx->r->status = HTTP_OK; - apr_pool_destroy(ctx->serf_pool); - ap_die(ctx->rstatus, ctx->r); - } - else { - apr_bucket *e; - apr_brigade_cleanup(ctx->tmpbb); - e = apr_bucket_flush_create(ctx->r->connection->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e); - e = apr_bucket_eos_create(ctx->r->connection->bucket_alloc); - APR_BRIGADE_INSERT_TAIL(ctx->tmpbb, e); - - /* TODO: return code? bleh */ - ap_pass_brigade(ctx->r->output_filters, ctx->tmpbb); - - apr_pool_destroy(ctx->serf_pool); - - ap_finalize_request_protocol(ctx->r); - ap_process_request_after_handler(ctx->r); - return; - } -} - -static void closed_connection(serf_connection_t *conn, - void *closed_baton, - apr_status_t why, - apr_pool_t *pool) -{ - s_baton_t *ctx = closed_baton; - - if (why) { - /* justin says that error handling isn't done yet. hah. */ - /* XXXXXX: review */ - ap_log_rerror(APLOG_MARK, APLOG_ERR, why, ctx->r, "Closed Connection Error"); - ctx->rstatus = HTTP_INTERNAL_SERVER_ERROR; - } - - if (mpm_supprts_serf) { - ap_mpm_register_timed_callback(apr_time_from_msec(1), - timed_cleanup_callback, ctx); - } - ctx->keep_reading = 0; -} - -static serf_bucket_t* conn_setup(apr_socket_t *sock, - void *setup_baton, - apr_pool_t *pool) -{ - serf_bucket_t *c; - s_baton_t *ctx = setup_baton; - - c = serf_bucket_socket_create(sock, ctx->bkt_alloc); - if (ctx->want_ssl) { - c = serf_bucket_ssl_decrypt_create(c, ctx->ssl_ctx, ctx->bkt_alloc); - } - - return c; -} - -static int copy_headers_in(void *vbaton, const char *key, const char *value) -{ - serf_bucket_t *hdrs_bkt = (serf_bucket_t *)vbaton; - - /* XXXXX: List of headers not to copy to serf. serf's serf_bucket_headers_setn, - * doesn't actually overwrite a header if we set it once, so we need to ignore anything - * we might want to toggle or combine. - */ - switch (key[0]) { - case 'a': - case 'A': - if (strcasecmp("Accept-Encoding", key) == 0) { - return 0; - } - break; - case 'c': - case 'C': - if (strcasecmp("Connection", key) == 0) { - return 0; - } - break; - case 'h': - case 'H': - if (strcasecmp("Host", key) == 0) { - return 0; - } - break; - case 'k': - case 'K': - if (strcasecmp("Keep-Alive", key) == 0) { - return 0; - } - break; - case 't': - case 'T': - if (strcasecmp("TE", key) == 0) { - return 0; - } - if (strcasecmp("Trailer", key) == 0) { - return 0; - } - break; - case 'u': - case 'U': - if (strcasecmp("Upgrade", key) == 0) { - return 0; - } - break; - default: - break; - } - - serf_bucket_headers_setn(hdrs_bkt, key, value); - return 0; -} - -static int copy_headers_out(void *vbaton, const char *key, const char *value) -{ - s_baton_t *ctx = vbaton; - int done = 0; - - /* XXXXX: Special Treatment required for MANY other headers. fixme.*/ - switch (key[0]) { - case 'c': - case 'C': - if (strcasecmp("Content-Type", key) == 0) { - ap_set_content_type(ctx->r, value); - done = 1; - break; - } - else if (strcasecmp("Connection", key) == 0) { - done = 1; - break; - } - else if (strcasecmp("Content-Encoding", key) == 0) { - done = 1; - break; - } - else if (strcasecmp("Content-Length", key) == 0) { - done = 1; - break; - } - break; - case 't': - case 'T': - if (strcasecmp("Transfer-Encoding", key) == 0) { - done = 1; - break; - } - break; - default: - break; - } - - if (!done) { - apr_table_addn(ctx->r->headers_out, key, value); - } - - return 0; -} - -static serf_bucket_t* accept_response(serf_request_t *request, - serf_bucket_t *stream, - void *acceptor_baton, - apr_pool_t *pool) -{ - serf_bucket_t *c; - serf_bucket_alloc_t *bkt_alloc; - - /* get the per-request bucket allocator */ - bkt_alloc = serf_request_get_alloc(request); - - /* Create a barrier so the response doesn't eat us! */ - c = serf_bucket_barrier_create(stream, bkt_alloc); - - return serf_bucket_response_create(c, bkt_alloc); -} - -static apr_status_t handle_response(serf_request_t *request, - serf_bucket_t *response, - void *vbaton, - apr_pool_t *pool) -{ - apr_status_t rv; - s_baton_t *ctx = vbaton; - const char *data; - apr_size_t len; - serf_status_line sl; - - if (response == NULL) { - ctx->rstatus = HTTP_INTERNAL_SERVER_ERROR; - return APR_EGENERAL; - } - - /* XXXXXXX: Create better error message. */ - rv = serf_bucket_response_status(response, &sl); - if (rv) { - if (APR_STATUS_IS_EAGAIN(rv)) { - return APR_SUCCESS; - } - - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, ctx->r, "serf_bucket_response_status..."); - - ctx->rstatus = HTTP_INTERNAL_SERVER_ERROR; - - if (mpm_supprts_serf) { - ap_mpm_register_timed_callback(apr_time_from_msec(1), - timed_cleanup_callback, ctx); - } - - return rv; - } - - /** - * XXXXX: If I understood serf buckets better, it might be possible to not - * copy all of the data here, and better stream it to the client. - **/ - - do { - apr_brigade_cleanup(ctx->tmpbb); - rv = serf_bucket_read(response, AP_IOBUFSIZE, &data, &len); - - if (SERF_BUCKET_READ_ERROR(rv)) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, ctx->r, "serf_bucket_read(response)"); - return rv; - } - - if (!ctx->done_headers) { - serf_bucket_t *hdrs; - serf_status_line line; - - /* TODO: improve */ - serf_bucket_response_status(response, &line); - ctx->r->status = line.code; - - hdrs = serf_bucket_response_get_headers(response); - serf_bucket_headers_do(hdrs, copy_headers_out, ctx); - ctx->done_headers = 1; - } - - - if (len > 0) { - /* TODO: make APR bucket <-> serf bucket stuff more magical. */ - apr_brigade_write(ctx->tmpbb, NULL, NULL, data, len); - } - - if (APR_STATUS_IS_EOF(rv)) { - ctx->keep_reading = 0; - - ctx->rstatus = ap_pass_brigade(ctx->r->output_filters, ctx->tmpbb); - - if (mpm_supprts_serf) { - ap_mpm_register_timed_callback(apr_time_from_msec(1), - timed_cleanup_callback, ctx); - } - return APR_EOF; - } - - ctx->rstatus = ap_pass_brigade(ctx->r->output_filters, ctx->tmpbb); - - /* XXXX: Should we send a flush now? */ - if (APR_STATUS_IS_EAGAIN(rv)) { - return APR_SUCCESS; - } - - } while (1); -} - - -static apr_status_t setup_request(serf_request_t *request, - void *vbaton, - serf_bucket_t **req_bkt, - serf_response_acceptor_t *acceptor, - void **acceptor_baton, - serf_response_handler_t *handler, - void **handler_baton, - apr_pool_t *pool) -{ - s_baton_t *ctx = vbaton; - serf_bucket_t *hdrs_bkt; - - *req_bkt = serf_bucket_request_create(ctx->r->method, ctx->r->unparsed_uri, - ctx->body_bkt, - serf_request_get_alloc(request)); - - hdrs_bkt = serf_bucket_request_get_headers(*req_bkt); - - apr_table_do(copy_headers_in, hdrs_bkt, ctx->r->headers_in, NULL); - - if (ctx->conf->preservehost) { - serf_bucket_headers_setn(hdrs_bkt, "Host", - apr_table_get(ctx->r->headers_in, "Host")); - } - else { - serf_bucket_headers_setn(hdrs_bkt, "Host", ctx->conf->url.hostname); - } - - serf_bucket_headers_setn(hdrs_bkt, "Accept-Encoding", "gzip"); - - if (ctx->want_ssl) { - if (ctx->ssl_ctx == NULL) { - *req_bkt = serf_bucket_ssl_encrypt_create(*req_bkt, NULL, - ctx->bkt_alloc); - ctx->ssl_ctx = serf_bucket_ssl_encrypt_context_get(*req_bkt); - } - else { - *req_bkt = serf_bucket_ssl_encrypt_create(*req_bkt, ctx->ssl_ctx, - ctx->bkt_alloc); - } - } - - *acceptor = accept_response; - *acceptor_baton = ctx; - *handler = handle_response; - *handler_baton = ctx; - - return APR_SUCCESS; -} - -/* TOOD: rewrite drive_serf to make it async */ -static int drive_serf(request_rec *r, serf_config_t *conf) -{ - apr_status_t rv = 0; - apr_pool_t *pool; - apr_sockaddr_t *address; - s_baton_t *baton = apr_palloc(r->pool, sizeof(s_baton_t)); - /* XXXXX: make persistent/per-process or something.*/ - serf_context_t *serfme; - serf_connection_t *conn; - serf_server_config_t *ctx = - (serf_server_config_t *)ap_get_module_config(r->server->module_config, - &serf_module); - - /* Allocate everything out of a subpool, with a shorter lifetime than - * the main request, so that we can cleanup safely and remove our events - * from the main serf context in the async mpm mode. - */ - apr_pool_create(&pool, r->pool); - if (strcmp(conf->url.scheme, "cluster") == 0) { - int rc; - ap_serf_cluster_provider_t *cp; - serf_cluster_t *cluster; - apr_array_header_t *servers = NULL; - apr_uint32_t pick = 0; - ap_serf_server_t *choice; - - /* TODO: could this be optimized in post-config to pre-setup the - * pointers to the right cluster inside the conf structure? - */ - cluster = apr_hash_get(ctx->clusters, - conf->url.hostname, - APR_HASH_KEY_STRING); - if (!cluster) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "SerfCluster: unable to find cluster %s", conf->url.hostname); - return HTTP_INTERNAL_SERVER_ERROR; - } - - cp = ap_lookup_provider(AP_SERF_CLUSTER_PROVIDER, cluster->provider, "0"); - - if (cp == NULL) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "SerfCluster: unable to find provider %s", cluster->provider); - return HTTP_INTERNAL_SERVER_ERROR; - } - - if (cp->list_servers == NULL) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "SerfCluster: %s is missing list servers provider.", cluster->provider); - return HTTP_INTERNAL_SERVER_ERROR; - } - - rc = cp->list_servers(cp->baton, - r, - cluster->params, - &servers); - - if (rc != OK) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, - "SerfCluster: %s list servers returned failure", cluster->provider); - return HTTP_INTERNAL_SERVER_ERROR; - } - - if (servers == NULL || apr_is_empty_array(servers)) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r, - "SerfCluster: %s failed to provide a list of servers", cluster->provider); - return HTTP_INTERNAL_SERVER_ERROR; - } - - /* TOOD: restructure try all servers in the array !! */ - pick = ap_random_pick(0, servers->nelts-1); - choice = APR_ARRAY_IDX(servers, pick, ap_serf_server_t *); - - rv = apr_sockaddr_info_get(&address, choice->ip, - APR_UNSPEC, choice->port, 0, - pool); - } - else { - /* XXXXX: cache dns? */ - rv = apr_sockaddr_info_get(&address, conf->url.hostname, - APR_UNSPEC, conf->url.port, 0, - pool); - } - - if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "Unable to resolve: %s", conf->url.hostname); - return HTTP_INTERNAL_SERVER_ERROR; - } - - if (mpm_supprts_serf) { - serfme = ap_lookup_provider("mpm_serf", "instance", "0"); - if (!serfme) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "mpm lied to us about supporting serf."); - return HTTP_INTERNAL_SERVER_ERROR; - } - } - else { - serfme = serf_context_create(pool); - } - - baton->r = r; - baton->conf = conf; - baton->serf_pool = pool; - baton->bkt_alloc = serf_bucket_allocator_create(pool, NULL, NULL); - baton->body_bkt = NULL; - baton->ssl_ctx = NULL; - baton->rstatus = OK; - - baton->tmpbb = apr_brigade_create(r->pool, r->connection->bucket_alloc); - baton->done_headers = 0; - baton->keep_reading = 1; - - if (strcasecmp(conf->url.scheme, "https") == 0) { - baton->want_ssl = 1; - } - else { - baton->want_ssl = 0; - } - - rv = ap_setup_client_block(baton->r, REQUEST_CHUNKED_DECHUNK); - if (rv) { - return rv; - } - - /* TODO: create custom serf bucket, which does async request body reads */ - if (ap_should_client_block(r)) { - apr_size_t len; - apr_off_t flen = 0; - char buf[AP_IOBUFSIZE]; - apr_file_t *fp; - - rv = apr_file_mktemp(&fp, "mod_serf_buffer.XXXXXX", 0, pool); - if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "mod_serf: Unable to create temp request body buffer file."); - return HTTP_INTERNAL_SERVER_ERROR; - } - - do { - len = sizeof(buf); - rv = ap_get_client_block(baton->r, buf, len); - if (rv > 0) { - rv = apr_file_write_full(fp, buf, rv, NULL); - if (rv) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "mod_serf: failed to read request body"); - return HTTP_INTERNAL_SERVER_ERROR; - } - } - } while(rv > 0); - - if (rv < 0) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "mod_serf: failed to read request body"); - return HTTP_INTERNAL_SERVER_ERROR; - } - - apr_file_seek(fp, APR_SET, &flen); - baton->body_bkt = serf_bucket_file_create(fp, baton->bkt_alloc); - } - - conn = serf_connection_create(serfme, address, - conn_setup, baton, - closed_connection, baton, - pool); - - /* XXX: Is it correct that we don't use the returned serf_request_t? */ - serf_connection_request_create(conn, setup_request, baton); - - if (mpm_supprts_serf) { - return SUSPENDED; - } - else { - do { - rv = serf_context_run(serfme, SERF_DURATION_FOREVER, pool); - - /* XXXX: Handle timeouts */ - if (APR_STATUS_IS_TIMEUP(rv)) { - continue; - } - - if (rv != APR_SUCCESS) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, "serf_context_run() for %pI", address); - return HTTP_INTERNAL_SERVER_ERROR; - } - - serf_debug__closed_conn(baton->bkt_alloc); - } while (baton->keep_reading); - - return baton->rstatus; - } -} - -static int serf_handler(request_rec *r) -{ - serf_config_t *conf = ap_get_module_config(r->per_dir_config, - &serf_module); - - if (conf->on == 0) { - return DECLINED; - } - - return drive_serf(r, conf); -} - -static int is_true(const char *w) -{ - if (strcasecmp(w, "on") == 0 || strcmp(w, "1") == 0 || - strcasecmp(w, "true") == 0) - { - return 1; - } - - return 0; -} -static const char *add_pass(cmd_parms *cmd, void *vconf, - int argc, char *const argv[]) -{ - int i; - apr_status_t rv; - serf_config_t *conf = (serf_config_t *) vconf; - - if (argc < 1) { - return "SerfPass must have at least a URI."; - } - - rv = apr_uri_parse(cmd->pool, argv[0], &conf->url); - - if (rv != APR_SUCCESS) { - return "mod_serf: Unable to parse SerfPass url."; - } - - if (!conf->url.scheme) { - return "mod_serf: Need scheme part in url."; - } - - /* XXXX: These are bugs in apr_uri_parse. Fixme. */ - if (!conf->url.port) { - conf->url.port = apr_uri_port_of_scheme(conf->url.scheme); - } - - if (!conf->url.path) { - conf->url.path = "/"; - } - - for (i = 1; i < argc; i++) { - const char *p = argv[i]; - const char *x = ap_strchr_c(p, '='); - - if (x) { - if (strncmp(p, "preservehost", x-p) == 0) { - conf->preservehost = is_true(x+1); - } - } - } - - conf->on = 1; - - return NULL; -} - -/* SerfCluster ... */ - -static const char *add_cluster(cmd_parms *cmd, void *d, - int argc, char *const argv[]) -{ - const char *rv; - ap_serf_cluster_provider_t *backend; - int i; - serf_cluster_t *cluster = NULL; - serf_server_config_t *ctx = - (serf_server_config_t *)ap_get_module_config(cmd->server->module_config, - &serf_module); - - const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); - - if (err != NULL) { - return err; - } - - if (argc < 2) { - return "SerfCluster must have at least a name and provider."; - } - - cluster = apr_palloc(cmd->pool, sizeof(serf_cluster_t)); - cluster->name = apr_pstrdup(cmd->pool, argv[0]); - cluster->provider = apr_pstrdup(cmd->pool, argv[1]); - cluster->params = apr_table_make(cmd->pool, 6); - - backend = ap_lookup_provider(AP_SERF_CLUSTER_PROVIDER, cluster->provider, "0"); - - if (backend == NULL) { - return apr_psprintf(cmd->pool, "SerfCluster: unable to find " - "provider '%s'", cluster->provider); - } - - for (i = 2; i < argc; i++) { - const char *p = argv[i]; - const char *x = ap_strchr_c(p, '='); - - if (x && strlen(p) > 1) { - apr_table_addn(cluster->params, - apr_pstrndup(cmd->pool, p, x-p), - x+1); - } - else { - apr_table_addn(cluster->params, - apr_pstrdup(cmd->pool, p), - ""); - } - } - - if (backend->check_config == NULL) { - return apr_psprintf(cmd->pool, "SerfCluster: Provider '%s' failed to " - "provider a configuration checker", - cluster->provider); - } - - rv = backend->check_config(backend->baton, cmd, cluster->params); - - if (rv) { - return rv; - } - - apr_hash_set(ctx->clusters, cluster->name, APR_HASH_KEY_STRING, cluster); - - return NULL; -} - -static void *create_dir_config(apr_pool_t *p, char *dummy) -{ - serf_config_t *new = (serf_config_t *) apr_pcalloc(p, sizeof(serf_config_t)); - new->on = 0; - new->preservehost = 1; - return new; -} - -static void *create_server_config(apr_pool_t *p, server_rec *s) -{ - serf_server_config_t *ctx = - (serf_server_config_t *) apr_pcalloc(p, sizeof(serf_server_config_t)); - - ctx->clusters = apr_hash_make(p); - - return ctx; -} - -static void * merge_server_config(apr_pool_t *p, void *basev, void *overridesv) -{ - serf_server_config_t *ctx = apr_pcalloc(p, sizeof(serf_server_config_t)); - serf_server_config_t *base = (serf_server_config_t *) basev; - serf_server_config_t *overrides = (serf_server_config_t *) overridesv; - - ctx->clusters = apr_hash_overlay(p, base->clusters, overrides->clusters); - return ctx; -} - -static const command_rec serf_cmds[] = -{ - AP_INIT_TAKE_ARGV("SerfCluster", add_cluster, NULL, RSRC_CONF, - "Configure a cluster backend"), - AP_INIT_TAKE_ARGV("SerfPass", add_pass, NULL, OR_INDEXES, - "URL to reverse proxy to"), - {NULL} -}; - -typedef struct hb_table_baton_t { - apr_pool_t *p; - const char *msg; -} hb_table_baton_t; - -static int hb_table_check(void *rec, const char *key, const char *value) -{ - hb_table_baton_t *b = (hb_table_baton_t*)rec; - if (strcmp(key, "path") != 0) { - b->msg = apr_psprintf(b->p, - "SerfCluster Heartbeat Invalid parameter '%s'", - key); - return 1; - } - - return 0; -} - -static const char* hb_config_check(void *baton, - cmd_parms *cmd, - apr_table_t *params) -{ - hb_table_baton_t b; - - if (apr_is_empty_table(params)) { - return "SerfCluster Heartbeat requires a path to the heartbat information."; - } - - b.p = cmd->pool; - b.msg = NULL; - - apr_table_do(hb_table_check, &b, params, NULL); - - if (b.msg) { - return b.msg; - } - - return NULL; -} - -typedef struct hb_server_t { - const char *ip; - int busy; - int ready; - int seen; - unsigned int port; -} hb_server_t; - -static void -argstr_to_table(apr_pool_t *p, char *str, apr_table_t *parms) -{ - char *key; - char *value; - char *strtok_state; - - key = apr_strtok(str, "&", &strtok_state); - while (key) { - value = strchr(key, '='); - if (value) { - *value = '\0'; /* Split the string in two */ - value++; /* Skip passed the = */ - } - else { - value = "1"; - } - ap_unescape_url(key); - ap_unescape_url(value); - apr_table_set(parms, key, value); - key = apr_strtok(NULL, "&", &strtok_state); - } -} - -static apr_status_t read_heartbeats(const char *path, - apr_array_header_t *servers, - apr_pool_t *pool) -{ - apr_finfo_t fi; - apr_status_t rv; - apr_file_t *fp; - - if (!path) { - return APR_SUCCESS; - } - - rv = apr_file_open(&fp, path, APR_READ|APR_BINARY|APR_BUFFERED, - APR_OS_DEFAULT, pool); - - if (rv) { - return rv; - } - - rv = apr_file_info_get(&fi, APR_FINFO_SIZE, fp); - - if (rv) { - return rv; - } - - { - char *t; - int lineno = 0; - apr_table_t *hbt = apr_table_make(pool, 10); - char buf[4096]; - - while (apr_file_gets(buf, sizeof(buf), fp) == APR_SUCCESS) { - hb_server_t *server; - const char *ip; - lineno++; - - /* comment */ - if (buf[0] == '#') { - continue; - } - - - /* line format: \n */ - t = strchr(buf, ' '); - if (!t) { - continue; - } - - ip = apr_pstrndup(pool, buf, t - buf); - t++; - server = apr_pcalloc(pool, sizeof(hb_server_t)); - server->ip = ip; - server->port = 80; - server->seen = -1; - apr_table_clear(hbt); - - argstr_to_table(pool, apr_pstrdup(pool, t), hbt); - - if (apr_table_get(hbt, "busy")) { - server->busy = atoi(apr_table_get(hbt, "busy")); - } - - if (apr_table_get(hbt, "ready")) { - server->ready = atoi(apr_table_get(hbt, "ready")); - } - - if (apr_table_get(hbt, "lastseen")) { - server->seen = atoi(apr_table_get(hbt, "lastseen")); - } - - if (apr_table_get(hbt, "port")) { - server->port = atoi(apr_table_get(hbt, "port")); - } - - if (server->busy == 0 && server->ready != 0) { - /* Server has zero threads active, but lots of them ready, - * it likely just started up, so lets /4 the number ready, - * to prevent us from completely flooding it with all new - * requests. - */ - server->ready = server->ready / 4; - } - - APR_ARRAY_PUSH(servers, hb_server_t *) = server; - } - } - - return APR_SUCCESS; -} - -static int hb_server_sort(const void *a_, const void *b_) -{ - hb_server_t *a = (hb_server_t*)a_; - hb_server_t *b = (hb_server_t*)b_; - if (a->ready == b->ready) { - return 0; - } - else if (a->ready > b->ready) { - return -1; - } - else { - return 1; - } -} - -static int hb_list_servers(void *baton, - request_rec *r, - apr_table_t *params, - apr_array_header_t **out_servers) -{ - int i; - hb_server_t *hbs; - apr_status_t rv; - apr_pool_t *tpool; - apr_array_header_t *tmpservers; - apr_array_header_t *servers; - const char *path = apr_table_get(params, "path"); - - apr_pool_create(&tpool, r->pool); - - path = ap_server_root_relative(tpool, path); - - tmpservers = apr_array_make(tpool, 32, sizeof(hb_server_t *)); - rv = read_heartbeats(path, tmpservers, tpool); - - if (rv) { - ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, - "SerfCluster: Heartbeat unable to read '%s'", path); - apr_pool_destroy(tpool); - return HTTP_INTERNAL_SERVER_ERROR; - } - - qsort(tmpservers->elts, tmpservers->nelts, sizeof(hb_server_t *), - hb_server_sort); - - servers = apr_array_make(r->pool, tmpservers->nelts, sizeof(ap_serf_server_t *)); - for (i = 0; - i < tmpservers->nelts; - i++) - { - ap_serf_server_t *x; - - hbs = APR_ARRAY_IDX(tmpservers, i, hb_server_t *); - if (hbs->ready > 0) { - x = apr_palloc(r->pool, sizeof(ap_serf_server_t)); - x->ip = apr_pstrdup(r->pool, hbs->ip); - x->port = hbs->port; - APR_ARRAY_PUSH(servers, ap_serf_server_t *) = x; - } - } - - *out_servers = servers; - apr_pool_destroy(tpool); - return OK; -} - -static const ap_serf_cluster_provider_t builtin_heartbeat = -{ - "heartbeat", - NULL, - &hb_config_check, - &hb_list_servers, - NULL, - NULL -}; - -static int static_table_check(void *rec, const char *key, const char *value) -{ - hb_table_baton_t *b = (hb_table_baton_t*)rec; - if (strcmp(key, "hosts") != 0 && - strcmp(key, "order") != 0) { - b->msg = apr_psprintf(b->p, - "SerfCluster Static Invalid parameter '%s'", - key); - return 1; - } - - return 0; -} - -static const char* static_config_check(void *baton, - cmd_parms *cmd, - apr_table_t *params) -{ - hb_table_baton_t b; - - if (apr_is_empty_table(params)) { - return "SerfCluster Static requires at least a host list."; - } - - b.p = cmd->pool; - b.msg = NULL; - - apr_table_do(static_table_check, &b, params, NULL); - - if (b.msg) { - return b.msg; - } - - if (apr_table_get(params, "hosts") == NULL) { - return "SerfCluster Static requires at least a hosts parameter"; - } - return NULL; -} - -static int static_list_servers(void *baton, - request_rec *r, - apr_table_t *params, - apr_array_header_t **out_servers) -{ - apr_status_t rv; - char *ip; - char *strtok_state; - apr_array_header_t *servers; - const char *hosts = apr_table_get(params, "hosts"); - const char *order = apr_table_get(params, "order"); - - servers = apr_array_make(r->pool, 10, sizeof(ap_serf_server_t *)); - - ip = apr_strtok(apr_pstrdup(r->pool, hosts), ",", &strtok_state); - while (ip) { - char *host_str; - char *scope_id; - apr_port_t port = 0; - - rv = apr_parse_addr_port(&host_str, &scope_id, &port, ip, r->pool); - if (!rv) { - ap_serf_server_t *s = apr_palloc(r->pool, sizeof(ap_serf_server_t)); - s->ip = host_str; - s->port = port ? port : 80; - APR_ARRAY_PUSH(servers, ap_serf_server_t *) = s; - } - ip = apr_strtok(NULL, ",", &strtok_state); - } - - if (strcmp(order, "random") == 0) { - /* TODO: support order=random */ - } - - *out_servers = servers; - - return OK; -} - -static const ap_serf_cluster_provider_t builtin_static = -{ - "static", - NULL, - &static_config_check, - &static_list_servers, - NULL, - NULL -}; - -static int serf_post_config(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) -{ - apr_status_t rv; - rv = ap_mpm_query(AP_MPMQ_HAS_SERF, &mpm_supprts_serf); - - if (rv != APR_SUCCESS) { - mpm_supprts_serf = 0; - } - - return OK; -} - -static void register_hooks(apr_pool_t *p) -{ - ap_register_provider(p, AP_SERF_CLUSTER_PROVIDER, - "heartbeat", "0", &builtin_heartbeat); - - ap_register_provider(p, AP_SERF_CLUSTER_PROVIDER, - "static", "0", &builtin_static); - - ap_hook_post_config(serf_post_config, NULL, NULL, APR_HOOK_MIDDLE); - - ap_hook_handler(serf_handler, NULL, NULL, APR_HOOK_FIRST); -} - -AP_DECLARE_MODULE(serf) = -{ - STANDARD20_MODULE_STUFF, - create_dir_config, - NULL, - create_server_config, - merge_server_config, - serf_cmds, - register_hooks -}; diff --git a/modules/proxy/mod_serf.dsp b/modules/proxy/mod_serf.dsp deleted file mode 100644 index 4301c70d94..0000000000 --- a/modules/proxy/mod_serf.dsp +++ /dev/null @@ -1,123 +0,0 @@ -# Microsoft Developer Studio Project File - Name="mod_serf" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=mod_serf - Win32 Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "mod_serf.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "mod_serf.mak" CFG="mod_serf - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "mod_serf - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "mod_serf - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "mod_serf - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MD /W3 /O2 /Oy- /Zi /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /I "../../srclib/serf" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Release\mod_serf_src" /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "NDEBUG" -# ADD RSC /l 0x409 /fo"Release/mod_serf.res" /i "../../include" /i "../../srclib/apr/include" /d "NDEBUG" /d BIN_NAME="mod_serf.so" /d LONG_NAME="serf_module for Apache" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /out:".\Release\mod_serf.so" /base:@..\..\os\win32\BaseAddr.ref,mod_serf.so -# ADD LINK32 libserf.lib kernel32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Release\mod_serf.so" /libpath:..\..\srclib\serf\Release /base:@..\..\os\win32\BaseAddr.ref,mod_serf.so /opt:ref -# Begin Special Build Tool -TargetPath=.\Release\mod_serf.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ELSEIF "$(CFG)" == "mod_serf - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W3 /EHsc /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c -# ADD CPP /nologo /MDd /W3 /EHsc /Zi /Od /I "../../include" /I "../../srclib/apr/include" /I "../../srclib/apr-util/include" /I "../../srclib/serf" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /Fd"Debug\mod_serf_src" /FD /c -# ADD BASE MTL /nologo /D "_DEBUG" /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x809 /d "_DEBUG" -# ADD RSC /l 0x409 /fo"Debug/mod_serf.res" /i "../../include" /i "../../srclib/apr/include" /d "_DEBUG" /d BIN_NAME="mod_serf.so" /d LONG_NAME="serf_module for Apache" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_serf.so" /base:@..\..\os\win32\BaseAddr.ref,mod_serf.so -# ADD LINK32 libserf.lib kernel32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /incremental:no /debug /out:".\Debug\mod_serf.so" /libpath:..\..\srclib\serf\Debug /base:@..\..\os\win32\BaseAddr.ref,mod_serf.so -# Begin Special Build Tool -TargetPath=.\Debug\mod_serf.so -SOURCE="$(InputPath)" -PostBuild_Desc=Embed .manifest -PostBuild_Cmds=if exist $(TargetPath).manifest mt.exe -manifest $(TargetPath).manifest -outputresource:$(TargetPath);2 -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "mod_serf - Win32 Release" -# Name "mod_serf - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90" -# Begin Source File - -SOURCE=.\mod_serf.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter ".h" -# Begin Source File - -SOURCE=.\mod_proxy.h -# End Source File -# End Group -# Begin Source File - -SOURCE=..\..\build\win32\httpd.rc -# End Source File -# End Target -# End Project diff --git a/modules/proxy/mod_serf.h b/modules/proxy/mod_serf.h deleted file mode 100644 index 39fb541b30..0000000000 --- a/modules/proxy/mod_serf.h +++ /dev/null @@ -1,109 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * @file mod_serf.h - * @brief Serf Interfaces - * - */ - -#include "httpd.h" -#include "http_config.h" -#if !defined(WIN32) && !defined(NETWARE) -#include "ap_config_auto.h" -#endif -#ifdef HAVE_SERF -#include "serf.h" -#endif - -#include "ap_provider.h" - -#ifndef _MOD_SERF_H_ -#define _MOD_SERF_H_ -/** - * @addtogroup Serf_cluster_provider - * @{ - */ -#define AP_SERF_CLUSTER_PROVIDER "serf_cluster" -typedef struct ap_serf_server_t ap_serf_server_t; -struct ap_serf_server_t { - /* TOOD: consider using apr_sockaddr_t, except they suck. */ - const char *ip; - apr_port_t port; -}; - -typedef struct ap_serf_cluster_provider_t ap_serf_cluster_provider_t; -struct ap_serf_cluster_provider_t { - /** - * Human readable name of this provider, used in configuration. - */ - const char *name; - /** - * Baton passed to all methods in this provider. - * - * This field may be NULL. - */ - void *baton; - /** - * Check that the key/value pairs used to configure the - * cluster are valid. - * - * Return non-NULL on failure with an error message, like standard httpd - * configuration directives. - * - * This field must be set. - */ - const char* (*check_config)(void *baton, - cmd_parms *cmd, - apr_table_t *params); - /** - * Provide an ordered array of ap_serf_server_t in the order that - * mod_serf should attempt to use them. If a server on the list - * is known to be not responding, it may be skipped. If mod_serf is - * unable to contact any of the servers, a 502 will be returned to the - * client. - * - * Returns OK on sucess, all other return codes will result in a 500. - * - * This field must be set. - */ - int (*list_servers)(void *baton, - request_rec *r, - apr_table_t *params, - apr_array_header_t **servers); - /** - * If a request was successfully fulfilled by this address, feedback will - * be given to the provider, so it may make better recommendations. - * - * This field may be NULL. - */ - void (*server_success)(void *baton, request_rec *r, apr_table_t *params, - ap_serf_server_t* server); - /** - * If a request failed to be fulfilled by this address, feedback will - * be given to the provider, so it may make better recommendations. - * - * This field may be NULL. - */ - void (*server_failure)(void *baton, request_rec *r, apr_table_t *params, - ap_serf_server_t* server); - -}; -/** @} */ - -#endif /* _MOD_SERF_H_ */ - diff --git a/os/win32/BaseAddr.ref b/os/win32/BaseAddr.ref index c51f4ae7a7..9d939148cb 100644 --- a/os/win32/BaseAddr.ref +++ b/os/win32/BaseAddr.ref @@ -107,13 +107,12 @@ mod_heartbeat.so 0x6F7F0000 0x00010000 mod_heartmonitor.so 0x6F7E0000 0x00010000 mod_watchdog.so 0x6F7D0000 0x00010000 mod_proxy_scgi.so 0x6F7C0000 0x00010000 -mod_serf.so 0x6F7B0000 0x00010000 -mod_reqtimeout.so 0x6F7A0000 0x00010000 -mod_reflector.so 0x6F790000 0x00010000 -mod_slotmem_plain.so 0x6F780000 0x00010000 -mod_slotmem_shm.so 0x6F770000 0x00010000 -mod_authn_socache.so 0x6F760000 0x00010000 -mod_proxy_express.so 0x6F750000 0x00010000 -mod_log_debug.so 0x6F740000 0x00010000 -mod_proxy_html.so 0x6F730000 0x00010000 -mod_xml2enc.so 0x6F720000 0x00010000 \ No newline at end of file +mod_reqtimeout.so 0x6F7B0000 0x00010000 +mod_reflector.so 0x6F7A0000 0x00010000 +mod_slotmem_plain.so 0x6F790000 0x00010000 +mod_slotmem_shm.so 0x6F780000 0x00010000 +mod_authn_socache.so 0x6F770000 0x00010000 +mod_proxy_express.so 0x6F760000 0x00010000 +mod_log_debug.so 0x6F750000 0x00010000 +mod_proxy_html.so 0x6F740000 0x00010000 +mod_xml2enc.so 0x6F730000 0x00010000