projects
/
privoxy.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
13c2297
)
Garbage collect csp->sfd and consistently use csp->server_connection.sfd instead.
author
Fabian Keil
<fk@fabiankeil.de>
Sun, 4 Oct 2009 15:45:11 +0000
(15:45 +0000)
committer
Fabian Keil
<fk@fabiankeil.de>
Sun, 4 Oct 2009 15:45:11 +0000
(15:45 +0000)
jcc.c
patch
|
blob
|
history
project.h
patch
|
blob
|
history
diff --git
a/jcc.c
b/jcc.c
index
d15cbf0
..
c0d3cba
100644
(file)
--- a/
jcc.c
+++ b/
jcc.c
@@
-1,4
+1,4
@@
-const char jcc_rcs[] = "$Id: jcc.c,v 1.29
7 2009/10/03 10:37:49
fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.29
8 2009/10/04 15:34:17
fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
@@
-1235,7
+1235,8
@@
static void mark_server_socket_tainted(struct client_state *csp)
&& !(csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED))
{
log_error(LOG_LEVEL_CONNECT,
&& !(csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED))
{
log_error(LOG_LEVEL_CONNECT,
- "Marking the server socket %d tainted.", csp->sfd);
+ "Marking the server socket %d tainted.",
+ csp->server_connection.sfd);
csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED;
}
}
csp->flags |= CSP_FLAG_SERVER_SOCKET_TAINTED;
}
}
@@
-1710,27
+1711,27
@@
static void chat(struct client_state *csp)
/* here we connect to the server, gateway, or the forwarder */
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
/* here we connect to the server, gateway, or the forwarder */
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
- if ((csp->sfd != JB_INVALID_SOCKET)
- && socket_is_still_usable(csp->sfd)
+ if ((csp->s
erver_connection.s
fd != JB_INVALID_SOCKET)
+ && socket_is_still_usable(csp->s
erver_connection.s
fd)
&& connection_destination_matches(&csp->server_connection, http, fwd))
{
log_error(LOG_LEVEL_CONNECT,
"Reusing server socket %u. Opened for %s.",
&& connection_destination_matches(&csp->server_connection, http, fwd))
{
log_error(LOG_LEVEL_CONNECT,
"Reusing server socket %u. Opened for %s.",
- csp->sfd, csp->server_connection.host);
+ csp->s
erver_connection.s
fd, csp->server_connection.host);
}
else
{
}
else
{
- if (csp->sfd != JB_INVALID_SOCKET)
+ if (csp->s
erver_connection.s
fd != JB_INVALID_SOCKET)
{
log_error(LOG_LEVEL_CONNECT,
"Closing server socket %u. Opened for %s.",
{
log_error(LOG_LEVEL_CONNECT,
"Closing server socket %u. Opened for %s.",
- csp->sfd, csp->server_connection.host);
- close_socket(csp->sfd);
+ csp->s
erver_connection.s
fd, csp->server_connection.host);
+ close_socket(csp->s
erver_connection.s
fd);
mark_connection_closed(&csp->server_connection);
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
mark_connection_closed(&csp->server_connection);
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
- while ((csp->sfd = forwarded_connect(fwd, http, csp))
+ while ((csp->s
erver_connection.s
fd = forwarded_connect(fwd, http, csp))
&& (errno == EINVAL)
&& (forwarded_connect_retries++ < max_forwarded_connect_retries))
{
&& (errno == EINVAL)
&& (forwarded_connect_retries++ < max_forwarded_connect_retries))
{
@@
-1739,7
+1740,7
@@
static void chat(struct client_state *csp)
forwarded_connect_retries, http->hostport);
}
forwarded_connect_retries, http->hostport);
}
- if (csp->sfd == JB_INVALID_SOCKET)
+ if (csp->s
erver_connection.s
fd == JB_INVALID_SOCKET)
{
if (fwd->type != SOCKS_NONE)
{
{
if (fwd->type != SOCKS_NONE)
{
@@
-1766,8
+1767,10
@@
static void chat(struct client_state *csp)
return;
}
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
return;
}
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
- save_connection_destination(csp->sfd, http, fwd, &csp->server_connection);
- csp->server_connection.keep_alive_timeout = (unsigned)csp->config->keep_alive_timeout;
+ save_connection_destination(csp->server_connection.sfd,
+ http, fwd, &csp->server_connection);
+ csp->server_connection.keep_alive_timeout =
+ (unsigned)csp->config->keep_alive_timeout;
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
@@
-1785,8
+1788,8
@@
static void chat(struct client_state *csp)
* Write the client's (modified) header to the server
* (along with anything else that may be in the buffer)
*/
* Write the client's (modified) header to the server
* (along with anything else that may be in the buffer)
*/
- if (write_socket(csp->sfd, hdr, strlen(hdr))
- || (flush_socket(csp->sfd, csp->iob) < 0))
+ if (write_socket(csp->s
erver_connection.s
fd, hdr, strlen(hdr))
+ || (flush_socket(csp->s
erver_connection.s
fd, csp->iob) < 0))
{
log_error(LOG_LEVEL_CONNECT,
"write header to: %s failed: %E", http->hostport);
{
log_error(LOG_LEVEL_CONNECT,
"write header to: %s failed: %E", http->hostport);
@@
-1823,7
+1826,8
@@
static void chat(struct client_state *csp)
/* we're finished with the client's header */
freez(hdr);
/* we're finished with the client's header */
freez(hdr);
- maxfd = (csp->cfd > csp->sfd) ? csp->cfd : csp->sfd;
+ maxfd = (csp->cfd > csp->server_connection.sfd) ?
+ csp->cfd : csp->server_connection.sfd;
/* pass data between the client and server
* until one or the other shuts down the connection.
/* pass data between the client and server
* until one or the other shuts down the connection.
@@
-1845,7
+1849,7
@@
static void chat(struct client_state *csp)
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if (!watch_client_socket)
{
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if (!watch_client_socket)
{
- maxfd = csp->sfd;
+ maxfd = csp->s
erver_connection.s
fd;
}
else
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
}
else
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
@@
-1853,7
+1857,7
@@
static void chat(struct client_state *csp)
FD_SET(csp->cfd, &rfds);
}
FD_SET(csp->cfd, &rfds);
}
- FD_SET(csp->sfd, &rfds);
+ FD_SET(csp->s
erver_connection.s
fd, &rfds);
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if ((csp->flags & CSP_FLAG_CHUNKED)
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if ((csp->flags & CSP_FLAG_CHUNKED)
@@
-1948,8
+1952,10
@@
static void chat(struct client_state *csp)
* available on the socket, the client went fishing
* and continuing talking to the server makes no sense.
*/
* available on the socket, the client went fishing
* and continuing talking to the server makes no sense.
*/
- log_error(LOG_LEVEL_CONNECT, "The client closed socket %d while "
- "the server socket %d is still open.", csp->cfd, csp->sfd);
+ log_error(LOG_LEVEL_CONNECT,
+ "The client closed socket %d while "
+ "the server socket %d is still open.",
+ csp->cfd, csp->server_connection.sfd);
mark_server_socket_tainted(csp);
break;
}
mark_server_socket_tainted(csp);
break;
}
@@
-1993,7
+1999,7
@@
static void chat(struct client_state *csp)
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
}
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
- if (write_socket(csp->sfd, buf, (size_t)len))
+ if (write_socket(csp->s
erver_connection.s
fd, buf, (size_t)len))
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
mark_server_socket_tainted(csp);
{
log_error(LOG_LEVEL_ERROR, "write to: %s failed: %E", http->host);
mark_server_socket_tainted(csp);
@@
-2007,7
+2013,7
@@
static void chat(struct client_state *csp)
* If `hdr' is null, then it's the header otherwise it's the body.
* FIXME: Does `hdr' really mean `host'? No.
*/
* If `hdr' is null, then it's the header otherwise it's the body.
* FIXME: Does `hdr' really mean `host'? No.
*/
- if (FD_ISSET(csp->sfd, &rfds))
+ if (FD_ISSET(csp->s
erver_connection.s
fd, &rfds))
{
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if (!socket_is_still_usable(csp->cfd))
{
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
if (!socket_is_still_usable(csp->cfd))
@@
-2025,7
+2031,7
@@
static void chat(struct client_state *csp)
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
fflush(NULL);
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
fflush(NULL);
- len = read_socket(csp->sfd, buf, sizeof(buf) - 1);
+ len = read_socket(csp->s
erver_connection.s
fd, buf, sizeof(buf) - 1);
if (len < 0)
{
if (len < 0)
{
@@
-2309,13
+2315,13
@@
static void chat(struct client_state *csp)
log_error(LOG_LEVEL_ERROR,
"Empty server or forwarder response received on socket %d. "
"Closing client connection %d without sending data.",
log_error(LOG_LEVEL_ERROR,
"Empty server or forwarder response received on socket %d. "
"Closing client connection %d without sending data.",
- csp->sfd, csp->cfd);
+ csp->s
erver_connection.s
fd, csp->cfd);
}
else
{
log_error(LOG_LEVEL_ERROR,
"Empty server or forwarder response received on socket %d.",
}
else
{
log_error(LOG_LEVEL_ERROR,
"Empty server or forwarder response received on socket %d.",
- csp->sfd);
+ csp->s
erver_connection.s
fd);
send_crunch_response(csp, error_response(csp, "no-server-data"));
}
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"));
}
log_error(LOG_LEVEL_CLF, "%s - - [%T] \"%s\" 502 0", csp->ip_addr_str, http->cmd);
@@
-2506,8
+2512,8
@@
static void serve(struct client_state *csp)
&& (csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE)
&& !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)
&& (csp->cfd != JB_INVALID_SOCKET)
&& (csp->flags & CSP_FLAG_SERVER_CONNECTION_KEEP_ALIVE)
&& !(csp->flags & CSP_FLAG_SERVER_SOCKET_TAINTED)
&& (csp->cfd != JB_INVALID_SOCKET)
- && (csp->sfd != JB_INVALID_SOCKET)
- && socket_is_still_usable(csp->sfd)
+ && (csp->s
erver_connection.s
fd != JB_INVALID_SOCKET)
+ && socket_is_still_usable(csp->s
erver_connection.s
fd)
&& (latency < csp->server_connection.keep_alive_timeout);
if (continue_chatting)
&& (latency < csp->server_connection.keep_alive_timeout);
if (continue_chatting)
@@
-2526,7
+2532,7
@@
static void serve(struct client_state *csp)
log_error(LOG_LEVEL_CONNECT,
"Waiting for the next client request. "
"Keeping the server socket %d to %s open.",
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);
+ csp->s
erver_connection.s
fd, csp->server_connection.host);
if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE)
&& data_is_available(csp->cfd, (int)client_timeout)
if ((csp->flags & CSP_FLAG_CLIENT_CONNECTION_KEEP_ALIVE)
&& data_is_available(csp->cfd, (int)client_timeout)
@@
-2566,7
+2572,7
@@
static void serve(struct client_state *csp)
"No additional client request received in time.");
#ifdef FEATURE_CONNECTION_SHARING
if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING)
"No additional client request received in time.");
#ifdef FEATURE_CONNECTION_SHARING
if ((csp->config->feature_flags & RUNTIME_FEATURE_CONNECTION_SHARING)
- && (socket_is_still_usable(csp->sfd)))
+ && (socket_is_still_usable(csp->s
erver_connection.s
fd)))
{
time_t time_open = time(NULL) - csp->server_connection.timestamp;
{
time_t time_open = time(NULL) - csp->server_connection.timestamp;
@@
-2576,7
+2582,7
@@
static void serve(struct client_state *csp)
}
remember_connection(&csp->server_connection);
}
remember_connection(&csp->server_connection);
- csp->sfd = JB_INVALID_SOCKET;
+ csp->s
erver_connection.s
fd = JB_INVALID_SOCKET;
close_socket(csp->cfd);
csp->cfd = JB_INVALID_SOCKET;
privoxy_mutex_lock(&connection_reuse_mutex);
close_socket(csp->cfd);
csp->cfd = JB_INVALID_SOCKET;
privoxy_mutex_lock(&connection_reuse_mutex);
@@
-2594,11
+2600,11
@@
static void serve(struct client_state *csp)
break;
}
}
break;
}
}
- else if (csp->sfd != JB_INVALID_SOCKET)
+ else if (csp->s
erver_connection.s
fd != JB_INVALID_SOCKET)
{
log_error(LOG_LEVEL_CONNECT,
"The connection on server socket %d to %s isn't reusable. "
{
log_error(LOG_LEVEL_CONNECT,
"The connection on server socket %d to %s isn't reusable. "
- "Closing.", csp->sfd, csp->server_connection.host);
+ "Closing.", csp->s
erver_connection.s
fd, csp->server_connection.host);
}
} while (continue_chatting);
}
} while (continue_chatting);
@@
-2607,12
+2613,12
@@
static void serve(struct client_state *csp)
chat(csp);
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
chat(csp);
#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
- if (csp->sfd != JB_INVALID_SOCKET)
+ if (csp->s
erver_connection.s
fd != JB_INVALID_SOCKET)
{
#ifdef FEATURE_CONNECTION_SHARING
{
#ifdef FEATURE_CONNECTION_SHARING
- forget_connection(csp->sfd);
+ forget_connection(csp->s
erver_connection.s
fd);
#endif /* def FEATURE_CONNECTION_SHARING */
#endif /* def FEATURE_CONNECTION_SHARING */
- close_socket(csp->sfd);
+ close_socket(csp->s
erver_connection.s
fd);
}
if (csp->cfd != JB_INVALID_SOCKET)
}
if (csp->cfd != JB_INVALID_SOCKET)
@@
-3410,7
+3416,7
@@
static void listen_loop(void)
}
csp->flags |= CSP_FLAG_ACTIVE;
}
csp->flags |= CSP_FLAG_ACTIVE;
- csp->s
fd
= JB_INVALID_SOCKET;
+ csp->s
erver_connection.sfd
= JB_INVALID_SOCKET;
csp->config = config = load_config();
csp->config = config = load_config();
diff --git
a/project.h
b/project.h
index
c8ff384
..
22887f2
100644
(file)
--- a/
project.h
+++ b/
project.h
@@
-1,7
+1,7
@@
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
#ifndef PROJECT_H_INCLUDED
#define PROJECT_H_INCLUDED
/** Version string. */
-#define PROJECT_H_VERSION "$Id: project.h,v 1.1
49 2009/08/19 15:57:13
fabiankeil Exp $"
+#define PROJECT_H_VERSION "$Id: project.h,v 1.1
50 2009/10/04 15:34:18
fabiankeil Exp $"
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/project.h,v $
@@
-632,8
+632,9
@@
struct url_actions
/*
/*
- * Structure to make sure we only reuse the server socket
- * if the host and forwarding settings are the same.
+ * Structure to hold the server socket and the information
+ * required to make sure we only reuse the connection if
+ * the host and forwarding settings are the same.
*/
struct reusable_connection
{
*/
struct reusable_connection
{
@@
-829,9
+830,6
@@
struct client_state
/** socket to talk to client (web browser) */
jb_socket cfd;
/** socket to talk to client (web browser) */
jb_socket cfd;
- /** socket to talk to server (web server or proxy) */
- jb_socket sfd;
-
/** current connection to the server (may go through a proxy) */
struct reusable_connection server_connection;
/** current connection to the server (may go through a proxy) */
struct reusable_connection server_connection;