From owner-freebsd-ports-bugs@FreeBSD.ORG Fri May 6 17:30:03 2005 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 46A5D16A4D4 for ; Fri, 6 May 2005 17:30:03 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 132B443DBE for ; Fri, 6 May 2005 17:30:02 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j46HU2hx020599 for ; Fri, 6 May 2005 17:30:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j46HU2Bm020598; Fri, 6 May 2005 17:30:02 GMT (envelope-from gnats) Resent-Date: Fri, 6 May 2005 17:30:02 GMT Resent-Message-Id: <200505061730.j46HU2Bm020598@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Roland Smith Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5A54C16A4D4 for ; Fri, 6 May 2005 17:29:28 +0000 (GMT) Received: from smtp-vbr4.xs4all.nl (smtp-vbr4.xs4all.nl [194.109.24.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BF9943DAE for ; Fri, 6 May 2005 17:29:27 +0000 (GMT) (envelope-from rsmith@xs4all.nl) Received: from slackbox.xs4all.nl (slackbox.xs4all.nl [213.84.242.160]) by smtp-vbr4.xs4all.nl (8.12.11/8.12.11) with ESMTP id j46HTQJD091166 for ; Fri, 6 May 2005 19:29:26 +0200 (CEST) (envelope-from rsmith@xs4all.nl) Received: by slackbox.xs4all.nl (Postfix, from userid 1001) id 5A86661F1; Fri, 6 May 2005 19:29:26 +0200 (CEST) Message-Id: <20050506172926.5A86661F1@slackbox.xs4all.nl> Date: Fri, 6 May 2005 19:29:26 +0200 (CEST) From: Roland Smith To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: ports/80709: [PATCH]: torsmo doesn't display mail count correctly. X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Roland Smith List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2005 17:30:03 -0000 >Number: 80709 >Category: ports >Synopsis: [PATCH]: torsmo doesn't display mail count correctly. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri May 06 17:30:02 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Roland Smith >Release: FreeBSD 5.4-STABLE amd64 >Organization: >Environment: System: FreeBSD slackbox.xs4all.nl 5.4-STABLE FreeBSD 5.4-STABLE #0: Fri Apr 15 17:37:34 CEST 2005 rsmith@slackbox.xs4all.nl:/usr/obj/usr/src/sys/RFS amd64 >Description: Torsmo 0.18 does not display the mail count of an mbox type mailbox correctly. If mails are deleted from a mailbox, the mail count isn't altered. Possibly because it checks for stat.st_mtime instead of stat.st_ctime. The update is also done very unfrequently. A posible error in stat(2) is also not detected. There are two overlapping variables. >How-To-Repeat: Run Torsmo. >Fix: Apply the following patch (patch-mail.c): --------------------- patch ----------------------------- --- mail.c.orig Fri May 6 10:47:22 2005 +++ mail.c Fri May 6 19:17:15 2005 @@ -12,30 +12,26 @@ static double last_mail_update; void update_mail_count() { - struct stat buf; + struct stat sbuf; if (current_mail_spool == NULL) return; /* TODO: use that fine file modification notify on Linux 2.4 */ - /* don't check mail so often (9.5s is minimum interval) */ - if (current_update_time - last_mail_update < 9.5) + /* don't check mail so often (5.5s is minimum interval) */ + if (current_update_time - last_mail_update < 5.5) return; else last_mail_update = current_update_time; - if (stat(current_mail_spool, &buf)) { - static int rep; - if (!rep) { + if (stat(current_mail_spool, &sbuf) == -1) { ERR("can't stat %s: %s", current_mail_spool, strerror(errno)); - rep = 1; - } - return; + return; } #if HAVE_DIRENT_H /* maildir format */ - if (S_ISDIR(buf.st_mode)){ + if (S_ISDIR(sbuf.st_mode)){ DIR *dir; char *dirname; struct dirent *dirent; @@ -95,7 +91,7 @@ /* mbox format */ - if (buf.st_mtime != last_mail_mtime) { + if (sbuf.st_ctime != last_mail_mtime) { /* yippee, modification time has changed, let's read mail count! */ static int rep; FILE *fp; @@ -127,7 +123,6 @@ reading_status = 1; } } - else { if (reading_status && strncmp(buf, "X-Mozilla-Status:", 17) == 0) { /* check that mail isn't already read */ if (strchr(buf+21, '0')) @@ -144,7 +139,6 @@ reading_status = 0; continue; } - } /* skip until \n */ while (strchr(buf, '\n') == NULL && !feof(fp)) @@ -155,7 +149,7 @@ if (reading_status) info.new_mail_count++; - last_mail_mtime = buf.st_mtime; + last_mail_mtime = sbuf.st_mtime; } } --------------------- patch ----------------------------- >Release-Note: >Audit-Trail: >Unformatted: