shithub: riscv

Download patch

ref: 1d94a18e5683d0d69aca4c8350b7914419fae6bc
parent: 35f6a75355ea4f52f675f9cfbb865241512a7315
author: cinap_lenrek <[email protected]>
date: Sun Apr 9 00:32:38 EDT 2017

upas/fs: fix sync condition

we used to check for mb->d->name != nil before stating, to avoid
stating pop3/imap mailboxes who don't really have a local file,
but this breaks when the md->d is reconstructed (faked) from
the index! resulting in the mailbox stop being refreshed.

the solution is to not have mb->d == nil for imap/pop mailoxes.

--- a/sys/src/cmd/upas/fs/fs.c
+++ b/sys/src/cmd/upas/fs/fs.c
@@ -879,7 +879,7 @@
 			if(Topmsg(f->mb, f->m)){
 				f->qid.path = PATH(f->mb->id, Qmbox);
 				f->qid.type = QTDIR;
-				f->qid.vers = f->mb->d->qid.vers;
+				f->qid.vers = f->mb->vers;
 				msgdecref(f->mb, f->mtop);
 				msgdecref(f->mb, f->m);
 				f->m = f->mtop = nil;
@@ -1462,7 +1462,7 @@
 				mb->waketime = 0;
 				break;
 			}
-			if(mb->d != nil && mb->d->name != nil){
+			if(mb->d != nil){
 				d = dirstat(mb->path);
 				if(d != nil){
 					if(d->qid.path != mb->d->qid.path
--- a/sys/src/cmd/upas/fs/imap.c
+++ b/sys/src/cmd/upas/fs/imap.c
@@ -39,7 +39,7 @@
 
 typedef struct Imap Imap;
 struct Imap {
-	long	lastread;
+	ulong	lastread;
 
 	char	*mbox;
 	/* free this to free the strings below */
@@ -913,7 +913,7 @@
 	Message *m, **ll;
 
 	*new = 0;
-	if(time(0) - imap->lastread < 10)
+	if((ulong)time(0) - imap->lastread < 10)
 		return nil;
 	imap->lastread = time(0);
 	imap4cmd(imap, "status %Z (messages uidvalidity)", imap->mbox);
@@ -1008,10 +1008,9 @@
 	imap = mb->aux;
 	if(err = imap4dial(imap))
 		goto out;
-	if((err = imap4read(imap, mb, doplumb, new)) == nil)
-		mb->d->atime = mb->d->mtime = time(0);
+	err = imap4read(imap, mb, doplumb, new);
 out:
-	mb->waketime = time(0) + imap->refreshtime;
+	mb->waketime = (ulong)time(0) + imap->refreshtime;
 	return err;
 }
 
@@ -1185,7 +1184,6 @@
 	mb->rename = imap4rename;
 //	mb->remove = imap4remove;
 	mb->modflags = imap4modflags;
-	mb->d = emalloc(sizeof *mb->d);
 	mb->addfrom = 1;
 	return nil;
 }
--- a/sys/src/cmd/upas/fs/pop3.c
+++ b/sys/src/cmd/upas/fs/pop3.c
@@ -539,17 +539,13 @@
 
 	pop = mb->aux;
 
-	if(err = pop3dial(pop)) {
-		mb->waketime = time(0) + pop->refreshtime;
-		return err;
-	}
-
-	if((err = pop3read(pop, mb, doplumb, new)) == nil){
+	if(err = pop3dial(pop))
+		goto out;
+	if((err = pop3read(pop, mb, doplumb, new)) == nil)
 		pop3purge(pop, mb);
-		mb->d->atime = mb->d->mtime = time(0);
-	}
 	pop3hangup(pop);
-	mb->waketime = time(0) + pop->refreshtime;
+out:
+	mb->waketime = (ulong)time(0) + pop->refreshtime;
 	return err;
 }
 
@@ -661,7 +657,6 @@
 	mb->sync = pop3sync;
 	mb->close = pop3close;
 	mb->ctl = pop3ctl;
-	mb->d = emalloc(sizeof *mb->d);
 	mb->addfrom = 1;
 	return nil;
 }