Compare commits

..
8 Commits
Author SHA1 Message Date
cvs2svn 52f5c926a8 This commit was manufactured by cvs2svn to create tag 'rel_1_5_1rc2'. 2002-06-18 20:10:24 +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 67 additions and 114 deletions

No files matched your search

+31
View File
@@ -1,3 +1,34 @@
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>
* 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.40 2002-06-18 20:08:36 rjkaes Exp $
dnl Devlopers, please strive to achieve this order:
dnl
@@ -14,7 +14,7 @@ dnl 8. System services
dnl
dnl Read the Autoconf manual for details.
AC_INIT([tinyproxy], [1.5.1pre6], [rjkaes@users.sourceforge.net])
AC_INIT([tinyproxy], [1.5.1rc2], [rjkaes@users.sourceforge.net])
AC_CONFIG_SRCDIR([src/tinyproxy.c])
AC_PREREQ(2.52)
+12 -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.4 2002-06-15 17:31:31 rjkaes Exp $
*
* Handles the creation/destruction of the various children required for
* processing incoming connections.
@@ -19,6 +19,7 @@
#include "tinyproxy.h"
#include "child.h"
#include "filter.h"
#include "heap.h"
#include "log.h"
#include "reqs.h"
@@ -372,9 +373,16 @@ child_main_loop(void)
sleep(5);
/* Handle log rotation if it was requested */
if (log_rotation_request) {
rotate_log_files();
log_rotation_request = FALSE;
if (received_sighup) {
#ifdef FILTER_ENABLE
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
* the syslog daemon. Not much to it...
@@ -22,6 +22,7 @@
#include "hashmap.h"
#include "heap.h"
#include "log.h"
#include "utils.h"
static char *syslog_level[] = {
NULL,
@@ -68,7 +69,6 @@ log_message(int level, char *fmt, ...)
{
va_list args;
time_t nowtime;
FILE *cf;
char time_string[TIME_LENGTH];
#if defined(HAVE_SYSLOG_H) && !defined(HAVE_VSYSLOG_H)
@@ -130,19 +130,23 @@ log_message(int level, char *fmt, ...)
# endif
} else {
#endif
FILE* log_file;
int fd;
fd = create_file_safely(config.logf_name, FALSE);
log_file = fdopen(fd, "w+");
nowtime = time(NULL);
/* Format is month day hour:minute:second (24 time) */
strftime(time_string, TIME_LENGTH, "%b %d %H:%M:%S",
localtime(&nowtime));
if (!(cf = config.logf))
cf = stderr;
fprintf(cf, "%-9s %s [%ld]: ", syslog_level[level],
fprintf(log_file, "%-9s %s [%ld]: ", syslog_level[level],
time_string, (long int) getpid());
vfprintf(cf, fmt, args);
fprintf(cf, "\n");
fflush(cf);
vfprintf(log_file, fmt, args);
fprintf(log_file, "\n");
fclose(log_file);
#ifdef HAVE_SYSLOG_H
}
#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,
* listening socket, config options, etc.) and then sits there and loops
@@ -46,7 +46,7 @@ extern FILE *yyin;
*/
struct config_s config;
float load = 0.00;
bool_t log_rotation_request = FALSE;
bool_t received_sighup = FALSE;
bool_t processed_config_file = FALSE;
/*
@@ -60,7 +60,7 @@ takesig(int sig)
switch (sig) {
case SIGHUP:
log_rotation_request = TRUE;
received_sighup = TRUE;
break;
case SIGTERM:
@@ -211,7 +211,6 @@ main(int argc, char **argv)
exit(EX_SOFTWARE);
}
yyparse();
processed_config_file = TRUE;
#if defined(TUNNEL_SUPPORT) && defined(UPSTREAM_SUPPORT)
if (config.tunnel_name && config.upstream_name) {
@@ -224,29 +223,12 @@ main(int argc, char **argv)
/* Open the log file if not using syslog */
if (config.syslog == FALSE) {
int log_file_fd;
if (!config.logf_name) {
fprintf(stderr,
"%s: You MUST set a LogFile in the configuration file.\n",
argv[0]);
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 {
if (godaemon == TRUE)
openlog("tinyproxy", LOG_PID, LOG_DAEMON);
@@ -254,6 +236,7 @@ main(int argc, char **argv)
openlog("tinyproxy", LOG_PID, LOG_USER);
}
processed_config_file = TRUE;
log_message(LOG_INFO, PACKAGE " " VERSION " starting...");
send_stored_logs();
@@ -422,9 +405,7 @@ main(int argc, char **argv)
filter_destroy();
#endif /* FILTER_ENABLE */
if (config.syslog == FALSE)
fclose(config.logf);
else
if (config.syslog)
closelog();
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.
*
@@ -26,7 +26,6 @@
#define MAX_IDLE_TIME (60 * 10) /* 10 minutes of no activity */
struct config_s {
FILE *logf;
char *logf_name;
bool_t syslog;
int port;
@@ -61,7 +60,7 @@ struct config_s {
/* Global Structures used in the program */
extern struct config_s config;
extern bool_t log_rotation_request;
extern bool_t received_sighup;
extern bool_t processed_config_file;
#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
* 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());
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.
*
@@ -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 int create_file_safely(const char *filename, bool_t truncate_file);
extern void rotate_log_files(void);
#endif