> > A second and more defensive measure is to issue a non-blocking read on
> > the pipe to drain all qmail-queue bytes *prior* to the todo

This is the solution I eventually used. Works like a charm. I've
appended the patch so that it gets into the archives. Variations from
the original post include opening the trigger file just the once as
well as setting it non-blocking at the time it's opened.  I've called
it the trigger-happy patch :>


Regards.

*** Makefile.orig       Mon Jun 15 03:53:16 1998
--- Makefile    Fri Jul 27 11:23:47 2001
***************
*** 2114,2120 ****
        ./compile token822.c
  
  trigger.o: \
! compile trigger.c select.h open.h trigger.h hasnpbg1.h
        ./compile trigger.c
  
  triggerpull.o: \
--- 2114,2120 ----
        ./compile token822.c
  
  trigger.o: \
! compile trigger.c select.h open.h trigger.h hasnpbg1.h ndelay.h
        ./compile trigger.c
  
  triggerpull.o: \
*** trigger.orig.c      Mon Jun 15 03:53:16 1998
--- trigger.c   Thu Jul 26 18:02:07 2001
***************
*** 1,4 ****
--- 1,5 ----
  #include "select.h"
+ #include "ndelay.h"
  #include "open.h"
  #include "trigger.h"
  #include "hasnpbg1.h"
***************
*** 10,24 ****
  
  void trigger_set()
  {
!  if (fd != -1)
!    close(fd);
! #ifdef HASNAMEDPIPEBUG1
!  if (fdw != -1)
!    close(fdw);
! #endif
!  fd = open_read("lock/trigger");
  #ifdef HASNAMEDPIPEBUG1
!  fdw = open_write("lock/trigger");
  #endif
  }
  
--- 11,25 ----
  
  void trigger_set()
  {
!  if (fd == -1)
!   {
!    fd = open_read("lock/trigger");
!    if (fd != -1)
!      ndelay_on(fd);
!   }
  #ifdef HASNAMEDPIPEBUG1
!  if (fdw == -1)
!    fdw = open_write("lock/trigger");
  #endif
  }
  
***************
*** 36,41 ****
  int trigger_pulled(rfds)
  fd_set *rfds;
  {
!  if (fd != -1) if (FD_ISSET(fd,rfds)) return 1;
   return 0;
  }
--- 37,48 ----
  int trigger_pulled(rfds)
  fd_set *rfds;
  {
!  char buf[64];
! 
!  if ((fd != -1) && FD_ISSET(fd,rfds))
!   {
!    while (read(fd,buf,sizeof(buf)) == sizeof(buf)) ;
!    return 1;
!   }
   return 0;
  }

Reply via email to