From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/608 Path: main.gmane.org!not-for-mail From: Gerrit Pape Newsgroups: gmane.comp.sysutils.supervision.general Subject: svlogd: blocking on ENOSPC Date: Mon, 18 Oct 2004 17:39:24 +0000 Message-ID: <20041018173902.24555.qmail@9227b11f156c29.315fe32.mid.smarden.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="sm4nu43k4a2Rpi4c" X-Trace: sea.gmane.org 1098121134 15056 80.91.229.6 (18 Oct 2004 17:38:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 18 Oct 2004 17:38:54 +0000 (UTC) Original-X-From: supervision-return-847-gcsg-supervision=m.gmane.org@list.skarnet.org Mon Oct 18 19:38:41 2004 Return-path: Original-Received: from antah.skarnet.org ([212.85.147.14] ident=qmailr) by deer.gmane.org with smtp (Exim 3.35 #1 (Debian)) id 1CJbSz-0006VR-00 for ; Mon, 18 Oct 2004 19:38:41 +0200 Original-Received: (qmail 20749 invoked by uid 76); 18 Oct 2004 17:39:02 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Archive: Original-Received: (qmail 20744 invoked from network); 18 Oct 2004 17:39:02 -0000 Original-To: supervision@list.skarnet.org Mail-Followup-To: supervision@list.skarnet.org Content-Disposition: inline Xref: main.gmane.org gmane.comp.sysutils.supervision.general:608 X-Report-Spam: http://spam.gmane.org/gmane.comp.sysutils.supervision.general:608 --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, svlogd, just as multilog, sleeps and retries in case it's unable to write to the current logfile in a log directory and the system is ``out of disk space''. This usually makes the service block because svlogd stops reading from the pipe. Even though the space for logs can be calculated properly, if a log partition fills up by accident, it can bring the system in a troublesome state. Here's a patch that makes svlogd remove the oldest of rotated log files in the log directory in case the disk is full. In the worst case only the current logfile will be left. I would be interested in your opinions. Regards, Gerrit. --sm4nu43k4a2Rpi4c Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=diff diff -u -r1.7 -r1.8 --- src/svlogd.c 7 Oct 2004 07:56:29 -0000 1.7 +++ src/svlogd.c 7 Oct 2004 14:40:56 -0000 1.8 @@ -287,8 +287,41 @@ if (len > ((dir +n)->sizemax -(dir +n)->size)) len =(dir +n)->sizemax -(dir +n)->size; } - while ((i =write((dir +n)->fdcur, s, len)) == -1) + while ((i =write((dir +n)->fdcur, s, len)) == -1) { + if (errno == ENOSPC) { + DIR *d; + direntry *f; + char oldest[FMT_PTIME]; + + while (fchdir((dir +n)->fddir) == -1) + pause2("unable to change directory, want remove old logfile", + (dir +n)->name); + oldest[0] ='A'; oldest[1] =oldest[27] =0; + while (! (d =opendir("."))) + pause2("unable to open directory, want remove old logfile", + (dir +n)->name); + errno =0; + while ((f =readdir(d))) + if ((f->d_name[0] == '@') && (str_len(f->d_name) == 27)) + if (str_diff(f->d_name, oldest) < 0) byte_copy(oldest, 27, f->d_name); + if (errno) warn2("unable to read directory, want remove old logfile", + (dir +n)->name); + closedir(d); + if (*oldest == '@') { + strerr_warn5(WARNING, "out of disk space, delete: ", (dir +n)->name, + "/", oldest, 0); + if (unlink(oldest) == -1) + warn2("unable to unlink oldest logfile", (dir +n)->name); + else + i =1; + } + while (fchdir(fdwdir) == -1) + pause1("unable to change to initial working directory"); + if (i) continue; + } pause2("unable to write to current", (dir +n)->name); + } + (dir +n)->size +=i; if ((dir +n)->sizemax) if (s[i -1] == '\n') --sm4nu43k4a2Rpi4c--