[9380] in Athena Bugs

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

inc

daemon@ATHENA.MIT.EDU (tom@MIT.EDU)
Sat May 30 17:44:19 1992

From: tom@MIT.EDU
Date: Sat, 30 May 92 17:43:54 EDT
To: bugs@MIT.EDU
Cc: postmaster@MIT.EDU


The following is a patch to inc to make it close the post office
connection properly upon errors such as over quota or permission
denied. 

It has the side affect that if one goes over quota while retrieving
mail, messages that had been successfully incorporated will be removed
from the post office (unless the notruncate flag is specified) while
messages that were not written will be left on the post office for
future pickup.  This behavior has the feature that one need not have
enough room to inc all their mail at once or play games with temporary
inboxes.

						- Tom


*** /source/third/common/mh.6.6/uip/inc.c	Wed Feb 19 12:18:50 1992
--- inc.c	Sat May 30 16:47:59 1992
***************
*** 492,508 ****
  	    }
  	    msgnum = map_count ();
  	    if ((pd = mbx_open (file, getuid (), getgid (), m_gmprot ()))
! 		    == NOTOK)
  		adios (file, "unable to open");
! 	    if ((pf = fdopen (pd, "w+")) == NULL)
  		adios (NULLCP, "unable to fdopen %s", file);
  	}
  	else {
  	    hghnum = msgnum = mp -> hghmsg;
! 	    if ((mp = m_remsg (mp, 0, mp -> hghmsg + nmsgs)) == NULL)
  		adios (NULLCP, "unable to allocate folder storage");
  	}
  
  	for (i = 1; i <= nmsgs; i++) {
  	    msgnum++;
  	    if (file) {
--- 492,520 ----
  	    }
  	    msgnum = map_count ();
  	    if ((pd = mbx_open (file, getuid (), getgid (), m_gmprot ()))
! 		    == NOTOK) {
! 	        (void) pop_quit (); 
  		adios (file, "unable to open");
!             }
!             
! 	    if ((pf = fdopen (pd, "w+")) == NULL) {
!               (void) pop_quit ();
  		adios (NULLCP, "unable to fdopen %s", file);
+             }
  	}
  	else {
  	    hghnum = msgnum = mp -> hghmsg;
! 	    if ((mp = m_remsg (mp, 0, mp -> hghmsg + nmsgs)) == NULL) {
!               (void) pop_quit ();
  		adios (NULLCP, "unable to allocate folder storage");
+             }
  	}
  
+ 	/*
+        * make sure to call pop_quit() to close post office connection
+        * upon error to update the state of previous messages.
+        */
+ 
  	for (i = 1; i <= nmsgs; i++) {
  	    msgnum++;
  	    if (file) {
***************
*** 512,538 ****
  		(void) fwrite (mmdlm1, 1, strlen (mmdlm1), pf);
  		start = ftell (pf);
  
! 		if (pop_retr (i, pop_pack) == NOTOK)
  		    adios (NULLCP, "%s", response);
  
  		(void) fseek (pf, 0L, 1);
  		stop = ftell (pf);
! 		if (fflush (pf))
  		    adios (file, "write error on");
  		(void) fseek (pf, start, 0);
  	    }
  	    else {
  		cp = getcpy (m_name (msgnum));
! 		if ((pf = fopen (cp, "w+")) == NULL)
  		    adios (cp, "unable to write");
  		(void) chmod (cp, m_gmprot ());
  		start = stop = 0L;
  
! 		if (pop_retr (i, pop_action) == NOTOK)
  		    adios (NULLCP, "%s", response);
  
! 		if (fflush (pf))
  		    adios (cp, "write error on");
  		(void) fseek (pf, 0L, 0);
  	    }
  	    switch (p = scan (pf, msgnum, 0, nfs, width,
--- 524,560 ----
  		(void) fwrite (mmdlm1, 1, strlen (mmdlm1), pf);
  		start = ftell (pf);
  
! 		if (pop_retr (i, pop_pack) == NOTOK) {
! 	            (void) pop_quit ();	
  		    adios (NULLCP, "%s", response);
+                 }
  
  		(void) fseek (pf, 0L, 1);
  		stop = ftell (pf);
! 		if (fflush (pf)) {
!                   (void) pop_quit ();
  		    adios (file, "write error on");
+                 }
  		(void) fseek (pf, start, 0);
  	    }
  	    else {
  		cp = getcpy (m_name (msgnum));
! 		if ((pf = fopen (cp, "w+")) == NULL) {
!                   (void) pop_quit ();
  		    adios (cp, "unable to write");
+                 }
  		(void) chmod (cp, m_gmprot ());
  		start = stop = 0L;
  
! 		if (pop_retr (i, pop_action) == NOTOK) {
! 	            (void) pop_quit ();
  		    adios (NULLCP, "%s", response);
+                 }
  
! 		if (fflush (pf)) {
!                   (void) pop_quit ();
  		    adios (cp, "write error on");
+                 }
  		(void) fseek (pf, 0L, 0);
  	    }
  	    switch (p = scan (pf, msgnum, 0, nfs, width,
***************
*** 597,604 ****
  		free (cp);
  	    }
  
! 	    if (trnflag && pop_dele (i) == NOTOK)
! 		adios (NULLCP, "%s", response);
  	}
  	if (pop_quit () == NOTOK)
  	    adios (NULLCP, "%s", response);
--- 619,626 ----
  		free (cp);
  	    }
  
! 	    if (trnflag && pop_dele (i) == NOTOK) /* delete error */
! 		adios (NULLCP, "%s", response);   /* abort po connection */
  	}
  	if (pop_quit () == NOTOK)
  	    adios (NULLCP, "%s", response);

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