You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2007/12/12 13:57:05 UTC
svn commit: r603606 -
/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
Author: rjung
Date: Wed Dec 12 04:57:04 2007
New Revision: 603606
URL: http://svn.apache.org/viewvc?rev=603606&view=rev
Log:
Reorganize ajp_connect_to_endpoint() a bit,
shutdown connecion in case of error and
add/move logging.
The diff looks much easier, when ignoring whitespace.
Modified:
tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c?rev=603606&r1=603605&r2=603606&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Wed Dec 12 04:57:04 2007
@@ -261,7 +261,7 @@
p = &header[1];
/* Always do memcmp including the final \0-termination character.
- */
+ */
switch (header[0]) {
case 'A':
if (memcmp(p, "CCEPT", 6) == 0) {
@@ -825,40 +825,54 @@
ae->worker->keepalive,
ae->worker->socket_timeout,
ae->worker->socket_buf, l);
- if (IS_VALID_SOCKET(ae->sd)) {
- ae->last_errno = 0;
- if (JK_IS_DEBUG_LEVEL(l)) {
- jk_log(l, JK_LOG_DEBUG,
- "Connected socket %d to (%s)",
- ae->sd,
- jk_dump_hinfo(&ae->worker->worker_inet_addr, buf));
- }
- /* set last_access only if needed */
- if (ae->worker->cache_timeout > 0)
- ae->last_access = time(NULL);
- /* Check if we must execute a logon after the physical connect */
- if (ae->worker->logon != NULL) {
- rc = ae->worker->logon(ae, l);
- JK_TRACE_EXIT(l);
- return rc;
- }
- /* should we send a CPING to validate connection ? */
- if (ae->worker->connect_timeout > 0) {
- rc = ajp_handle_cping_cpong(ae,
- ae->worker->connect_timeout, l);
- JK_TRACE_EXIT(l);
- return rc;
- }
+
+ if (!IS_VALID_SOCKET(ae->sd)) {
+ ae->last_errno = errno;
+ jk_log(l, JK_LOG_INFO,
+ "Failed opening socket to (%s) (errno=%d)",
+ jk_dump_hinfo(&ae->worker->worker_inet_addr, buf), ae->last_errno);
JK_TRACE_EXIT(l);
- return JK_TRUE;
+ return JK_FALSE;
}
- ae->last_errno = errno;
- jk_log(l, JK_LOG_INFO,
- "Failed opening socket to (%s) (errno=%d)",
- jk_dump_hinfo(&ae->worker->worker_inet_addr, buf), ae->last_errno);
+ ae->last_errno = 0;
+ if (JK_IS_DEBUG_LEVEL(l)) {
+ jk_log(l, JK_LOG_DEBUG,
+ "Connected socket %d to (%s)",
+ ae->sd,
+ jk_dump_hinfo(&ae->worker->worker_inet_addr, buf));
+ }
+ /* set last_access only if needed */
+ if (ae->worker->cache_timeout > 0)
+ ae->last_access = time(NULL);
+ /* Check if we must execute a logon after the physical connect */
+ /* XXX: Not sure, if we really should do logon before cping/cpong */
+ /* XXX: and if no cping/cpong is allowed before or after logon. */
+ if (ae->worker->logon != NULL) {
+ rc = ae->worker->logon(ae, l);
+ if (rc == JK_FALSE)
+ jk_log(l, JK_LOG_INFO,
+ "(%s) ajp14 worker logon to the backend server failed",
+ ae->worker->name);
+ }
+ /* should we send a CPING to validate connection ? */
+ else if (ae->worker->connect_timeout > 0) {
+ rc = ajp_handle_cping_cpong(ae, ae->worker->connect_timeout, l);
+ if (rc == JK_FALSE)
+ jk_log(l, JK_LOG_INFO,
+ "(%s) cping/cpong after connecting to the backend server failed (errno=%d)",
+ ae->worker->name, ae->last_errno);
+ }
+ if (rc != JK_TRUE) {
+ /* Close the socket if unable to connect */
+ jk_log(l, JK_LOG_INFO,
+ "(%s) error connecting to the backend server",
+ ae->worker->name, ae->last_errno);
+ jk_shutdown_socket(ae->sd, l);
+ ae->sd = JK_INVALID_SOCKET;
+ }
JK_TRACE_EXIT(l);
- return JK_FALSE;
+ return rc;
}
/*
@@ -895,8 +909,8 @@
if ((rc = jk_tcp_socket_sendfull(ae->sd, msg->buf,
msg->len, l)) > 0) {
ae->endpoint.wr += (jk_uint64_t)rc;
- JK_TRACE_EXIT(l);
ae->last_errno = 0;
+ JK_TRACE_EXIT(l);
return JK_TRUE;
}
ae->last_errno = errno;
@@ -1212,7 +1226,7 @@
* connections to the node if one of them fails
* the cping/cpong heartbeat?
* Tomcat can be either too busy or simply dead, so
- * there is a chance that all oter connections would
+ * there is a chance that all other connections would
* fail as well.
*/
err = 2;
@@ -1300,12 +1314,6 @@
}
}
else {
- /* Close the socket if unable to connect */
- jk_shutdown_socket(ae->sd, l);
- ae->sd = JK_INVALID_SOCKET;
- jk_log(l, JK_LOG_INFO,
- "(%s) error connecting to the backend server (errno=%d)",
- ae->worker->name, ae->last_errno);
JK_TRACE_EXIT(l);
return JK_FALSE;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org