summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/child.c8
-rw-r--r--src/child.h4
-rw-r--r--src/conns.c4
-rw-r--r--src/conns.h7
-rw-r--r--src/daemon.c8
-rw-r--r--src/reqs.c11
-rw-r--r--src/tinyproxy.h8
7 files changed, 32 insertions, 18 deletions
diff --git a/src/child.c b/src/child.c
index 25f87fa..25e8eb9 100644
--- a/src/child.c
+++ b/src/child.c
@@ -1,4 +1,4 @@
-/* $Id: child.c,v 1.14 2004-02-13 21:27:42 rjkaes Exp $
+/* $Id: child.c,v 1.15 2004-08-10 21:24:23 rjkaes Exp $
*
* Handles the creation/destruction of the various children required for
* processing incoming connections.
@@ -47,8 +47,8 @@ struct child_s {
static struct child_s *child_ptr;
static struct child_config_s {
- unsigned int maxclients, maxrequestsperchild;
- unsigned int maxspareservers, minspareservers, startservers;
+ int maxclients, maxrequestsperchild;
+ int maxspareservers, minspareservers, startservers;
} child_config;
static unsigned int* servers_waiting; /* servers waiting for a connection */
@@ -129,7 +129,7 @@ _child_lock_release(void)
* Set the configuration values for the various child related settings.
*/
short int
-child_configure(child_config_t type, unsigned int val)
+child_configure(child_config_t type, int val)
{
switch (type) {
case CHILD_MAXCLIENTS:
diff --git a/src/child.h b/src/child.h
index 2ae5b3d..eecf15e 100644
--- a/src/child.h
+++ b/src/child.h
@@ -1,4 +1,4 @@
-/* $Id: child.h,v 1.1 2002-05-26 18:45:26 rjkaes Exp $
+/* $Id: child.h,v 1.2 2004-08-10 21:24:23 rjkaes Exp $
*
* See 'child.c' for more information.
*
@@ -32,6 +32,6 @@ extern void child_close_sock(void);
extern void child_main_loop(void);
extern void child_kill_children(void);
-extern short int child_configure(child_config_t type, unsigned int val);
+extern short int child_configure(child_config_t type, int val);
#endif
diff --git a/src/conns.c b/src/conns.c
index c94b245..6a20044 100644
--- a/src/conns.c
+++ b/src/conns.c
@@ -1,4 +1,4 @@
-/* $Id: conns.c,v 1.22 2004-04-27 18:53:14 rjkaes Exp $
+/* $Id: conns.c,v 1.23 2004-08-10 21:24:23 rjkaes Exp $
*
* Create and free the connection structure. One day there could be
* other connection related tasks put here, but for now the header
@@ -76,6 +76,8 @@ initialize_conn(int client_fd, const char* ipaddr, const char* string_addr,
connptr->client_ip_addr = safestrdup(ipaddr);
connptr->client_string_addr = safestrdup(string_addr);
+ connptr->upstream_proxy = NULL;
+
update_stats(STAT_OPEN);
#ifdef REVERSE_SUPPORT
diff --git a/src/conns.h b/src/conns.h
index 8b6f69e..d730737 100644
--- a/src/conns.h
+++ b/src/conns.h
@@ -1,4 +1,4 @@
-/* $Id: conns.h,v 1.17 2004-04-27 18:53:14 rjkaes Exp $
+/* $Id: conns.h,v 1.18 2004-08-10 21:24:23 rjkaes Exp $
*
* See 'conns.c' for a detailed description.
*
@@ -78,6 +78,11 @@ struct conn_s {
*/
char* reversepath;
#endif
+
+ /*
+ * Pointer to upstream proxy.
+ */
+ struct upstream *upstream_proxy;
};
/*
diff --git a/src/daemon.c b/src/daemon.c
index 10bda1d..189b1dc 100644
--- a/src/daemon.c
+++ b/src/daemon.c
@@ -1,4 +1,4 @@
-/* $Id: daemon.c,v 1.2 2002-10-03 20:38:06 rjkaes Exp $
+/* $Id: daemon.c,v 1.3 2004-08-10 21:24:23 rjkaes Exp $
*
* This file contains functions which are useful when writing a
* daemon process. The functions include a "makedaemon" function and
@@ -40,7 +40,11 @@ makedaemon(void)
chdir("/");
umask(077);
-#if 0
+#if NDEBUG
+ /*
+ * When not in debugging mode, close the standard file
+ * descriptors.
+ */
close(0);
close(1);
close(2);
diff --git a/src/reqs.c b/src/reqs.c
index d577867..fc9375f 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -1,4 +1,4 @@
-/* $Id: reqs.c,v 1.112 2004-04-27 18:53:14 rjkaes Exp $
+/* $Id: reqs.c,v 1.113 2004-08-10 21:24:23 rjkaes Exp $
*
* This is where all the work in tinyproxy is actually done. Incoming
* connections have a new child created for them. The child then
@@ -1223,7 +1223,7 @@ process_client_headers(struct conn_s *connptr, hashmap_t hashofheaders)
* proxy is in use.)
*/
if (connptr->server_fd == -1 || connptr->show_stats
- || (connptr->connect_method && !UPSTREAM_CONFIGURED())) {
+ || (connptr->connect_method && (connptr->upstream_proxy == NULL))) {
log_message(LOG_INFO, "Not sending client headers to remote machine");
return 0;
}
@@ -1600,7 +1600,7 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
char *combined_string;
int len;
- struct upstream *cur_upstream = upstream_get(request->host);
+ struct upstream *cur_upstream = connptr->upstream_proxy;
if(!cur_upstream) {
log_message(LOG_WARNING,
"No upstream proxy defined for %s.",
@@ -1751,7 +1751,8 @@ handle_connection(int fd)
goto send_error;
}
- if (UPSTREAM_CONFIGURED() && (UPSTREAM_HOST(request->host) != NULL)) {
+ connptr->upstream_proxy = UPSTREAM_HOST(request->host);
+ if (connptr->upstream_proxy != NULL) {
if (connect_to_upstream(connptr, request) < 0) {
goto send_error;
}
@@ -1797,7 +1798,7 @@ handle_connection(int fd)
return;
}
- if (!connptr->connect_method || UPSTREAM_CONFIGURED()) {
+ if (!connptr->connect_method || (connptr->upstream_proxy != NULL)) {
if (process_server_headers(connptr) < 0) {
if (connptr->error_variables)
send_http_error_message(connptr);
diff --git a/src/tinyproxy.h b/src/tinyproxy.h
index 256b9e7..0ede12c 100644
--- a/src/tinyproxy.h
+++ b/src/tinyproxy.h
@@ -1,4 +1,4 @@
-/* $Id: tinyproxy.h,v 1.44 2004-04-27 18:53:14 rjkaes Exp $
+/* $Id: tinyproxy.h,v 1.45 2004-08-10 21:24:23 rjkaes Exp $
*
* See 'tinyproxy.c' for a detailed description.
*
@@ -26,7 +26,10 @@
#define MAXBUFFSIZE ((size_t)(1024 * 96)) /* Max size of buffer */
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
-#ifdef UPSTREAM_SUPPORT
+/*
+ * Even if upstream support is not compiled into tinyproxy, this
+ * structure still needs to be defined.
+ */
struct upstream {
struct upstream *next;
char *domain; /* optional */
@@ -34,7 +37,6 @@ struct upstream {
int port;
in_addr_t ip, mask;
};
-#endif
#ifdef REVERSE_SUPPORT
struct reversepath {