-const char gateway_rcs[] = "$Id: gateway.c,v 1.55 2009/07/05 12:01:45 fabiankeil Exp $";
+const char gateway_rcs[] = "$Id: gateway.c,v 1.56 2009/07/11 14:49:09 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/gateway.c,v $
reusable_connection[slot].port = http->port;
reusable_connection[slot].in_use = 0;
reusable_connection[slot].timestamp = connection->timestamp;
+ reusable_connection->request_sent = connection->request_sent;
+ reusable_connection->response_received = connection->response_received;
reusable_connection[slot].keep_alive_timeout = connection->keep_alive_timeout;
assert(NULL != fwd);
freez(closed_connection->host);
closed_connection->port = 0;
closed_connection->timestamp = 0;
+ closed_connection->request_sent = 0;
+ closed_connection->response_received = 0;
closed_connection->keep_alive_timeout = 0;
closed_connection->forwarder_type = SOCKS_NONE;
freez(closed_connection->gateway_host);
&& (JB_INVALID_SOCKET != reusable_connection[slot].sfd))
{
time_t time_open = time(NULL) - reusable_connection[slot].timestamp;
+ time_t latency = reusable_connection[slot].response_received -
+ reusable_connection[slot].request_sent;
- if (reusable_connection[slot].keep_alive_timeout < time_open)
+ if (reusable_connection[slot].keep_alive_timeout < time_open + latency)
{
log_error(LOG_LEVEL_CONNECT,
"The connection to %s:%d in slot %d timed out. "
- "Closing socket %d. Timeout is: %d.",
+ "Closing socket %d. Timeout is: %d. Assumed latency: %d",
reusable_connection[slot].host,
reusable_connection[slot].port, slot,
reusable_connection[slot].sfd,
- reusable_connection[slot].keep_alive_timeout);
+ reusable_connection[slot].keep_alive_timeout,
+ latency);
close_socket(reusable_connection[slot].sfd);
mark_connection_closed(&reusable_connection[slot]);
}
-const char jcc_rcs[] = "$Id: jcc.c,v 1.268 2009/07/13 17:05:36 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.269 2009/07/13 17:08:41 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
log_error(LOG_LEVEL_CONNECT, "to %s successful", http->hostport);
+ csp->server_connection.request_sent = time(NULL);
+
/* we're finished with the client's header */
freez(hdr);
log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header");
}
+ csp->server_connection.response_received = time(NULL);
+
if (crunch_response_triggered(csp, crunchers_light))
{
/*
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
static int monitor_thread_running = 0;
int continue_chatting = 0;
+ unsigned int latency = 0;
+
do
{
chat(csp);
&& !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)
&& (csp->cfd != JB_INVALID_SOCKET)
&& (csp->sfd != JB_INVALID_SOCKET)
- && socket_is_still_usable(csp->sfd);
+ && socket_is_still_usable(csp->sfd)
+ && (latency < csp->server_connection.keep_alive_timeout);
if (continue_chatting)
{
+ unsigned int client_timeout = (unsigned)csp->server_connection.keep_alive_timeout - latency;
log_error(LOG_LEVEL_CONNECT,
"Waiting for the next client request. "
"Keeping the server socket %d to %s open.",
csp->sfd, csp->server_connection.host);
if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE)
- && data_is_available(csp->cfd, (int)csp->server_connection.keep_alive_timeout)
+ && data_is_available(csp->cfd, (int)client_timeout)
&& socket_is_still_usable(csp->cfd))
{
log_error(LOG_LEVEL_CONNECT, "Client request arrived in "
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.142 2009/06/11 11:49:11 fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.143 2009/06/28 14:31:43 fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
{
jb_socket sfd;
int in_use;
- time_t timestamp;
+ time_t timestamp; /* XXX: rename? */
+
+ time_t request_sent;
+ time_t response_received;
+
/*
* Number of seconds after which this
* connection will no longer be reused.