[8687] in Athena Bugs

home help back first fref pref prev next nref lref last post

[daemon@ATHENA.MIT.EDU : vax 7.3P: afs and movemail]

daemon@ATHENA.MIT.EDU (Calvin Clark)
Thu Nov 28 11:08:01 1991

Date: Thu, 28 Nov 91 11:08:10 -0500
From: Calvin Clark <ckclark@Athena.MIT.EDU>
To: bugs@Athena.MIT.EDU
Cc: dkk@Athena.MIT.EDU, mar@Athena.MIT.EDU, emacsdev@Athena.MIT.EDU
In-Reply-To: [8684]
Reply-To: ckclark@mit.edu


>Since IS is apparently planning to migrate from NFS to AFS this
>summer, the following bug report should be taken seriously.  Loss of
>mail can result (and almost did...) from the bug.

s/almost/in fact/  (Sorry, Mark.)

It turns out that there are significant problems over NFS, as well.  In
fact, the NFS problem is even more profound.  On AFS, it is possible to
write about a megabyte over your quota after a successful open().  The
only time a user with a AFS homedir will lose mail due to this bug is
when he is near his quota and has more than a megabyte of mail at the
post office.  A user with an NFS homedir will lose all the mail
regardless of how much is waiting for him on the pop server.

Anyway, I have added a lot of error checking to movemail, much of which
is probably gratuitous.  The part that was killing users with AFS
homedirs was that the exit status of close() was not being checked.  I
have banged hard on this new version with both NFS and AFS test
accounts, and I believe it to be far more robust than the old one.  I
will submit the important parts of these changes to the FSF RSN,
meaning, as soon as I get a straight answer on why the system error
message for a failed file storage on AFS is "Network is down":

~/junk> /mit/bitbucket/ckclark/movemail/mm po:sipb0 mail
afs: failed to store file (69)
movemail: Error in close: Network is down

I also have to get a good explanation on the seemingly bizarre behavior
of fflush() over AFS.

I have installed these changes in the emacsdev locker, so those using
the version of emacs there will be less likely to lose mail.  (You can
use this movemail with the release version of emacs by changing the
value of the elisp variable "movemail-program" in you .emacs file, or
wherever, to point into emacsdev.)

Enough hot air:

RCS file: RCS/movemail.c,v
retrieving revision 1.4
diff -c -r1.4 movemail.c
*** /tmp/,RCSt1027610	Thu Nov 28 10:36:38 1991
--- movemail.c	Thu Nov 28 10:23:58 1991
***************
*** 455,473 ****
  	}
  	mbx_delimit_end(mbf);
  	fflush(mbf);
      }
  
      for (i = 1; i <= nmsgs; i++) {
  	if (pop_command("DELE %d", i) == NOTOK) {
  	    error(Errmsg);
  	    pop_command("QUIT");
- 	    close(mbfi);
  	    return(1);
  	}
      }
  
      pop_command("QUIT");
-     close(mbfi);
      return(0);
  }
  
--- 455,482 ----
  	}
  	mbx_delimit_end(mbf);
  	fflush(mbf);
+ 	if (ferror(mbf)) {
+ 	  error("Error in fflush: %s", get_errmsg());
+ 	  pop_command("QUIT");
+ 	  close(mbfi);
+ 	  return(1);
+ 	}
      }
  
+     if (close(mbfi) == -1) {
+       error("Error in close: %s", get_errmsg());
+       return(1);
+     }
+ 
      for (i = 1; i <= nmsgs; i++) {
  	if (pop_command("DELE %d", i) == NOTOK) {
  	    error(Errmsg);
  	    pop_command("QUIT");
  	    return(1);
  	}
      }
  
      pop_command("QUIT");
      return(0);
  }
  
***************
*** 625,631 ****
      while (1) {
  	switch (multiline(buf, sizeof buf, sfi)) {
  	case OK:
! 	    (*action)(buf, arg);
  	    break;
  	case DONE:
  	    return (OK);
--- 634,643 ----
      while (1) {
  	switch (multiline(buf, sizeof buf, sfi)) {
  	case OK:
! 	    if ((*action)(buf, arg) != OK) {
! 	      strcpy(Errmsg, get_errmsg());
! 	      return (NOTOK);
! 	    }
  	    break;
  	case DONE:
  	    return (OK);
***************
*** 708,731 ****
      return(OK);
  }
  
! mbx_write(line, mbf)
  char *line;
  FILE *mbf;
  {
!     fputs(line, mbf);
!     fputc(0x0a, mbf);
  }
  
! mbx_delimit_begin(mbf)
  FILE *mbf;
  {
!     fputs("\f\n0, unseen,,\n", mbf);
  }
  
  mbx_delimit_end(mbf)
  FILE *mbf;
  {
!     putc('\037', mbf);
  }
  
  #endif /* MAIL_USE_POP */
--- 720,750 ----
      return(OK);
  }
  
! int mbx_write(line, mbf)
  char *line;
  FILE *mbf;
  {
!     if (fputs(line, mbf) == EOF) 
!       return(NOTOK);
!     if (fputc(0x0a, mbf) == EOF)
!       return(NOTOK);
!     return(OK);
  }
  
! int mbx_delimit_begin(mbf)
  FILE *mbf;
  {
!     if (fputs("\f\n0, unseen,,\n", mbf) == EOF)
!       return(NOTOK);
!     return(OK);
  }
  
  mbx_delimit_end(mbf)
  FILE *mbf;
  {
!     if (putc('\037', mbf) == EOF)
!       return(NOTOK);
!     return(OK);
  }
  
  #endif /* MAIL_USE_POP */

home help back first fref pref prev next nref lref last post