Author: mturk
Date: Mon Oct 13 04:31:00 2008
New Revision: 704015
URL: http://svn.apache.org/viewvc?rev=704015&view=rev
Log:
Add socket_connect_timeout, as per mod_proxy
Modified:
tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c
tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c
tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
tomcat/connectors/trunk/jk/native/common/jk_connect.c
tomcat/connectors/trunk/jk/native/common/jk_connect.h
tomcat/connectors/trunk/jk/native/common/jk_util.c
tomcat/connectors/trunk/jk/native/common/jk_util.h
tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
tomcat/connectors/trunk/jk/xdocs/reference/workers.xml
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp12_worker.c Mon Oct 13
04:31:00 2008
@@ -127,7 +127,7 @@
attempt++) {
p->sd =
jk_open_socket(&p->worker->worker_inet_addr,
- JK_FALSE, 0, 0, l);
+ JK_FALSE, 0, 0, 0, l);
jk_log(l, JK_LOG_DEBUG, "In jk_endpoint_t::service, sd = %d",
p->sd);
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=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.c Mon Oct 13
04:31:00 2008
@@ -913,6 +913,7 @@
ae->sd = jk_open_socket(&ae->worker->worker_inet_addr,
ae->worker->keepalive,
ae->worker->socket_timeout,
+ ae->worker->socket_connect_timeout,
ae->worker->socket_buf, l);
if (!IS_VALID_SOCKET(ae->sd)) {
@@ -2509,6 +2510,10 @@
p->socket_timeout =
jk_get_worker_socket_timeout(props, p->name,
AJP_DEF_SOCKET_TIMEOUT);
+ p->socket_connect_timeout =
+ jk_get_worker_socket_connect_timeout(props, p->name,
+ p->socket_timeout * 1000);
+
p->keepalive =
jk_get_worker_socket_keepalive(props, p->name, JK_FALSE);
@@ -2591,51 +2596,55 @@
"setting endpoint options:",
p->keepalive);
jk_log(l, JK_LOG_DEBUG,
- "keepalive: %d",
+ "keepalive: %d",
p->keepalive);
jk_log(l, JK_LOG_DEBUG,
- "timeout: %d",
+ "socket timeout: %d",
p->socket_timeout);
jk_log(l, JK_LOG_DEBUG,
- "buffer size: %d",
+ "socket connect timeout: %d",
+ p->socket_connect_timeout);
+
+ jk_log(l, JK_LOG_DEBUG,
+ "buffer size: %d",
p->socket_buf);
jk_log(l, JK_LOG_DEBUG,
- "pool timeout: %d",
+ "pool timeout: %d",
p->cache_timeout);
jk_log(l, JK_LOG_DEBUG,
- "ping timeout: %d",
+ "ping timeout: %d",
p->ping_timeout);
jk_log(l, JK_LOG_DEBUG,
- "connect timeout: %d",
+ "connect timeout: %d",
p->connect_timeout);
jk_log(l, JK_LOG_DEBUG,
- "reply timeout: %d",
+ "reply timeout: %d",
p->reply_timeout);
jk_log(l, JK_LOG_DEBUG,
- "prepost timeout: %d",
+ "prepost timeout: %d",
p->prepost_timeout);
jk_log(l, JK_LOG_DEBUG,
- "recovery options: %d",
+ "recovery options: %d",
p->recovery_opts);
jk_log(l, JK_LOG_DEBUG,
- "retries: %d",
+ "retries: %d",
p->retries);
jk_log(l, JK_LOG_DEBUG,
- "max packet size: %d",
+ "max packet size: %d",
p->max_packet_size);
jk_log(l, JK_LOG_DEBUG,
- "retry interval: %d",
+ "retry interval: %d",
p->retry_interval);
}
/*
Modified: tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_ajp_common.h Mon Oct 13
04:31:00 2008
@@ -306,6 +306,7 @@
* Handle Socket Timeouts
*/
int socket_timeout;
+ int socket_connect_timeout;
int keepalive;
int socket_buf;
/*
Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.c
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.c?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_connect.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_connect.c Mon Oct 13 04:31:00
2008
@@ -172,8 +172,9 @@
FD_ZERO(&efdset);
FD_SET(sd, &efdset);
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
+
rc = select((int)sd + 1, NULL, &wfdset, &efdset, &tv);
if (JK_IS_SOCKET_ERROR(rc) || rc == 0) {
rc = WSAGetLastError();
@@ -235,8 +236,8 @@
FD_ZERO(&wfdset);
FD_SET(sd, &wfdset);
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout % 1000) * 1000;
rc = select(sd + 1, NULL, &wfdset, NULL, &tv);
if (rc <= 0) {
/* Save errno */
@@ -413,7 +414,8 @@
* @remark Cares about errno
*/
jk_sock_t jk_open_socket(struct sockaddr_in *addr, int keepalive,
- int timeout, int sock_buf, jk_logger_t *l)
+ int timeout, int connect_timeout,
+ int sock_buf, jk_logger_t *l)
{
char buf[32];
jk_sock_t sd;
@@ -578,7 +580,7 @@
#if (_XOPEN_SOURCE >= 520) && defined(AS400)
((struct sockaddr *)addr)->sa_len = sizeof(struct sockaddr_in);
#endif
- ret = nb_connect(sd, (struct sockaddr *)addr, timeout, l);
+ ret = nb_connect(sd, (struct sockaddr *)addr, connect_timeout, l);
#if defined(WIN32) || (defined(NETWARE) && defined(__NOVELL_LIBC__))
if (JK_IS_SOCKET_ERROR(ret)) {
JK_GET_SOCKET_ERRNO();
Modified: tomcat/connectors/trunk/jk/native/common/jk_connect.h
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_connect.h?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_connect.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_connect.h Mon Oct 13 04:31:00
2008
@@ -41,7 +41,8 @@
int jk_resolve(const char *host, int port, struct sockaddr_in *rc, jk_logger_t
*l);
jk_sock_t jk_open_socket(struct sockaddr_in *addr, int keepalive,
- int timeout, int sock_buf, jk_logger_t *l);
+ int timeout, int connect_timeout,
+ int sock_buf, jk_logger_t *l);
int jk_close_socket(jk_sock_t sd, jk_logger_t *l);
Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Mon Oct 13 04:31:00 2008
@@ -58,6 +58,7 @@
#define PREPOST_TIMEOUT_OF_WORKER ("prepost_timeout")
#define REPLY_TIMEOUT_OF_WORKER ("reply_timeout")
#define SOCKET_TIMEOUT_OF_WORKER ("socket_timeout")
+#define SOCKET_CONNECT_TIMEOUT_OF_WORKER ("socket_connect_timeout")
#define PING_TIMEOUT_OF_WORKER ("ping_timeout")
#define PING_MODE_OF_WORKER ("ping_mode")
#define SOCKET_BUFFER_OF_WORKER ("socket_buffer")
@@ -182,6 +183,7 @@
PING_MODE_OF_WORKER,
REPLY_TIMEOUT_OF_WORKER,
SOCKET_TIMEOUT_OF_WORKER,
+ SOCKET_CONNECT_TIMEOUT_OF_WORKER,
SOCKET_BUFFER_OF_WORKER,
SOCKET_KEEPALIVE_OF_WORKER,
CONN_PING_INTERVAL_OF_WORKER,
@@ -272,6 +274,7 @@
PING_MODE_OF_WORKER,
REPLY_TIMEOUT_OF_WORKER,
SOCKET_TIMEOUT_OF_WORKER,
+ SOCKET_CONNECT_TIMEOUT_OF_WORKER,
SOCKET_BUFFER_OF_WORKER,
SOCKET_KEEPALIVE_OF_WORKER,
CONN_PING_INTERVAL_OF_WORKER,
@@ -959,6 +962,19 @@
return jk_map_get_int(m, buf, def);
}
+int jk_get_worker_socket_connect_timeout(jk_map_t *m, const char *wname, int
def)
+{
+ char buf[1024];
+
+ if (!m || !wname) {
+ return -1;
+ }
+
+ MAKE_WORKER_PARAM(SOCKET_CONNECT_TIMEOUT_OF_WORKER);
+
+ return jk_map_get_int(m, buf, def);
+}
+
int jk_get_worker_recover_timeout(jk_map_t *m, const char *wname, int def)
{
char buf[1024];
Modified: tomcat/connectors/trunk/jk/native/common/jk_util.h
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.h?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.h Mon Oct 13 04:31:00 2008
@@ -74,6 +74,8 @@
int jk_get_worker_socket_timeout(jk_map_t *m, const char *wname, int def);
+int jk_get_worker_socket_connect_timeout(jk_map_t *m, const char *wname, int
def);
+
int jk_get_worker_socket_buffer(jk_map_t *m, const char *wname, int def);
int jk_get_worker_socket_keepalive(jk_map_t *m, const char *wname, int def);
Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Mon Oct 13
04:31:00 2008
@@ -43,6 +43,11 @@
<br />
<subsection name="Native">
<changelog>
+ <update>
+ Added socket_connect_timeout directive for setting the
+ connect timeout for the socket. This enables to have low
+ connection timeout but higher operational timeouts. (mturk)
+ </update>
<fix>Always send initial POST packet even if the client
disconnected after sending request but before providing
POST data. In that case or in case the client broke the
Modified: tomcat/connectors/trunk/jk/xdocs/reference/workers.xml
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/reference/workers.xml?rev=704015&r1=704014&r2=704015&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/reference/workers.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/reference/workers.xml Mon Oct 13 04:31:00
2008
@@ -248,6 +248,15 @@
on all socket operations.
</directive>
+<directive name="socket_connect_timeout" default="socket_timeout"
required="false">
+Socket connect timeout in milliseconds used for the communication channel
between JK and remote host.
+If the remote host does not respond inside the timeout specified, JK will
generate an error,
+and retry again.
+<p>
+This feature has been added in <b>jk 1.2.27</b>.
+</p>
+</directive>
+
<directive name="socket_keepalive" default="False" required="false">
This directive should be used when you have a firewall between your webserver
and the Tomcat engine, who tend to drop inactive connections. This flag will
tell the Operating System
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]