------------------------------------------------------------ revno: 12406 revision-id: squid3@treenet.co.nz-20121124034134-1f0vq84hlr4e2oon parent: squid3@treenet.co.nz-20121124034043-fihi03y5pn2ode74 committer: Amos Jeffries branch nick: 3.3 timestamp: Fri 2012-11-23 20:41:34 -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-20121124034134-1f0vq84hlr4e2oon # target_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # testament_sha1: 986dcc845205a6709977b20567fd09dc2abae4bc # timestamp: 2012-11-24 03:44:02 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/3.3 # base_revision_id: squid3@treenet.co.nz-20121124034043-\ # fihi03y5pn2ode74 # # Begin patch === modified file 'helpers/log_daemon/file/log_file_daemon.cc' --- helpers/log_daemon/file/log_file_daemon.cc 2012-07-02 12:14:07 +0000 +++ helpers/log_daemon/file/log_file_daemon.cc 2012-11-24 03:41:34 +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");