X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Flog-file.c;h=1ef69a14456ff4a64828266ed9e220a75fa81e02;hb=4adf195fb2f36dfbd054745469fa1c580de2f61b;hp=c6575cc42f726d3f4b1870315aea423fa8e74acc;hpb=f14ddc51661615c9f9daa70f1ef8f3abe0e2be37;p=libucw.git diff --git a/lib/log-file.c b/lib/log-file.c index c6575cc4..1ef69a14 100644 --- a/lib/log-file.c +++ b/lib/log-file.c @@ -1,13 +1,15 @@ /* * UCW Library -- Keeping of Log Files * - * (c) 1997--2005 Martin Mares + * (c) 1997--2006 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. */ #include "lib/lib.h" +#include "lib/lfs.h" +#include "lib/threads.h" #include #include @@ -30,6 +32,7 @@ do_log_switch(struct tm *tm) if (!log_name_patt || log_filename[0] && !log_params) return 0; + ucwlib_lock(); log_switch_nest++; l = strftime(name, log_filename_size, log_name_patt, tm); if (l < 0 || l >= log_filename_size) @@ -37,7 +40,7 @@ do_log_switch(struct tm *tm) if (strcmp(name, log_filename)) { strcpy(log_filename, name); - fd = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666); + fd = sh_open(name, O_WRONLY | O_CREAT | O_APPEND, 0666); if (fd < 0) die("Unable to open log file %s: %m", name); close(2); @@ -48,6 +51,7 @@ do_log_switch(struct tm *tm) switched = 1; } log_switch_nest--; + ucwlib_unlock(); return switched; }