------------------------------------------------------------ revno: 11718 revision-id: squid3@treenet.co.nz-20121129112058-qjxrxlrh2pp6lk5s parent: squid3@treenet.co.nz-20121129112018-rrp7unxvfwluy455 committer: Amos Jeffries branch nick: 3.2 timestamp: Thu 2012-11-29 04:20:58 -0700 message: log_file_daemon: better error reporting Report rotation errors and log file removal errors instead of silently ignoring them. Detected by Coverity Scan. Issue 740316 ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20121129112058-qjxrxlrh2pp6lk5s # target_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # testament_sha1: c55006330f5e04b53777dcc6ca4e1b43dbab43da # timestamp: 2012-11-29 11:22:08 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/branches\ # /SQUID_3_2 # base_revision_id: squid3@treenet.co.nz-20121129112018-\ # rrp7unxvfwluy455 # # Begin patch === modified file 'helpers/log_daemon/file/log_file_daemon.cc' --- helpers/log_daemon/file/log_file_daemon.cc 2012-02-05 06:09:46 +0000 +++ helpers/log_daemon/file/log_file_daemon.cc 2012-11-29 11:20:58 +0000 @@ -57,16 +57,24 @@ snprintf(from, MAXPATHLEN, "%s.%d", path, i - 1); snprintf(to, MAXPATHLEN, "%s.%d", path, i); #if _SQUID_OS2_ || _SQUID_WINDOWS_ - remove(to); + if (remove(to) < 0) { + fprintf(stderr, "WARNING: remove '%s' failure: %s\n", to, xstrerror()); + } #endif - rename(from, to); + if (rename(path, to) < 0 && errno != ENOENT) { + fprintf(stderr, "WARNING: rename '%s' to '%s' failure: %s\n", path, to, xstrerror()); + } } if (rotate_count > 0) { snprintf(to, MAXPATHLEN, "%s.%d", path, 0); #if _SQUID_OS2_ || _SQUID_WINDOWS_ - remove(to); + if (remove(to) < 0) { + fprintf(stderr, "WARNING: remove '%s' failure: %s\n", to, xstrerror()); + } #endif - rename(path, to); + if (rename(path, to) < 0 && errno != ENOENT) { + fprintf(stderr, "WARNING: rename %s to %s failure: %s\n", path, to, xstrerror()); + } } } @@ -119,7 +127,7 @@ * out of device space - recover by rotating and hoping that rotation count drops a big one. */ if (err == EFBIG || err == ENOSPC) { - fprintf(stderr, "WARNING: %s writing %s. Attempting to recover via a log rotation.\n",strerror(err),argv[1]); + fprintf(stderr, "WARNING: %s writing %s. Attempting to recover via a log rotation.\n",xstrerr(err),argv[1]); fclose(fp); rotate(argv[1], rotate_count); fp = fopen(argv[1], "a");