You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by mt...@apache.org on 2006/07/25 18:50:07 UTC
svn commit: r425454 - in /httpd/httpd/trunk: CHANGES
modules/proxy/NWGNUproxyajp modules/proxy/ajp_utils.c
modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Author: mturk
Date: Tue Jul 25 09:50:07 2006
New Revision: 425454
URL: http://svn.apache.org/viewvc?rev=425454&view=rev
Log:
Added cping/cpong support for the AJP protocol.
Added:
httpd/httpd/trunk/modules/proxy/ajp_utils.c
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/modules/proxy/NWGNUproxyajp
httpd/httpd/trunk/modules/proxy/mod_proxy.c
httpd/httpd/trunk/modules/proxy/mod_proxy.h
httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.dsp
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Jul 25 09:50:07 2006
@@ -2,6 +2,12 @@
Changes with Apache 2.3.0
[Remove entries to the current 2.0 and 2.2 section below, when backported]
+ *) 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_dbd: Fix dependence on virtualhost configuration in
defining prepared statements (possible segfault at startup
in user modules such as mod_authn_dbd). [Nick Kew]
Modified: httpd/httpd/trunk/modules/proxy/NWGNUproxyajp
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/NWGNUproxyajp?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/NWGNUproxyajp (original)
+++ httpd/httpd/trunk/modules/proxy/NWGNUproxyajp Tue Jul 25 09:50:07 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)
Added: httpd/httpd/trunk/modules/proxy/ajp_utils.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_utils.c?rev=425454&view=auto
==============================================================================
--- httpd/httpd/trunk/modules/proxy/ajp_utils.c (added)
+++ httpd/httpd/trunk/modules/proxy/ajp_utils.c Tue Jul 25 09:50:07 2006
@@ -0,0 +1,104 @@
+/* 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;
+ 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 */
+ rc = ajp_ilink_receive(sock, msg);
+ if (rc != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "ajp_handle_cping_cpong: ajp_ilink_receive failed");
+ return rc;
+ }
+
+ rc = ajp_msg_get_uint8(msg, &result);
+ if (rc != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "ajp_handle_cping_cpong: invalid CPONG message");
+ return rc;
+ }
+ if (result != CMD_AJP13_CPONG) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, 0, r->server,
+ "ajp_handle_cping_cpong: awaited CPONG, received %d ",
+ result);
+ return APR_EGENERAL;
+
+ }
+
+ /* 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 APR_SUCCESS;
+}
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Jul 25 09:50:07 2006
@@ -244,6 +244,15 @@
else
worker->flush_wait = ival * 1000; /* change to microseconds */
}
+ 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";
}
@@ -423,7 +432,7 @@
const char *var;
const char *val;
const char *firstpart;
-
+
start = ap_strstr_c(str, "${");
if (start == NULL) {
return str;
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Jul 25 09:50:07 2006
@@ -332,6 +332,8 @@
flush_auto
} flush_packets; /* control AJP flushing */
int flush_wait; /* poll wait time in microseconds if flush_auto */
+ apr_interval_time_t ping_timeout;
+ char ping_timeout_set;
};
/*
Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.c Tue Jul 25 09:50:07 2006
@@ -530,6 +530,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/trunk/modules/proxy/mod_proxy_ajp.dsp
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.dsp?rev=425454&r1=425453&r2=425454&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.dsp (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_ajp.dsp Tue Jul 25 09:50:07 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
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp
modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by Mladen Turk <mt...@apache.org>.
Joe Orton wrote:
> On Tue, Jul 25, 2006 at 04:50:07PM -0000, Mladen Turk wrote:
>> Author: mturk
>> Date: Tue Jul 25 09:50:07 2006
>> New Revision: 425454
>>
>> URL: http://svn.apache.org/viewvc?rev=425454&view=rev
>> Log:
>> Added cping/cpong support for the AJP protocol.
>
> This is missing a prototype in ajp.h:
>
Done.
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by Joe Orton <jo...@redhat.com>.
On Tue, Jul 25, 2006 at 04:50:07PM -0000, Mladen Turk wrote:
> Author: mturk
> Date: Tue Jul 25 09:50:07 2006
> New Revision: 425454
>
> URL: http://svn.apache.org/viewvc?rev=425454&view=rev
> Log:
> Added cping/cpong support for the AJP protocol.
This is missing a prototype in ajp.h:
mod_proxy_ajp.c: In function 'proxy_ajp_handler':
mod_proxy_ajp.c:538: warning: implicit declaration of function 'ajp_handle_cping_cpong'
ajp_utils.c:25: warning: no previous prototype for 'ajp_handle_cping_cpong'
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp
modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by Mladen Turk <mt...@apache.org>.
William A. Rowe, Jr. wrote:
> Ruediger Pluem wrote:
>>
>> ajp_utils.c is in Dos EOL style format.
>
> Mladen, please don't trash httpd in the style of tomcat svn.
>
> Text is text. Teach your svn utilities that :)
>
It needs eol-style set up. It's a new file.
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp
modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Ruediger Pluem wrote:
>
> ajp_utils.c is in Dos EOL style format.
Mladen, please don't trash httpd in the style of tomcat svn.
Text is text. Teach your svn utilities that :)
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp
modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by Mladen Turk <mt...@apache.org>.
Ruediger Pluem wrote:
>
>
> It does not build properly on Linux (guess this is true for all systems except Windows
> and Netware). I am not a build system expert, but I guess config.m4 in the proxy directory
> needs to be adjusted to get ajp_utils.c compiled and linked.
>
Right. I missed to commit config.m4 together with other files.
Regards,
Mladen.
Re: svn commit: r425454 - in /httpd/httpd/trunk: CHANGES modules/proxy/NWGNUproxyajp
modules/proxy/ajp_utils.c modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h
modules/proxy/mod_proxy_ajp.c modules/proxy/mod_proxy_ajp.dsp
Posted by Ruediger Pluem <rp...@apache.org>.
On 07/25/2006 06:50 PM, mturk@apache.org wrote:
> Author: mturk
> Date: Tue Jul 25 09:50:07 2006
> New Revision: 425454
>
> URL: http://svn.apache.org/viewvc?rev=425454&view=rev
> Log:
> Added cping/cpong support for the AJP protocol.
>
> Added:
> httpd/httpd/trunk/modules/proxy/ajp_utils.c
> Modified: httpd/httpd/trunk/modules/proxy/NWGNUproxyajp
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/NWGNUproxyajp?rev=425454&r1=425453&r2=425454&view=diff
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/NWGNUproxyajp (original)
> +++ httpd/httpd/trunk/modules/proxy/NWGNUproxyajp Tue Jul 25 09:50:07 2006
It does not build properly on Linux (guess this is true for all systems except Windows
and Netware). I am not a build system expert, but I guess config.m4 in the proxy directory
needs to be adjusted to get ajp_utils.c compiled and linked.
> Added: httpd/httpd/trunk/modules/proxy/ajp_utils.c
> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/ajp_utils.c?rev=425454&view=auto
> ==============================================================================
> --- httpd/httpd/trunk/modules/proxy/ajp_utils.c (added)
> +++ httpd/httpd/trunk/modules/proxy/ajp_utils.c Tue Jul 25 09:50:07 2006
> +/*
> + * Handle the CPING/CPONG
> + */
> +apr_status_t ajp_handle_cping_cpong(apr_socket_t *sock,
> + request_rec *r,
> + apr_interval_time_t timeout)
Unlike all other functions there is no prototype and doxygen documentation for this
in ajp.h.
ajp_utils.c is in Dos EOL style format.
Regards
RĂ¼diger