-const char jcc_rcs[] = "$Id: jcc.c,v 1.260 2009/07/05 12:00:09 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.266 2009/07/11 14:39:34 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
{
assert(sfd != JB_INVALID_SOCKET);
assert(NULL != http->host);
+
+ server_connection->sfd = sfd;
server_connection->host = strdup(http->host);
if (NULL == server_connection->host)
{
if ((csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE))
{
log_error(LOG_LEVEL_CONNECT,
- "Marking the connection to the server tainted.");
+ "Marking the server socket %d tainted.", csp->sfd);
csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED;
}
}
struct http_request *http = csp->http;
jb_err err;
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ if ((!strcmpic(csp->http->ver, "HTTP/1.1"))
+ && (csp->http->ssl == 0))
+ {
+ /* Assume persistence until further notice */
+ csp->flags |= CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE;
+ }
+#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
+
err = sed(csp, FILTER_CLIENT_HEADERS);
if (JB_ERR_OK != err)
{
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if ((csp->sfd != JB_INVALID_SOCKET)
- && !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)
&& socket_is_still_usable(csp->sfd)
&& connection_destination_matches(&csp->server_connection, http, fwd))
{
*/
if (FD_ISSET(csp->sfd, &rfds))
{
+#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ if (!socket_is_still_usable(csp->cfd))
+ {
+ log_error(LOG_LEVEL_CONNECT,
+ "The server still wants to talk, but the client hung up on us.");
+ mark_server_socket_tainted(csp);
+ return;
+ }
+#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
+
fflush(NULL);
len = read_socket(csp->sfd, buf, sizeof(buf) - 1);
/* Did we actually get anything? */
if (NULL == csp->headers->first)
{
- log_error(LOG_LEVEL_ERROR, "Empty server or forwarder response.");
+ log_error(LOG_LEVEL_ERROR,
+ "Empty server or forwarder response received on socket %d.", csp->sfd);
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd);
send_crunch_response(csp, error_response(csp, "no-server-data"));
free_http_request(http);
return;
}
+ csp->server_connection.timestamp = time(NULL);
+
/*
* We have now received the entire server header,
* filter it and send the result to the client
"No additional client request received in time.");
if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING))
{
- remember_connection(csp->sfd, csp->http,
- forward_url(csp, csp->http),
- csp->server_connection.keep_alive_timeout);
+ remember_connection(csp, forward_url(csp, csp->http));
csp->sfd = JB_INVALID_SOCKET;
close_socket(csp->cfd);
csp->cfd = JB_INVALID_SOCKET;