diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-16 05:38:27 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2001-09-16 05:38:27 +0000 |
commit | 4619035cd285d913ad22da19567671b34b72c286 (patch) | |
tree | 36fcd68f65693471f1d052721b7454c41af2869b | |
parent | 8df2fba997d6baef51ccd0126f9d3f347f866ce6 (diff) | |
download | tinyproxy-4619035cd285d913ad22da19567671b34b72c286.tar.gz tinyproxy-4619035cd285d913ad22da19567671b34b72c286.zip |
Fixed a problem where log messages could be missed during a rotate.
-rw-r--r-- | src/tinyproxy.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/tinyproxy.c b/src/tinyproxy.c index 279807b..d350bbd 100644 --- a/src/tinyproxy.c +++ b/src/tinyproxy.c @@ -1,4 +1,4 @@ -/* $Id: tinyproxy.c,v 1.15 2001-09-15 21:29:22 rjkaes Exp $ +/* $Id: tinyproxy.c,v 1.16 2001-09-16 05:38:27 rjkaes Exp $ * * The initialise routine. Basically sets up all the initial stuff (logfile, * listening socket, config options, etc.) and then sits there and loops @@ -66,7 +66,8 @@ void takesig(int sig) if (config.logf) { char *rename_file; - int log_file_fd; + int log_file_des; + FILE *old_fd; rename_file = safemalloc(strlen(config.logf_name) + 5); if (!rename_file) { @@ -79,18 +80,21 @@ void takesig(int sig) rename(config.logf_name, rename_file); - log_file_fd = create_file_safely(config.logf_name); - if (log_file_fd < 0) { + log_file_des = create_file_safely(config.logf_name); + if (log_file_des < 0) { fprintf(stderr, "Could not safely create new log file.\n"); exit(EX_OSERR); } + + old_fd = config.logf; - fclose(config.logf); - if (!(config.logf = fdopen(log_file_fd, "w"))) { + if (!(config.logf = fdopen(log_file_des, "w"))) { fprintf(stderr, "Could not create new log file.\n"); exit(EX_CANTCREAT); } + fclose(old_fd); + log_message(LOG_NOTICE, "Log file rotated."); safefree(rename_file); |