httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r479647 - in /httpd/httpd/branches/2.2.x: ./ modules/proxy/
Date Mon, 27 Nov 2006 15:00:58 GMT
Author: mturk
Date: Mon Nov 27 07:00:56 2006
New Revision: 479647

URL: http://svn.apache.org/viewvc?view=rev&rev=479647
Log:
Backport support for ping/pong.

Added:
    httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c   (with props)
Modified:
    httpd/httpd/branches/2.2.x/CHANGES
    httpd/httpd/branches/2.2.x/STATUS
    httpd/httpd/branches/2.2.x/modules/proxy/NWGNUproxyajp
    httpd/httpd/branches/2.2.x/modules/proxy/ajp.h
    httpd/httpd/branches/2.2.x/modules/proxy/config.m4
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.c
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c
    httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.dsp

Modified: httpd/httpd/branches/2.2.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/CHANGES?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.2.x/CHANGES [utf-8] Mon Nov 27 07:00:56 2006
@@ -17,6 +17,12 @@
      parameter in the URL correctly. PR 40400.
      [Ruediger Pluem, Tomokazu Harada <harada sysrdc.ns-sol.co.jp>]
 
+  *) mod_proxy_ajp: Added cping/cpong support for the AJP protocol.
+     A new worker directive ping=timeout will cause CPING packet
+     to be send expecting CPONG packet within defined timeout.  
+     In case the backend is too busy this will fail instead
+     sending the full header.  [Mladen Turk]
+
   *) mod_disk_cache: Make sure that only positive integers are accepted
      for the CacheMaxFileSize and CacheMinFileSize parameters in the
      config file. PR39380 [Niklas Edmundsson <nikke acc.umu.se>]

Modified: httpd/httpd/branches/2.2.x/STATUS
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/STATUS?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/STATUS (original)
+++ httpd/httpd/branches/2.2.x/STATUS Mon Nov 27 07:00:56 2006
@@ -156,18 +156,6 @@
         deflate output filter.
       +1: rpluem, niq
 
-    * mod_proxy: Add in support for ping/pong (heartbeat test) for
-      the Proxy. Implement cping/cpong for AJP.
-      Trunk version of patch:
-        http://svn.apache.org/viewvc?view=rev&revision=425454
-      2.2.x version of patch:
-        http://people.apache.org/~jim/patches/pingpong2.txt
-        http://svn.apache.org/viewvc?view=rev&revision=425559
-        http://svn.apache.org/viewvc?view=rev&revision=425690
-        http://svn.apache.org/viewvc?view=rev&revision=452549
-        (Note: your patch should auto-createmodules/proxy/ajp_utils.c)
-      +1: jim, rpluem, mturk
-
     * Allow htcacheclean and httxt2dbm to link apr/apr-util statically
       like the older support programs.
       Trunk version of patch:

Modified: httpd/httpd/branches/2.2.x/modules/proxy/NWGNUproxyajp
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/NWGNUproxyajp?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/NWGNUproxyajp (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/NWGNUproxyajp Mon Nov 27 07:00:56 2006
@@ -171,6 +171,7 @@
 	$(OBJDIR)/ajp_header.o \
 	$(OBJDIR)/ajp_msg.o \
 	$(OBJDIR)/ajp_link.o \
+	$(OBJDIR)/ajp_utils.o \
 	$(OBJDIR)/libprews.o \
 	$(EOLIST)
 

Modified: httpd/httpd/branches/2.2.x/modules/proxy/ajp.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/ajp.h?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/ajp.h (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/ajp.h Mon Nov 27 07:00:56 2006
@@ -471,6 +471,17 @@
 apr_status_t  ajp_parse_data(request_rec  *r, ajp_msg_t *msg,
                              apr_uint16_t *len, char **ptr);
 
+
+/** 
+ * Handle the CPING/CPONG messages
+ * @param sock      backend socket
+ * @param r         current request
+ * @param timeout   time window for receiving cpong reply
+ * @return          APR_SUCCESS or error
+ */
+apr_status_t ajp_handle_cping_cpong(apr_socket_t *sock,
+                                    request_rec *r,
+                                    apr_interval_time_t timeout);
 /** @} */
 
 #endif /* AJP_H */

Added: httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c?view=auto&rev=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c (added)
+++ httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c Mon Nov 27 07:00:56 2006
@@ -0,0 +1,105 @@
+/* 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 "ajp.h"
+
+/*
+ * Handle the CPING/CPONG
+ */
+apr_status_t ajp_handle_cping_cpong(apr_socket_t *sock,
+                                    request_rec *r,
+                                    apr_interval_time_t timeout)
+{
+    ajp_msg_t *msg;
+    apr_status_t rc, rv;
+    apr_interval_time_t org;
+    apr_byte_t result;
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "Into ajp_handle_cping_cpong");
+
+    rc = ajp_msg_create(r->pool, &msg);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: ajp_msg_create failed");
+        return rc;
+    }
+
+    rc = ajp_msg_serialize_cping(msg);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: ajp_marshal_into_msgb failed");
+        return rc;
+    }
+
+    rc = ajp_ilink_send(sock, msg);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: ajp_ilink_send failed");
+        return rc;
+    }
+
+    rc = apr_socket_timeout_get(sock, &org);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: apr_socket_timeout_get failed");
+        return rc;
+    }
+
+    /* Set CPING/CPONG response timeout */
+    rc = apr_socket_timeout_set(sock, timeout);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: apr_socket_timeout_set failed");
+        return rc;
+    }
+    ajp_msg_reuse(msg);
+
+    /* Read CPONG reply */
+    rv = ajp_ilink_receive(sock, msg);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: ajp_ilink_receive failed");
+        goto cleanup;
+    }
+
+    rv = ajp_msg_get_uint8(msg, &result);
+    if (rv != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: invalid CPONG message");
+        goto cleanup;
+    }
+    if (result != CMD_AJP13_CPONG) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: awaited CPONG, received %d ",
+               result);
+        rv = APR_EGENERAL;
+        goto cleanup;
+    }
+
+cleanup:
+    /* Restore original socket timeout */
+    rc = apr_socket_timeout_set(sock, org);
+    if (rc != APR_SUCCESS) {
+        ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+               "ajp_handle_cping_cpong: apr_socket_timeout_set failed");
+        return rc;
+    }
+
+    ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
+                         "ajp_handle_cping_cpong: Done");
+    return rv;
+}

Propchange: httpd/httpd/branches/2.2.x/modules/proxy/ajp_utils.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: httpd/httpd/branches/2.2.x/modules/proxy/config.m4
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/config.m4?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/config.m4 (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/config.m4 Mon Nov 27 07:00:56 2006
@@ -16,7 +16,7 @@
 proxy_connect_objs="mod_proxy_connect.lo"
 proxy_ftp_objs="mod_proxy_ftp.lo"
 proxy_http_objs="mod_proxy_http.lo"
-proxy_ajp_objs="mod_proxy_ajp.lo ajp_header.lo ajp_link.lo ajp_msg.lo"
+proxy_ajp_objs="mod_proxy_ajp.lo ajp_header.lo ajp_link.lo ajp_msg.lo ajp_utils.lo"
 proxy_balancer_objs="mod_proxy_balancer.lo"
 
 case "$host" in

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.c?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.c Mon Nov 27 07:00:56 2006
@@ -250,6 +250,15 @@
             return "lbset must be between 0 and 99";
         worker->lbset = ival;
     }
+    else if (!strcasecmp(key, "ping")) {
+        /* Ping/Pong timeout in seconds.
+         */
+        ival = atoi(val);
+        if (ival < 1)
+            return "Ping/Pong timeout must be at least one second";
+        worker->ping_timeout = apr_time_from_sec(ival);
+        worker->ping_timeout_set = 1;
+    }
     else {
         return "unknown Worker parameter";
     }

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy.h Mon Nov 27 07:00:56 2006
@@ -325,6 +325,8 @@
     } flush_packets;           /* control AJP flushing */
     int             flush_wait;  /* poll wait time in microseconds if flush_auto */
     int             lbset;      /* load balancer cluster set */
+    apr_interval_time_t ping_timeout;
+    char ping_timeout_set;
 };
 
 /*

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.c Mon Nov 27 07:00:56 2006
@@ -532,6 +532,20 @@
         goto cleanup;
     }
 
+    /* Handle CPING/CPONG */
+    if (worker->ping_timeout_set) {
+        status = ajp_handle_cping_cpong(backend->sock, r,
+                                        worker->ping_timeout);
+        if (status != APR_SUCCESS) {
+            backend->close++;
+            ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
+                         "proxy: AJP: cping/cpong failed to %pI (%s)",
+                         worker->cp->addr,
+                         worker->hostname);
+            status = HTTP_SERVICE_UNAVAILABLE;
+            goto cleanup;
+        }
+    }
     /* Step Three: Process the Request */
     status = ap_proxy_ajp_request(p, r, backend, origin, dconf, uri, url,
                                   server_portstr);

Modified: httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.dsp
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.dsp?view=diff&rev=479647&r1=479646&r2=479647
==============================================================================
--- httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.dsp (original)
+++ httpd/httpd/branches/2.2.x/modules/proxy/mod_proxy_ajp.dsp Mon Nov 27 07:00:56 2006
@@ -126,6 +126,10 @@
 
 SOURCE=.\ajp_msg.c
 # End Source File
+# Begin Source File
+
+SOURCE=.\ajp_utils.c
+# End Source File
 # End Group
 # Begin Source File
 



Mime
View raw message