X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fvlog.c;h=11b2f7cc4ef48be324b4f90412ff1fef40995432;hb=a5ac7299f8042c01fcdb60c5508047146baf3a16;hp=301473cd827462e9d781ede7e15e42a31cbd9c37;hpb=7ff2009a9599a4cebeea038764a2d3f13c60f601;p=openvswitch diff --git a/lib/vlog.c b/lib/vlog.c index 301473cd..11b2f7cc 100644 --- a/lib/vlog.c +++ b/lib/vlog.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -322,7 +323,25 @@ vlog_set_log_file(const char *file_name) int vlog_reopen_log_file(void) { - return log_file_name ? vlog_set_log_file(log_file_name) : 0; + struct stat old, new; + + /* Skip re-opening if there's nothing to reopen. */ + if (!log_file_name) { + return 0; + } + + /* Skip re-opening if it would be a no-op because the old and new files are + * the same. (This avoids writing "closing log file" followed immediately + * by "opened log file".) */ + if (log_file + && !fstat(fileno(log_file), &old) + && !stat(log_file_name, &new) + && old.st_dev == new.st_dev + && old.st_ino == new.st_ino) { + return 0; + } + + return vlog_set_log_file(log_file_name); } /* Set debugging levels: