Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ceb6c7ebb | ||
|
|
a25e0a608e | ||
|
|
f58a34ed34 | ||
|
|
3138b239f6 | ||
|
|
cf2ecb83b8 | ||
|
|
14f83aec55 | ||
|
|
50058c1cab | ||
|
|
42ef3b86b6 | ||
|
|
6004eca8c6 | ||
|
|
0a1f83bbe5 | ||
|
|
82f7a5cba6 | ||
|
|
c89813d5d7 | ||
|
|
fefedea577 | ||
|
|
3284f365b2 | ||
|
|
ed90a4676f | ||
|
|
f79807ac11 | ||
|
|
e4fe04cbaf | ||
|
|
577f3cebbf | ||
|
|
1a8c914dd2 |
No files matched your search
@@ -1,5 +1,54 @@
|
|||||||
|
2002-05-08 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* configure.ac: The --with-config option now supports absolute
|
||||||
|
paths. If an absolute path is given, the full directory path and
|
||||||
|
file name are extracted into their appropriate parts.
|
||||||
|
|
||||||
|
2002-05-07 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/reqs.c (connect_to_tunnel): Removed request logging code in
|
||||||
|
the tunnel method since it breaks the "tunnel" concept.
|
||||||
|
|
||||||
|
2002-05-02 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* configure.ac: Added code to figure out exactly where to install
|
||||||
|
the configuration file.
|
||||||
|
|
||||||
|
* Makefile.am (install-data-local): Added a new install run to
|
||||||
|
install the configuration file to the location specified in
|
||||||
|
DEFAULT_CONF_FILE.
|
||||||
|
|
||||||
|
2002-04-28 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/reqs.c (process_client_headers):
|
||||||
|
(process_server_headers): Added more error checking code and
|
||||||
|
send HTTP errors back to the client to let them know what is
|
||||||
|
happening.
|
||||||
|
(handle_connection): If there was a server error when processing
|
||||||
|
the headers, send an error back to the client.
|
||||||
|
|
||||||
|
2002-04-27 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/thread.c (thread_pool_create): Set the thread's status
|
||||||
|
_before_ the thread is created. Thanks to Hans-Georg Bork for
|
||||||
|
solving this problem.
|
||||||
|
(thread_main): Fixed up the status setting code. Removed
|
||||||
|
duplicated code and explicitly set the status when needed.
|
||||||
|
|
||||||
|
Fixed up all the code checking the return value from the pthread
|
||||||
|
functions. These functions return 0 if OK, but a _positive_ error
|
||||||
|
code.
|
||||||
|
|
||||||
2002-04-26 Robert James Kaes <rjkaes@flarenet.com>
|
2002-04-26 Robert James Kaes <rjkaes@flarenet.com>
|
||||||
|
|
||||||
|
* src/thread.c: servers_waiting needs to be signed, since it can
|
||||||
|
go below 0 without causing a problem, but if it wraps around all
|
||||||
|
hell can break loose.
|
||||||
|
|
||||||
|
* src/reqs.c (connect_to_tunnel): Changed the len type to an
|
||||||
|
signed integer so that we can detect error conditions. Thanks to
|
||||||
|
Tom Cross for pointing out this problem.
|
||||||
|
|
||||||
* src/log.c (send_stored_logs): Check the return value of
|
* src/log.c (send_stored_logs): Check the return value of
|
||||||
hashmap_first() since it could be -1, indicating an empty hashmap.
|
hashmap_first() since it could be -1, indicating an empty hashmap.
|
||||||
|
|
||||||
|
|||||||
+22
@@ -1,2 +1,24 @@
|
|||||||
EXTRA_DIST = TODO
|
EXTRA_DIST = TODO
|
||||||
SUBDIRS = src doc
|
SUBDIRS = src doc
|
||||||
|
|
||||||
|
install-data-local:
|
||||||
|
$(mkinstalldirs) $(DESTDIR)@TINYPROXY_CONFIG_DIR@
|
||||||
|
$(INSTALL) -m 600 $(srcdir)/doc/tinyproxy.conf \
|
||||||
|
$(DESTDIR)@TINYPROXY_CONFIG_DIR@/@TINYPROXY_CONFIG_FILE@-dist
|
||||||
|
test ! -f $(DESTDIR)@TINYPROXY_CONFIG_DIR@/@TINYPROXY_CONFIG_FILE@ \
|
||||||
|
&& $(INSTALL) -m 600 $(srcdir)/doc/tinyproxy.conf \
|
||||||
|
$(DESTDIR)@TINYPROXY_CONFIG_DIR@/@TINYPROXY_CONFIG_FILE@
|
||||||
|
@echo ""
|
||||||
|
@echo "A configuration file has been copied to:"
|
||||||
|
@echo ""
|
||||||
|
@echo "@TINYPROXY_CONFIG_DIR@/@TINYPROXY_CONFIG_FILE@-dist"
|
||||||
|
@echo ""
|
||||||
|
@echo "You will need to rename this file to:"
|
||||||
|
@echo ""
|
||||||
|
@echo "@TINYPROXY_CONFIG_DIR@/@TINYPROXY_CONFIG_FILE@"
|
||||||
|
@echo ""
|
||||||
|
@echo "and modify the values to suit your local system."
|
||||||
|
@echo ""
|
||||||
|
@echo "All the configuration directives are commented in the file, so"
|
||||||
|
@echo "you should not have any problems configuring your system."
|
||||||
|
@echo ""
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
|
|
||||||
NEWS
|
|
||||||
====
|
|
||||||
|
|
||||||
It's been a few months since I release the 1.4.3 version. That's
|
|
||||||
a bit longer than I want to take with this release (which I originally
|
|
||||||
thought would be released a week after the 1.4.3 release in November
|
|
||||||
21, 2001 :), but my real life kind of intruded on the project.
|
|
||||||
Anyway, this release doesn't add any new features or functions; it's
|
|
||||||
basically a bug fix and standard compliance release. A few
|
|
||||||
portability bugs have been fixed, and I've rewritten a few request
|
|
||||||
processing functions to make them more compliant with the HTTP
|
|
||||||
standard.
|
|
||||||
|
|
||||||
Now, I've tested the request related code personally with all the
|
|
||||||
configurations I can think of, but I can't claim that it will work
|
|
||||||
perfectly with _every_ configuration and _every_ site. So, please
|
|
||||||
give these pre-releases a thorough testing and let me know if there
|
|
||||||
any problems you've noticed.
|
|
||||||
|
|
||||||
Robert James Kaes
|
|
||||||
April 8, 2002
|
|
||||||
+38
-26
@@ -1,4 +1,4 @@
|
|||||||
dnl $Id: configure.ac,v 2.22 2002-04-26 16:59:44 rjkaes Exp $
|
dnl $Id: configure.ac,v 2.29 2002-05-08 19:57:02 rjkaes Exp $
|
||||||
|
|
||||||
dnl Devlopers, please strive to achieve this order:
|
dnl Devlopers, please strive to achieve this order:
|
||||||
dnl
|
dnl
|
||||||
@@ -14,7 +14,7 @@ dnl 8. System services
|
|||||||
dnl
|
dnl
|
||||||
dnl Read the Autoconf manual for details.
|
dnl Read the Autoconf manual for details.
|
||||||
|
|
||||||
AC_INIT([tinyproxy], [1.5.0rc6], [rjkaes@users.sourceforge.net])
|
AC_INIT([tinyproxy], [1.5.0rc10], [rjkaes@users.sourceforge.net])
|
||||||
AC_CONFIG_SRCDIR([src/tinyproxy.c])
|
AC_CONFIG_SRCDIR([src/tinyproxy.c])
|
||||||
AC_PREREQ(2.52)
|
AC_PREREQ(2.52)
|
||||||
|
|
||||||
@@ -27,6 +27,9 @@ AC_DEFINE_UNQUOTED(TARGET_SYSTEM, ["$target"])
|
|||||||
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
|
AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
|
||||||
AM_CONFIG_HEADER(config.h)
|
AM_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
|
dnl Set the default CFLAGS
|
||||||
|
CFLAGS="-D_REENTRANT"
|
||||||
|
|
||||||
dnl Check if we're compiling on a weird platform :)
|
dnl Check if we're compiling on a weird platform :)
|
||||||
AC_AIX
|
AC_AIX
|
||||||
AC_ISC_POSIX
|
AC_ISC_POSIX
|
||||||
@@ -37,30 +40,44 @@ dnl Command line options
|
|||||||
dnl
|
dnl
|
||||||
|
|
||||||
dnl Set the URL name for find the statistics of tinyproxy
|
dnl Set the URL name for find the statistics of tinyproxy
|
||||||
AH_VERBATIM([DEFAULT_STATHOST],
|
AH_TEMPLATE([DEFAULT_STATHOST],
|
||||||
[/*
|
[This controls remote proxy stats display.])
|
||||||
* This controls remote proxy stats deplay. For example, the default
|
|
||||||
* DEFAULT_STATHOST of "tinyproxy.stats" means that where you access
|
|
||||||
* "http://tinyproxy.stats/" you will be shown the proxy stats. Use "" to
|
|
||||||
* disable.
|
|
||||||
*/
|
|
||||||
#ifndef DEFAULT_STATHOST
|
|
||||||
# define DEFAULT_STATHOST "tinyproxy.stats"
|
|
||||||
#endif])
|
|
||||||
AC_ARG_WITH(stathost,
|
AC_ARG_WITH(stathost,
|
||||||
[AC_HELP_STRING([--with-stathost=HOST], [Default status host])],
|
[AC_HELP_STRING([--with-stathost=HOST], [Default status host])],
|
||||||
[AC_DEFINE_UNQUOTED(DEFAULT_STATHOST, ["$withval"])])
|
[AC_DEFINE_UNQUOTED(DEFAULT_STATHOST, "$withval")],
|
||||||
|
[AC_DEFINE_UNQUOTED(DEFAULT_STATHOST, "tinyproxy.stats")])
|
||||||
|
|
||||||
dnl Set the default configuration file location
|
dnl Set the default configuration file location
|
||||||
AH_VERBATIM([DEFAULT_CONF_FILE],
|
test "$prefix" = "NONE" && prefix=/usr/local
|
||||||
[/* This is the default location of the configuation file. */
|
|
||||||
#ifndef DEFAULT_CONF_FILE
|
AH_TEMPLATE([DEFAULT_CONF_FILE],
|
||||||
# define DEFAULT_CONF_FILE "/etc/tinyproxy/tinyproxy.conf"
|
[This is the default file name for the configuration file.])
|
||||||
#endif])
|
|
||||||
AC_ARG_WITH(config,
|
AC_ARG_WITH(config,
|
||||||
[AC_HELP_STRING([--with-config=FILE],
|
[AC_HELP_STRING([--with-config=FILE],
|
||||||
[Set the default location of the config file])],
|
[Set the default location of the config file])],
|
||||||
[AC_DEFINE_UNQUOTED(DEFAULT_CONF_FILE, ["$withval"])])
|
[tp_config_file="$withval"],
|
||||||
|
[tp_config_file="tinyproxy.conf"])
|
||||||
|
|
||||||
|
# If the first character is a slash, it's an absolute path
|
||||||
|
if [[ `echo $tp_config_file | cut -c1` = "/" ]]; then
|
||||||
|
TINYPROXY_CONFIG_DIR=`echo "$tp_config_file" | sed 's/^\(.*\)\/[[^\/]]*$/\1/'`
|
||||||
|
TINYPROXY_CONFIG_FILE=`echo "$tp_config_file" | sed 's/^.*\/\([[^\/]]*\)$/\1/'`
|
||||||
|
else
|
||||||
|
# If sysconfdir is /usr/etc, change it to /etc (since /usr/etc doesn't exist)
|
||||||
|
if [[ "/usr/etc" = `eval echo $sysconfdir` -a "/usr" = "$prefix" ]]; then
|
||||||
|
TINYPROXY_CONFIG_DIR="/etc/tinyproxy"
|
||||||
|
else
|
||||||
|
TINYPROXY_CONFIG_DIR=`eval echo $sysconfdir/tinyproxy`
|
||||||
|
fi
|
||||||
|
TINYPROXY_CONFIG_FILE="$tp_config_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_SUBST(TINYPROXY_CONFIG_DIR)
|
||||||
|
AC_SUBST(TINYPROXY_CONFIG_FILE)
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(DEFAULT_CONF_FILE, "$TINYPROXY_CONFIG_DIR/$TINYPROXY_CONFIG_FILE")
|
||||||
|
|
||||||
|
AC_MSG_NOTICE([Default config location and file is: $TINYPROXY_CONFIG_DIR/$TINYPROXY_CONFIG_FILE])
|
||||||
|
|
||||||
dnl Add compiler-specific optimization flags
|
dnl Add compiler-specific optimization flags
|
||||||
AC_ARG_ENABLE(debug,
|
AC_ARG_ENABLE(debug,
|
||||||
@@ -142,8 +159,6 @@ dnl
|
|||||||
dnl Checks for programs
|
dnl Checks for programs
|
||||||
dnl
|
dnl
|
||||||
|
|
||||||
dnl Save $CFLAGS since AC_PROG_CC likes to insert "-g -O2"
|
|
||||||
dnl if $CFLAGS is blank
|
|
||||||
cflags_save="$CFLAGS"
|
cflags_save="$CFLAGS"
|
||||||
|
|
||||||
AC_PROG_AWK
|
AC_PROG_AWK
|
||||||
@@ -155,9 +170,7 @@ AC_PROG_LN_S
|
|||||||
AM_PROG_LEX
|
AM_PROG_LEX
|
||||||
AC_PROG_YACC
|
AC_PROG_YACC
|
||||||
|
|
||||||
dnl Restore the CFLAGS and add the -D_REENTRANT define since threading is
|
CFLAGS="$cflags_save"
|
||||||
dnl in use.
|
|
||||||
CFLAGS="$cflags_save -D_REENTRANT"
|
|
||||||
|
|
||||||
dnl Make sure YACC is actually bison
|
dnl Make sure YACC is actually bison
|
||||||
if test x"$YACC" != x"bison -y"; then
|
if test x"$YACC" != x"bison -y"; then
|
||||||
@@ -263,7 +276,6 @@ if test x"$profiling_enabled" = x"yes" ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Enable the debugging flags (by checking for the GCC compiler)
|
dnl Enable the debugging flags (by checking for the GCC compiler)
|
||||||
CFLAGS="-O2 $CFLAGS"
|
|
||||||
if test x"$debug_enabled" = x"yes" ; then
|
if test x"$debug_enabled" = x"yes" ; then
|
||||||
dnl Add the warnings if we have the GCC compiler
|
dnl Add the warnings if we have the GCC compiler
|
||||||
if test x"$GCC" = x"yes" ; then
|
if test x"$GCC" = x"yes" ; then
|
||||||
@@ -278,7 +290,7 @@ if test x"$debug_enabled" = x"yes" ; then
|
|||||||
YFLAGS="-v -d"
|
YFLAGS="-v -d"
|
||||||
else
|
else
|
||||||
dnl No debugging information, include the optimizations
|
dnl No debugging information, include the optimizations
|
||||||
CFLAGS="-DNDEBUG $CFLAGS"
|
CFLAGS="-O2 -DNDEBUG $CFLAGS"
|
||||||
YFLAGS="-d"
|
YFLAGS="-d"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
# $Id: Makefile.am,v 1.11 2002-04-10 21:51:01 rjkaes Exp $
|
# $Id: Makefile.am,v 1.12 2002-05-02 17:34:58 rjkaes Exp $
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
YFLAGS = @YFLAGS@
|
YFLAGS = @YFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
|
|
||||||
bin_PROGRAMS = tinyproxy
|
sbin_PROGRAMS = tinyproxy
|
||||||
|
|
||||||
tinyproxy_SOURCES = \
|
tinyproxy_SOURCES = \
|
||||||
acl.c acl.h \
|
acl.c acl.h \
|
||||||
|
|||||||
+72
-23
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: reqs.c,v 1.68 2002-04-26 16:43:20 rjkaes Exp $
|
/* $Id: reqs.c,v 1.71 2002-05-08 03:29:23 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* This is where all the work in tinyproxy is actually done. Incoming
|
* This is where all the work in tinyproxy is actually done. Incoming
|
||||||
* connections have a new thread created for them. The thread then
|
* connections have a new thread created for them. The thread then
|
||||||
@@ -108,7 +108,6 @@ static int
|
|||||||
check_allowed_connect_ports(int port)
|
check_allowed_connect_ports(int port)
|
||||||
{
|
{
|
||||||
ssize_t i;
|
ssize_t i;
|
||||||
ssize_t ret;
|
|
||||||
int *data;
|
int *data;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -119,8 +118,7 @@ check_allowed_connect_ports(int port)
|
|||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i < vector_length(ports_allowed_by_connect); ++i) {
|
for (i = 0; i < vector_length(ports_allowed_by_connect); ++i) {
|
||||||
ret = vector_getentry(ports_allowed_by_connect, i, (void **)&data);
|
if (vector_getentry(ports_allowed_by_connect, i, (void **)&data) < 0)
|
||||||
if (ret < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (*data == port)
|
if (*data == port)
|
||||||
@@ -655,13 +653,14 @@ get_content_length(hashmap_t hashofheaders)
|
|||||||
* FIXME: Need to add code to "hide" our internal information for security
|
* FIXME: Need to add code to "hide" our internal information for security
|
||||||
* purposes.
|
* purposes.
|
||||||
*/
|
*/
|
||||||
static void
|
static int
|
||||||
write_via_header(int fd, hashmap_t hashofheaders,
|
write_via_header(int fd, hashmap_t hashofheaders,
|
||||||
unsigned int major, unsigned int minor)
|
unsigned int major, unsigned int minor)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
char hostname[128];
|
char hostname[128];
|
||||||
char *data;
|
char *data;
|
||||||
|
int ret;
|
||||||
|
|
||||||
gethostname(hostname, sizeof(hostname));
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
|
||||||
@@ -671,7 +670,7 @@ write_via_header(int fd, hashmap_t hashofheaders,
|
|||||||
*/
|
*/
|
||||||
len = hashmap_entry_by_key(hashofheaders, "via", (void **)&data);
|
len = hashmap_entry_by_key(hashofheaders, "via", (void **)&data);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
write_message(fd,
|
ret = write_message(fd,
|
||||||
"Via: %s, %hu.%hu %s (%s/%s)\r\n",
|
"Via: %s, %hu.%hu %s (%s/%s)\r\n",
|
||||||
data,
|
data,
|
||||||
major, minor,
|
major, minor,
|
||||||
@@ -679,11 +678,13 @@ write_via_header(int fd, hashmap_t hashofheaders,
|
|||||||
|
|
||||||
hashmap_remove(hashofheaders, "via");
|
hashmap_remove(hashofheaders, "via");
|
||||||
} else {
|
} else {
|
||||||
write_message(fd,
|
ret = write_message(fd,
|
||||||
"Via: %hu.%hu %s (%s/%s)\r\n",
|
"Via: %hu.%hu %s (%s/%s)\r\n",
|
||||||
major, minor,
|
major, minor,
|
||||||
hostname, PACKAGE, VERSION);
|
hostname, PACKAGE, VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -714,6 +715,7 @@ process_client_headers(struct conn_s *connptr)
|
|||||||
hashmap_t hashofheaders;
|
hashmap_t hashofheaders;
|
||||||
hashmap_iter iter;
|
hashmap_iter iter;
|
||||||
long content_length = -1;
|
long content_length = -1;
|
||||||
|
int ret;
|
||||||
|
|
||||||
char *data, *header;
|
char *data, *header;
|
||||||
|
|
||||||
@@ -726,9 +728,7 @@ process_client_headers(struct conn_s *connptr)
|
|||||||
*/
|
*/
|
||||||
if (get_all_headers(connptr->client_fd, hashofheaders) < 0) {
|
if (get_all_headers(connptr->client_fd, hashofheaders) < 0) {
|
||||||
log_message(LOG_WARNING, "Could not retrieve all the headers from the client");
|
log_message(LOG_WARNING, "Could not retrieve all the headers from the client");
|
||||||
|
goto ERROR_EXIT;
|
||||||
hashmap_delete(hashofheaders);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -763,8 +763,14 @@ process_client_headers(struct conn_s *connptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send, or add the Via header */
|
/* Send, or add the Via header */
|
||||||
write_via_header(connptr->server_fd, hashofheaders,
|
ret = write_via_header(connptr->server_fd, hashofheaders,
|
||||||
connptr->protocol.major, connptr->protocol.minor);
|
connptr->protocol.major,
|
||||||
|
connptr->protocol.minor);
|
||||||
|
if (ret < 0) {
|
||||||
|
indicate_http_error(connptr, 503,
|
||||||
|
"Could not send data to remote server.");
|
||||||
|
goto PULL_CLIENT_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Output all the remaining headers to the remote machine.
|
* Output all the remaining headers to the remote machine.
|
||||||
@@ -778,15 +784,18 @@ process_client_headers(struct conn_s *connptr)
|
|||||||
(void**)&header);
|
(void**)&header);
|
||||||
|
|
||||||
if (!is_anonymous_enabled() || anonymous_search(data) <= 0) {
|
if (!is_anonymous_enabled() || anonymous_search(data) <= 0) {
|
||||||
write_message(connptr->server_fd,
|
ret = write_message(connptr->server_fd,
|
||||||
"%s: %s\r\n",
|
"%s: %s\r\n",
|
||||||
data, header);
|
data, header);
|
||||||
|
if (ret < 0) {
|
||||||
|
indicate_http_error(connptr,
|
||||||
|
503,
|
||||||
|
"Could not send data to remove server.");
|
||||||
|
goto PULL_CLIENT_DATA;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the hashofheaders since it's no longer needed */
|
|
||||||
hashmap_delete(hashofheaders);
|
|
||||||
|
|
||||||
#if defined(XTINYPROXY_ENABLE)
|
#if defined(XTINYPROXY_ENABLE)
|
||||||
if (config.my_domain)
|
if (config.my_domain)
|
||||||
@@ -794,16 +803,24 @@ process_client_headers(struct conn_s *connptr)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Write the final "blank" line to signify the end of the headers */
|
/* Write the final "blank" line to signify the end of the headers */
|
||||||
safe_write(connptr->server_fd, "\r\n", 2);
|
if (safe_write(connptr->server_fd, "\r\n", 2) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Spin here pulling the data from the client.
|
* Spin here pulling the data from the client.
|
||||||
*/
|
*/
|
||||||
|
PULL_CLIENT_DATA:
|
||||||
|
hashmap_delete(hashofheaders);
|
||||||
|
|
||||||
if (content_length > 0)
|
if (content_length > 0)
|
||||||
return pull_client_data(connptr,
|
return pull_client_data(connptr,
|
||||||
(unsigned long int) content_length);
|
(unsigned long int) content_length);
|
||||||
else
|
else
|
||||||
return 0;
|
return ret;
|
||||||
|
|
||||||
|
ERROR_EXIT:
|
||||||
|
hashmap_delete(hashofheaders);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -827,6 +844,7 @@ process_server_headers(struct conn_s *connptr)
|
|||||||
char *data, *header;
|
char *data, *header;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* FIXME: Remember to handle a "simple_req" type */
|
/* FIXME: Remember to handle a "simple_req" type */
|
||||||
|
|
||||||
@@ -847,12 +865,16 @@ process_server_headers(struct conn_s *connptr)
|
|||||||
log_message(LOG_WARNING, "Could not retrieve all the headers from the remote server.");
|
log_message(LOG_WARNING, "Could not retrieve all the headers from the remote server.");
|
||||||
hashmap_delete(hashofheaders);
|
hashmap_delete(hashofheaders);
|
||||||
safefree(response_line);
|
safefree(response_line);
|
||||||
|
|
||||||
|
indicate_http_error(connptr, 503, "Could not retrieve all the headers from the remote server.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send the saved response line first */
|
/* Send the saved response line first */
|
||||||
safe_write(connptr->client_fd, response_line, strlen(response_line));
|
ret = safe_write(connptr->client_fd, response_line, strlen(response_line));
|
||||||
safefree(response_line);
|
safefree(response_line);
|
||||||
|
if (ret < 0)
|
||||||
|
goto ERROR_EXIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there is a "Content-Length" header, retrieve the information
|
* If there is a "Content-Length" header, retrieve the information
|
||||||
@@ -874,8 +896,10 @@ process_server_headers(struct conn_s *connptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Send, or add the Via header */
|
/* Send, or add the Via header */
|
||||||
write_via_header(connptr->client_fd, hashofheaders,
|
ret = write_via_header(connptr->client_fd, hashofheaders,
|
||||||
connptr->protocol.major, connptr->protocol.minor);
|
connptr->protocol.major, connptr->protocol.minor);
|
||||||
|
if (ret < 0)
|
||||||
|
goto ERROR_EXIT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Okay, output all the remaining headers to the client.
|
* Okay, output all the remaining headers to the client.
|
||||||
@@ -888,17 +912,24 @@ process_server_headers(struct conn_s *connptr)
|
|||||||
&data,
|
&data,
|
||||||
(void **)&header);
|
(void **)&header);
|
||||||
|
|
||||||
write_message(connptr->client_fd,
|
ret = write_message(connptr->client_fd,
|
||||||
"%s: %s\r\n",
|
"%s: %s\r\n",
|
||||||
data, header);
|
data, header);
|
||||||
|
if (ret < 0)
|
||||||
|
goto ERROR_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hashmap_delete(hashofheaders);
|
hashmap_delete(hashofheaders);
|
||||||
|
|
||||||
/* Write the final blank line to signify the end of the headers */
|
/* Write the final blank line to signify the end of the headers */
|
||||||
safe_write(connptr->client_fd, "\r\n", 2);
|
if (safe_write(connptr->client_fd, "\r\n", 2) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
ERROR_EXIT:
|
||||||
|
hashmap_delete(hashofheaders);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1076,8 +1107,21 @@ connect_to_upstream(struct conn_s *connptr, struct request_s *request)
|
|||||||
static int
|
static int
|
||||||
connect_to_tunnel(struct conn_s *connptr)
|
connect_to_tunnel(struct conn_s *connptr)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/*
|
||||||
|
* NOTE: This must be fixed
|
||||||
|
*
|
||||||
|
* Needed to remove this for right now since it breaks the semantics
|
||||||
|
* of the "tunnel" concept since the information from the remote host
|
||||||
|
* wasn't being sent until _after_ data was sent by the client. This
|
||||||
|
* is not correct since we should be sending the data regardless of
|
||||||
|
* who sent it first.
|
||||||
|
*
|
||||||
|
* I'll have to look into this for the next release.
|
||||||
|
*/
|
||||||
char *request_buf;
|
char *request_buf;
|
||||||
size_t len;
|
ssize_t len;
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
request_buf = safemalloc(HTTP_LINE_LENGTH);
|
request_buf = safemalloc(HTTP_LINE_LENGTH);
|
||||||
@@ -1091,6 +1135,8 @@ connect_to_tunnel(struct conn_s *connptr)
|
|||||||
|
|
||||||
safefree(request_buf);
|
safefree(request_buf);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
log_message(LOG_INFO, "Redirecting to %s:%d",
|
log_message(LOG_INFO, "Redirecting to %s:%d",
|
||||||
config.tunnel_name, config.tunnel_port);
|
config.tunnel_name, config.tunnel_port);
|
||||||
|
|
||||||
@@ -1214,6 +1260,9 @@ handle_connection(int fd)
|
|||||||
|
|
||||||
if (!connptr->connect_method || UPSTREAM_CONFIGURED()) {
|
if (!connptr->connect_method || UPSTREAM_CONFIGURED()) {
|
||||||
if (process_server_headers(connptr) < 0) {
|
if (process_server_headers(connptr) < 0) {
|
||||||
|
if (connptr->error_string)
|
||||||
|
send_http_error_message(connptr);
|
||||||
|
|
||||||
update_stats(STAT_BADCONN);
|
update_stats(STAT_BADCONN);
|
||||||
destroy_conn(connptr);
|
destroy_conn(connptr);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+60
-43
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: thread.c,v 1.26 2002-04-22 19:41:17 rjkaes Exp $
|
/* $Id: thread.c,v 1.29 2002-04-28 18:32:16 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Handles the creation/destruction of the various threads required for
|
* Handles the creation/destruction of the various threads required for
|
||||||
* processing incoming connections.
|
* processing incoming connections.
|
||||||
@@ -66,7 +66,7 @@ static struct thread_config_s {
|
|||||||
unsigned int maxspareservers, minspareservers, startservers;
|
unsigned int maxspareservers, minspareservers, startservers;
|
||||||
} thread_config;
|
} thread_config;
|
||||||
|
|
||||||
static unsigned int servers_waiting; /* servers waiting for a connection */
|
static int servers_waiting = 0; /* servers waiting for a connection */
|
||||||
static pthread_mutex_t servers_mutex;
|
static pthread_mutex_t servers_mutex;
|
||||||
|
|
||||||
#define SERVER_COUNT_LOCK() do { \
|
#define SERVER_COUNT_LOCK() do { \
|
||||||
@@ -80,15 +80,15 @@ assert(servers_mutex_ret == 0); \
|
|||||||
|
|
||||||
#define SERVER_INC() do { \
|
#define SERVER_INC() do { \
|
||||||
SERVER_COUNT_LOCK(); \
|
SERVER_COUNT_LOCK(); \
|
||||||
DEBUG2("INC: servers_waiting: %u", servers_waiting); \
|
|
||||||
++servers_waiting; \
|
++servers_waiting; \
|
||||||
|
DEBUG2("INC: servers_waiting: %d", servers_waiting); \
|
||||||
SERVER_COUNT_UNLOCK(); \
|
SERVER_COUNT_UNLOCK(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SERVER_DEC() do { \
|
#define SERVER_DEC() do { \
|
||||||
SERVER_COUNT_LOCK(); \
|
SERVER_COUNT_LOCK(); \
|
||||||
--servers_waiting; \
|
--servers_waiting; \
|
||||||
DEBUG2("DEC: servers_waiting: %u", servers_waiting); \
|
DEBUG2("DEC: servers_waiting: %d", servers_waiting); \
|
||||||
SERVER_COUNT_UNLOCK(); \
|
SERVER_COUNT_UNLOCK(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -144,7 +144,11 @@ thread_main(void *arg)
|
|||||||
if (!cliaddr)
|
if (!cliaddr)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
ptr->connects = 0;
|
||||||
|
|
||||||
while (!config.quit) {
|
while (!config.quit) {
|
||||||
|
ptr->status = T_WAITING;
|
||||||
|
|
||||||
clilen = addrlen;
|
clilen = addrlen;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -190,34 +194,31 @@ thread_main(void *arg)
|
|||||||
ptr->connects,
|
ptr->connects,
|
||||||
thread_config.maxrequestsperchild);
|
thread_config.maxrequestsperchild);
|
||||||
|
|
||||||
ptr->status = T_EMPTY;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SERVER_COUNT_LOCK();
|
SERVER_COUNT_LOCK();
|
||||||
if (servers_waiting >= thread_config.maxspareservers) {
|
if (servers_waiting > thread_config.maxspareservers) {
|
||||||
/*
|
/*
|
||||||
* There are too many spare threads, kill ourself
|
* There are too many spare threads, kill ourself
|
||||||
* off.
|
* off.
|
||||||
*/
|
*/
|
||||||
SERVER_COUNT_UNLOCK();
|
|
||||||
|
|
||||||
log_message(LOG_NOTICE,
|
log_message(LOG_NOTICE,
|
||||||
"Waiting servers exceeds MaxSpareServers. Killing thread.");
|
"Waiting servers (%d) exceeds MaxSpareServers (%d). Killing thread.",
|
||||||
|
servers_waiting, thread_config.maxspareservers);
|
||||||
ptr->status = T_EMPTY;
|
SERVER_COUNT_UNLOCK();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
} else {
|
||||||
SERVER_COUNT_UNLOCK();
|
SERVER_COUNT_UNLOCK();
|
||||||
|
}
|
||||||
ptr->status = T_WAITING;
|
|
||||||
|
|
||||||
SERVER_INC();
|
SERVER_INC();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ptr->status = T_EMPTY;
|
||||||
|
|
||||||
safefree(cliaddr);
|
safefree(cliaddr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -230,7 +231,9 @@ thread_pool_create(void)
|
|||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int pthread_ret;
|
int pthread_ret;
|
||||||
// pthread_mutexattr_t mutexattr;
|
#if 0
|
||||||
|
pthread_mutexattr_t mutexattr;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize thread_attr to contain a non-default stack size
|
* Initialize thread_attr to contain a non-default stack size
|
||||||
@@ -242,7 +245,9 @@ thread_pool_create(void)
|
|||||||
pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
|
||||||
pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE);
|
pthread_attr_setstacksize(&thread_attr, THREAD_STACK_SIZE);
|
||||||
|
|
||||||
// pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK);
|
#if 0
|
||||||
|
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_ERRORCHECK);
|
||||||
|
#endif
|
||||||
pthread_mutex_init(&mlock, NULL);
|
pthread_mutex_init(&mlock, NULL);
|
||||||
pthread_mutex_init(&servers_mutex, NULL);
|
pthread_mutex_init(&servers_mutex, NULL);
|
||||||
|
|
||||||
@@ -257,11 +262,12 @@ thread_pool_create(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_ptr =
|
thread_ptr = safecalloc((size_t) thread_config.maxclients,
|
||||||
safecalloc((size_t) thread_config.maxclients,
|
|
||||||
sizeof(struct thread_s));
|
sizeof(struct thread_s));
|
||||||
if (!thread_ptr)
|
if (!thread_ptr) {
|
||||||
|
log_message(LOG_ERR, "Could not allocate memory for threads.");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (thread_config.startservers > thread_config.maxclients) {
|
if (thread_config.startservers > thread_config.maxclients) {
|
||||||
log_message(LOG_WARNING,
|
log_message(LOG_WARNING,
|
||||||
@@ -270,24 +276,33 @@ thread_pool_create(void)
|
|||||||
thread_config.startservers = thread_config.maxclients;
|
thread_config.startservers = thread_config.maxclients;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < thread_config.startservers; i++) {
|
for (i = 0; i < thread_config.maxclients; i++) {
|
||||||
pthread_ret = pthread_create(&thread_ptr[i].tid, &thread_attr,
|
|
||||||
&thread_main, &thread_ptr[i]);
|
|
||||||
if (pthread_ret < 0) {
|
|
||||||
log_message(LOG_WARNING, "Could not create thread number %d of %d: %s",
|
|
||||||
i, thread_config.startservers, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
} else {
|
|
||||||
thread_ptr[i].status = T_WAITING;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
servers_waiting = thread_config.startservers;
|
|
||||||
|
|
||||||
for (i = thread_config.startservers; i < thread_config.maxclients; i++) {
|
|
||||||
thread_ptr[i].status = T_EMPTY;
|
thread_ptr[i].status = T_EMPTY;
|
||||||
thread_ptr[i].connects = 0;
|
thread_ptr[i].connects = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < thread_config.startservers; i++) {
|
||||||
|
DEBUG2("Trying to create thread %d of %d", i + 1, thread_config.startservers);
|
||||||
|
thread_ptr[i].status = T_WAITING;
|
||||||
|
pthread_ret = pthread_create(&thread_ptr[i].tid, &thread_attr,
|
||||||
|
&thread_main, &thread_ptr[i]);
|
||||||
|
if (pthread_ret != 0) {
|
||||||
|
log_message(LOG_WARNING,
|
||||||
|
"Could not create thread number %d of %d: %s",
|
||||||
|
i, thread_config.startservers,
|
||||||
|
strerror(pthread_ret));
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
log_message(LOG_INFO,
|
||||||
|
"Creating thread number %d of %d ...",
|
||||||
|
i + 1, thread_config.startservers);
|
||||||
|
|
||||||
|
SERVER_INC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log_message(LOG_INFO, "Finished creating all threads.");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,34 +323,36 @@ thread_main_loop(void)
|
|||||||
/* If there are not enough spare servers, create more */
|
/* If there are not enough spare servers, create more */
|
||||||
SERVER_COUNT_LOCK();
|
SERVER_COUNT_LOCK();
|
||||||
if (servers_waiting < thread_config.minspareservers) {
|
if (servers_waiting < thread_config.minspareservers) {
|
||||||
|
log_message(LOG_NOTICE,
|
||||||
|
"Waiting servers (%d) is less than MinSpareServers (%d). Creating new thread.",
|
||||||
|
servers_waiting, thread_config.minspareservers);
|
||||||
|
|
||||||
SERVER_COUNT_UNLOCK();
|
SERVER_COUNT_UNLOCK();
|
||||||
|
|
||||||
for (i = 0; i < thread_config.maxclients; i++) {
|
for (i = 0; i < thread_config.maxclients; i++) {
|
||||||
if (thread_ptr[i].status == T_EMPTY) {
|
if (thread_ptr[i].status == T_EMPTY) {
|
||||||
|
thread_ptr[i].status = T_WAITING;
|
||||||
pthread_ret = pthread_create(&thread_ptr[i].tid,
|
pthread_ret = pthread_create(&thread_ptr[i].tid,
|
||||||
&thread_attr,
|
&thread_attr,
|
||||||
&thread_main,
|
&thread_main,
|
||||||
&thread_ptr[i]);
|
&thread_ptr[i]);
|
||||||
if (pthread_ret < 0) {
|
if (pthread_ret != 0) {
|
||||||
log_message(LOG_NOTICE,
|
log_message(LOG_NOTICE,
|
||||||
"Could not create thread: %s",
|
"Could not create thread: %s",
|
||||||
strerror(errno));
|
strerror(pthread_ret));
|
||||||
|
|
||||||
|
thread_ptr[i].status = T_EMPTY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_ptr[i].status = T_WAITING;
|
|
||||||
thread_ptr[i].connects = 0;
|
|
||||||
|
|
||||||
SERVER_INC();
|
SERVER_INC();
|
||||||
|
|
||||||
log_message(LOG_NOTICE,
|
|
||||||
"Waiting servers is less than MinSpareServers. Creating new thread.");
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
SERVER_COUNT_UNLOCK();
|
SERVER_COUNT_UNLOCK();
|
||||||
|
}
|
||||||
|
|
||||||
sleep(5);
|
sleep(5);
|
||||||
|
|
||||||
|
|||||||
+5
-4
@@ -1,4 +1,4 @@
|
|||||||
/* $Id: utils.c,v 1.28 2002-04-18 17:59:21 rjkaes Exp $
|
/* $Id: utils.c,v 1.29 2002-04-28 20:03:53 rjkaes Exp $
|
||||||
*
|
*
|
||||||
* Misc. routines which are used by the various functions to handle strings
|
* Misc. routines which are used by the various functions to handle strings
|
||||||
* and memory allocation and pretty much anything else we can think of. Also,
|
* and memory allocation and pretty much anything else we can think of. Also,
|
||||||
@@ -129,10 +129,11 @@ send_http_message(struct conn_s *connptr, int http_code,
|
|||||||
strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
strftime(timebuf, sizeof(timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
||||||
gmtime(&global_time));
|
gmtime(&global_time));
|
||||||
|
|
||||||
write_message(connptr->client_fd,
|
if (write_message(connptr->client_fd,
|
||||||
headers,
|
headers,
|
||||||
http_code, error_title, PACKAGE, VERSION, timebuf,
|
http_code, error_title, PACKAGE, VERSION,
|
||||||
message_len);
|
timebuf, message_len) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return safe_write(connptr->client_fd, message, message_len);
|
return safe_write(connptr->client_fd, message, message_len);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user