[3211] in Athena Bugs

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

post office problems with spop + PATCH

daemon@ATHENA.MIT.EDU (John T Kohl)
Fri Sep 15 11:13:04 1989

Date: Fri, 15 Sep 89 11:12:32 -0400
From: John T Kohl <jtkohl@ATHENA.MIT.EDU>
To: bugs@ATHENA.MIT.EDU
Cc: hoffmann@ATHENA.MIT.EDU
One of the post offices was having trouble this morning, related to the
zephyr mail notifications.

The current version of spop uses one zpopnotify per recipient; this can
lead to lots of processes & contention problems.

Enclosed is a patch which changes spop to use one zpopnotify per mail
message, much more efficient.

John

*** /tmp/,RCSt1a08468	Fri Sep 15 11:11:43 1989
--- spop.c	Fri Sep 15 11:11:40 1989
***************
*** 156,164 ****
      register struct bboard  *bp;
  #ifdef ATHENA
      int pid;
  #endif ATHENA
  
!     for (i = 0; bp = bb[i]; i++)
  	if (bp -> bb_file && *bp -> bb_file) {
  	    (void) lseek (fd, 0L, 0);
  #ifndef	SPOP
--- 156,166 ----
      register struct bboard  *bp;
  #ifdef ATHENA
      int pid;
+     char **bbnames;
+     int namecount = 0;
  #endif ATHENA
  
!     for (i = 0; bp = bb[i]; i++) {
  	if (bp -> bb_file && *bp -> bb_file) {
  	    (void) lseek (fd, 0L, 0);
  #ifndef	SPOP
***************
*** 175,194 ****
  #endif	not SPOP
  		(void) mbx_copy (bp -> bb_file, md, fd, 1, bb_head, 0);
  	    (void) mbx_close (bp -> bb_file, md);
  #ifdef ATHENA
! 	    pid = vfork();
! 	    if (pid > 0) {
! 		(void) wait(0);
! 	    } else if (pid < 0) {
! 		(void) lose ("unable to vfork");
! 		continue;
! 	    } else {
! 		/* child */
! 		execl(NOTIFY_PROG, NOTIFY_PROG, bp->bb_name, 0);
! 		_exit(1);		/* silently exit if error */
! 	    }
  #endif ATHENA
! 	}
  }
  
  /*  */
--- 177,209 ----
  #endif	not SPOP
  		(void) mbx_copy (bp -> bb_file, md, fd, 1, bb_head, 0);
  	    (void) mbx_close (bp -> bb_file, md);
+ 	}
  #ifdef ATHENA
! 	namecount++;
  #endif ATHENA
!     }
! #ifdef ATHENA
!     /* allocate array for execv.  calloc to zero out; +2 to make room
!        for program name and null terminator */
!     bbnames = (char **) calloc(namecount+2, sizeof(char *));
!     if (!bbnames)
! 	return;			/* silently fail */
!     bbnames[0] = NOTIFY_PROG;
!     namecount = 1;
!     for (i = 0; bp = bb[i]; i++)
! 	if (bp -> bb_file && *bp -> bb_file)
! 	    bbnames[namecount++] = bp->bb_file;
!     pid = vfork();
!     if (pid > 0) {
! 	(void) wait(0);
!     } else if (pid < 0) {
! 	return;				/* silently fail */
!     } else {
! 	/* child */
! 	execv(NOTIFY_PROG, bbnames);
! 	_exit(1);		/* silently exit if error */
!     }
! #endif ATHENA
  }
  
  /*  */

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