Compare commits

..
11 Commits
Author SHA1 Message Date
cvs2svn d8b36d2191 This commit was manufactured by cvs2svn to create tag
'release-1_5_1rc3'.
2002-06-27 16:30:54 +00:00
Robert James Kaes 96c5ee9065 Updated the ChangeLog. 2002-06-27 16:30:53 +00:00
Robert James Kaes dad3bb043a Updated the version number. 2002-06-27 16:30:38 +00:00
Robert James Kaes e50d0c4072 (child_make): Reset the various signals to the default signal handler so that the children can be properly destroyed. 2002-06-27 16:29:21 +00:00
Robert James Kaes 0a1885deb0 Updated the ChangeLog 2002-06-18 20:10:23 +00:00
Robert James Kaes cae69592be Updated the version number. 2002-06-18 20:08:36 +00:00
Robert James Kaes f0d7992765 (log_message): Changed the code so that the log is opened, written, and closed whenever a message is submitted. This allows the log file to be moved away, for example a rotating the log, and yet still have the information written to the correct file name by all the children. 2002-06-15 17:37:11 +00:00
Robert James Kaes ac5d67c11a Renamed the "log_rotation_request" boolean to "received_sighup".
(main): Removed the log file creation code because it has been moved into the log.c file.  Also, removed the explicit fclose() for the log file since it will be close when the program has exited.
2002-06-15 17:35:03 +00:00
Robert James Kaes 8a9db93977 (child_main_loop): Moved the filter re-initiation code into the loop. This code is activated whenever the SIGHUP signal is received. 2002-06-15 17:31:31 +00:00
Robert James Kaes fb688a2077 Removed the "logf" FILE structure from the config structure, and also renamed the "log_rotation_request" boolean to "received_sighup". 2002-06-15 17:29:59 +00:00
Robert James Kaes 2f84b170a6 Removed the rotate_log_files() function since I'm moving to an Apache style where the _user_ needs to move the log file themselves, and tinyproxy will continue to write to the original name. This allows more flexibility for users to determine their own log rotation scheme. 2002-06-15 17:28:19 +00:00
8 changed files with 81 additions and 114 deletions

No files matched your search

+37
View File
@@ -1,3 +1,40 @@
2002-06-27 Robert James Kaes <rjkaes@flarenet.com>
* src/child.c (child_make):
Reset the various signals to the default signal handler so that
the children can be properly destroyed.
2002-06-15 Robert James Kaes <rjkaes@flarenet.com>
* src/log.c (log_message):
Changed the code so that the log is opened, written, and closed
whenever a message is submitted. This allows the log file to be
moved away, for example a rotating the log, and yet still have the
information written to the correct file name by all the children.
* src/tinyproxy.c:
Renamed the "log_rotation_request" boolean to "received_sighup".
(main): Removed the log file creation code because it has been
moved into the log.c file. Also, removed the explicit fclose()
for the log file since it will be close when the program has
exited.
* src/child.c (child_main_loop):
Moved the filter re-initiation code into the loop. This code is
activated whenever the SIGHUP signal is received.
* src/tinyproxy.h:
Removed the "logf" FILE structure from the config structure, and
also renamed the "log_rotation_request" boolean to
"received_sighup".
* src/utils.c, src/utils.h:
Removed the rotate_log_files() function since I'm moving to an
Apache style where the _user_ needs to move the log file
themselves, and tinyproxy will continue to write to the original
name. This allows more flexibility for users to determine their
own log rotation scheme.
2002-06-07 Robert James Kaes <rjkaes@flarenet.com> 2002-06-07 Robert James Kaes <rjkaes@flarenet.com>
* src/filter.c, src/filter.h: * src/filter.c, src/filter.h:
+2 -2
View File
@@ -1,4 +1,4 @@
dnl $Id: configure.ac,v 2.39 2002-06-07 18:45:58 rjkaes Exp $ dnl $Id: configure.ac,v 2.41 2002-06-27 16:30:38 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.1pre6], [rjkaes@users.sourceforge.net]) AC_INIT([tinyproxy], [1.5.1rc3], [rjkaes@users.sourceforge.net])
AC_CONFIG_SRCDIR([src/tinyproxy.c]) AC_CONFIG_SRCDIR([src/tinyproxy.c])
AC_PREREQ(2.52) AC_PREREQ(2.52)
+20 -4
View File
@@ -1,4 +1,4 @@
/* $Id: child.c,v 1.3 2002-06-05 17:02:15 rjkaes Exp $ /* $Id: child.c,v 1.5 2002-06-27 16:29:21 rjkaes Exp $
* *
* Handles the creation/destruction of the various children required for * Handles the creation/destruction of the various children required for
* processing incoming connections. * processing incoming connections.
@@ -19,6 +19,8 @@
#include "tinyproxy.h" #include "tinyproxy.h"
#include "child.h" #include "child.h"
#include "daemon.h"
#include "filter.h"
#include "heap.h" #include "heap.h"
#include "log.h" #include "log.h"
#include "reqs.h" #include "reqs.h"
@@ -242,6 +244,13 @@ child_make(struct child_s* ptr)
if ((pid = fork()) > 0) if ((pid = fork()) > 0)
return pid; /* parent */ return pid; /* parent */
/*
* Reset the SIGNALS so that the child can be reaped.
*/
set_signal_handler(SIGCHLD, SIG_DFL);
set_signal_handler(SIGTERM, SIG_DFL);
set_signal_handler(SIGHUP, SIG_DFL);
child_main(ptr); /* never returns */ child_main(ptr); /* never returns */
return -1; return -1;
} }
@@ -372,9 +381,16 @@ child_main_loop(void)
sleep(5); sleep(5);
/* Handle log rotation if it was requested */ /* Handle log rotation if it was requested */
if (log_rotation_request) { if (received_sighup) {
rotate_log_files(); #ifdef FILTER_ENABLE
log_rotation_request = FALSE; if (config.filter) {
filter_destroy();
filter_init();
}
log_message(LOG_NOTICE, "Re-reading filter file.");
#endif /* FILTER_ENABLE */
received_sighup = FALSE;
} }
} }
} }
+13 -9
View File
@@ -1,4 +1,4 @@
/* $Id: log.c,v 1.21 2002-06-06 20:24:21 rjkaes Exp $ /* $Id: log.c,v 1.22 2002-06-15 17:37:11 rjkaes Exp $
* *
* Logs the various messages which tinyproxy produces to either a log file or * Logs the various messages which tinyproxy produces to either a log file or
* the syslog daemon. Not much to it... * the syslog daemon. Not much to it...
@@ -22,6 +22,7 @@
#include "hashmap.h" #include "hashmap.h"
#include "heap.h" #include "heap.h"
#include "log.h" #include "log.h"
#include "utils.h"
static char *syslog_level[] = { static char *syslog_level[] = {
NULL, NULL,
@@ -68,7 +69,6 @@ log_message(int level, char *fmt, ...)
{ {
va_list args; va_list args;
time_t nowtime; time_t nowtime;
FILE *cf;
char time_string[TIME_LENGTH]; char time_string[TIME_LENGTH];
#if defined(HAVE_SYSLOG_H) && !defined(HAVE_VSYSLOG_H) #if defined(HAVE_SYSLOG_H) && !defined(HAVE_VSYSLOG_H)
@@ -130,19 +130,23 @@ log_message(int level, char *fmt, ...)
# endif # endif
} else { } else {
#endif #endif
FILE* log_file;
int fd;
fd = create_file_safely(config.logf_name, FALSE);
log_file = fdopen(fd, "w+");
nowtime = time(NULL); nowtime = time(NULL);
/* Format is month day hour:minute:second (24 time) */ /* Format is month day hour:minute:second (24 time) */
strftime(time_string, TIME_LENGTH, "%b %d %H:%M:%S", strftime(time_string, TIME_LENGTH, "%b %d %H:%M:%S",
localtime(&nowtime)); localtime(&nowtime));
if (!(cf = config.logf)) fprintf(log_file, "%-9s %s [%ld]: ", syslog_level[level],
cf = stderr;
fprintf(cf, "%-9s %s [%ld]: ", syslog_level[level],
time_string, (long int) getpid()); time_string, (long int) getpid());
vfprintf(cf, fmt, args); vfprintf(log_file, fmt, args);
fprintf(cf, "\n"); fprintf(log_file, "\n");
fflush(cf);
fclose(log_file);
#ifdef HAVE_SYSLOG_H #ifdef HAVE_SYSLOG_H
} }
#endif #endif
+5 -24
View File
@@ -1,4 +1,4 @@
/* $Id: tinyproxy.c,v 1.36 2002-06-06 20:28:02 rjkaes Exp $ /* $Id: tinyproxy.c,v 1.37 2002-06-15 17:35:03 rjkaes Exp $
* *
* The initialize routine. Basically sets up all the initial stuff (logfile, * The initialize routine. Basically sets up all the initial stuff (logfile,
* listening socket, config options, etc.) and then sits there and loops * listening socket, config options, etc.) and then sits there and loops
@@ -46,7 +46,7 @@ extern FILE *yyin;
*/ */
struct config_s config; struct config_s config;
float load = 0.00; float load = 0.00;
bool_t log_rotation_request = FALSE; bool_t received_sighup = FALSE;
bool_t processed_config_file = FALSE; bool_t processed_config_file = FALSE;
/* /*
@@ -60,7 +60,7 @@ takesig(int sig)
switch (sig) { switch (sig) {
case SIGHUP: case SIGHUP:
log_rotation_request = TRUE; received_sighup = TRUE;
break; break;
case SIGTERM: case SIGTERM:
@@ -211,7 +211,6 @@ main(int argc, char **argv)
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
yyparse(); yyparse();
processed_config_file = TRUE;
#if defined(TUNNEL_SUPPORT) && defined(UPSTREAM_SUPPORT) #if defined(TUNNEL_SUPPORT) && defined(UPSTREAM_SUPPORT)
if (config.tunnel_name && config.upstream_name) { if (config.tunnel_name && config.upstream_name) {
@@ -224,29 +223,12 @@ main(int argc, char **argv)
/* Open the log file if not using syslog */ /* Open the log file if not using syslog */
if (config.syslog == FALSE) { if (config.syslog == FALSE) {
int log_file_fd;
if (!config.logf_name) { if (!config.logf_name) {
fprintf(stderr, fprintf(stderr,
"%s: You MUST set a LogFile in the configuration file.\n", "%s: You MUST set a LogFile in the configuration file.\n",
argv[0]); argv[0]);
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }
log_file_fd = create_file_safely(config.logf_name, FALSE);
if (log_file_fd < 0) {
fprintf(stderr,
"Could not safely create logfile \"%s\".\n",
config.logf_name);
exit(EX_CANTCREAT);
}
config.logf = fdopen(log_file_fd, "w+");
if (!config.logf) {
fprintf(stderr, "Could not write to log file \"%s\".\n",
config.logf_name);
exit(EX_CANTCREAT);
}
} else { } else {
if (godaemon == TRUE) if (godaemon == TRUE)
openlog("tinyproxy", LOG_PID, LOG_DAEMON); openlog("tinyproxy", LOG_PID, LOG_DAEMON);
@@ -254,6 +236,7 @@ main(int argc, char **argv)
openlog("tinyproxy", LOG_PID, LOG_USER); openlog("tinyproxy", LOG_PID, LOG_USER);
} }
processed_config_file = TRUE;
log_message(LOG_INFO, PACKAGE " " VERSION " starting..."); log_message(LOG_INFO, PACKAGE " " VERSION " starting...");
send_stored_logs(); send_stored_logs();
@@ -422,9 +405,7 @@ main(int argc, char **argv)
filter_destroy(); filter_destroy();
#endif /* FILTER_ENABLE */ #endif /* FILTER_ENABLE */
if (config.syslog == FALSE) if (config.syslog)
fclose(config.logf);
else
closelog(); closelog();
exit(EX_OK); exit(EX_OK);
+2 -3
View File
@@ -1,4 +1,4 @@
/* $Id: tinyproxy.h,v 1.32 2002-05-27 01:59:28 rjkaes Exp $ /* $Id: tinyproxy.h,v 1.33 2002-06-15 17:29:59 rjkaes Exp $
* *
* See 'tinyproxy.c' for a detailed description. * See 'tinyproxy.c' for a detailed description.
* *
@@ -26,7 +26,6 @@
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */ #define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
struct config_s { struct config_s {
FILE *logf;
char *logf_name; char *logf_name;
bool_t syslog; bool_t syslog;
int port; int port;
@@ -61,7 +60,7 @@ struct config_s {
/* Global Structures used in the program */ /* Global Structures used in the program */
extern struct config_s config; extern struct config_s config;
extern bool_t log_rotation_request; extern bool_t received_sighup;
extern bool_t processed_config_file; extern bool_t processed_config_file;
#endif #endif
+1 -69
View File
@@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.32 2002-05-31 18:26:30 rjkaes Exp $ /* $Id: utils.c,v 1.33 2002-06-15 17:28:19 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,
@@ -282,71 +282,3 @@ pidfile_create(const char *filename)
fprintf(fd, "%ld\n", (long) getpid()); fprintf(fd, "%ld\n", (long) getpid());
fclose(fd); fclose(fd);
} }
/*
* Rotate the current log file. This is performed whenever a SIGHUP is
* received.
*/
void
rotate_log_files(void)
{
char* rename_file;
int log_file_des;
FILE *old_fd;
FILE* new_fd;
log_message(LOG_NOTICE, "SIGHUP received, cleaning up.");
#ifdef FILTER_ENABLE
if (config.filter) {
filter_destroy();
filter_init();
}
log_message(LOG_NOTICE, "Re-reading filter file.");
#endif /* FILTER_ENABLE */
if (config.logf) {
rename_file = safemalloc(strlen(config.logf_name) + 5);
if (!rename_file) {
log_message(LOG_CRIT,
"Could not allocate memory when trying to rotate the log file; therefore, the log has not been rotated.");
return;
}
strcpy(rename_file, config.logf_name);
strcat(rename_file, ".rot");
rename(config.logf_name, rename_file);
log_file_des = create_file_safely(config.logf_name, TRUE);
if (log_file_des < 0) {
log_message(LOG_CRIT,
"Could not properly create the new log file; therefore the log has not been rotated.");
/* Switch the file name back */
rename(rename_file, config.logf_name);
safefree(rename_file);
return;
}
old_fd = config.logf;
if (!(new_fd = fdopen(log_file_des, "w"))) {
log_message(LOG_CRIT,
"Could not create the new log file; therefore, the log has not been rotated.");
/* Switch the file name back */
rename(rename_file, config.logf_name);
safefree(rename_file);
}
config.logf = new_fd;
fclose(old_fd);
log_message(LOG_NOTICE, "Log file rotated.");
safefree(rename_file);
}
log_message(LOG_NOTICE,
"Finished cleaning memory/connections.");
}
+1 -3
View File
@@ -1,4 +1,4 @@
/* $Id: utils.h,v 1.19 2002-05-31 18:27:13 rjkaes Exp $ /* $Id: utils.h,v 1.20 2002-06-15 17:28:19 rjkaes Exp $
* *
* See 'utils.h' for a detailed description. * See 'utils.h' for a detailed description.
* *
@@ -32,6 +32,4 @@ extern int indicate_http_error(struct conn_s* connptr, int number, const char *s
extern void pidfile_create(const char *path); extern void pidfile_create(const char *path);
extern int create_file_safely(const char *filename, bool_t truncate_file); extern int create_file_safely(const char *filename, bool_t truncate_file);
extern void rotate_log_files(void);
#endif #endif