more clever connection refusals
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 11 Jun 1995 03:09:05 +0000 (19:09 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Sun, 11 Jun 1995 03:09:05 +0000 (19:09 -0800)
SCCS-vsn: usr.sbin/sendmail/src/conf.c 8.191

usr/src/usr.sbin/sendmail/src/conf.c

index 453a943..542bc5f 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)conf.c     8.190 (Berkeley) %G%";
+static char sccsid[] = "@(#)conf.c     8.191 (Berkeley) %G%";
 #endif /* not lint */
 
 # include "sendmail.h"
 #endif /* not lint */
 
 # include "sendmail.h"
@@ -1532,21 +1532,38 @@ shouldqueue(pri, ctime)
 **             FALSE if we should accept new work.
 **
 **     Side Effects:
 **             FALSE if we should accept new work.
 **
 **     Side Effects:
-**             none.
+**             Sets process title when it is rejecting connections.
 */
 
 bool
 refuseconnections()
 {
        extern bool enoughdiskspace();
 */
 
 bool
 refuseconnections()
 {
        extern bool enoughdiskspace();
+       extern void setproctitle();
 
 #ifdef XLA
        if (!xla_smtp_ok())
                return TRUE;
 #endif
 
 
 #ifdef XLA
        if (!xla_smtp_ok())
                return TRUE;
 #endif
 
-       /* this is probably too simplistic */
-       return CurrentLA >= RefuseLA || !enoughdiskspace(MinBlocksFree + 1);
+       if (CurrentLA >= RefuseLA)
+       {
+               setproctitle("rejecting connections: load average: %d",
+                       CurrentLA);
+       }
+       else if (!enoughdiskspace(MinBlocksFree + 1))
+       {
+               setproctitle("rejecting connections: min free: %d",
+                       MinBlocksFree);
+       }
+       else if (MaxChildren > 0 && CurChildren >= MaxChildren)
+       {
+               setproctitle("rejecting connections: maximum children: %d",
+                       CurChildren);
+       }
+       else
+               return FALSE;
+       return TRUE;
 }
 \f/*
 **  SETPROCTITLE -- set process title for ps
 }
 \f/*
 **  SETPROCTITLE -- set process title for ps
@@ -1707,18 +1724,19 @@ reapchild(sig)
 #endif
                        break;
                }
 #endif
                        break;
                }
+               CurChildren--;
        }
 # else
 # ifdef WNOHANG
        union wait status;
 
        while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
        }
 # else
 # ifdef WNOHANG
        union wait status;
 
        while (wait3(&status, WNOHANG, (struct rusage *) NULL) > 0)
-               continue;
+               CurChildren--;
 # else /* WNOHANG */
        auto int status;
 
        while (wait(&status) > 0)
 # else /* WNOHANG */
        auto int status;
 
        while (wait(&status) > 0)
-               continue;
+               CurChildren--;
 # endif /* WNOHANG */
 # endif
 # ifdef SYS5SIGNALS
 # endif /* WNOHANG */
 # endif
 # ifdef SYS5SIGNALS