File: chkspawn.c

package info (click to toggle)
qmail 1.01-5
  • links: PTS
  • area: non-free
  • in suites: hamm
  • size: 2,188 kB
  • ctags: 1,711
  • sloc: ansic: 13,993; makefile: 1,914; perl: 448; sh: 377
file content (48 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "substdio.h"
#include "subfd.h"
#include "fmt.h"
#include "select.h"
#include "exit.h"
#include "auto_spawn.h"

char num[FMT_ULONG];
fd_set fds;

void main()
{
  unsigned long hiddenlimit;
  unsigned long maxnumd;
 
  hiddenlimit = sizeof(fds) * 8;
  maxnumd = (hiddenlimit - 5) / 2;
 
  if (auto_spawn < 1) {
    substdio_puts(subfderr,"Oops. You have set conf-spawn lower than 1.\n");
    substdio_flush(subfderr);
    _exit(1);
  }

  if (auto_spawn > 255) {
    substdio_puts(subfderr,"Oops. You have set conf-spawn higher than 255.\n");
    substdio_flush(subfderr);
    _exit(1);
  }

  if (auto_spawn > maxnumd) {
    substdio_puts(subfderr,"Oops. Your system's FD_SET() has a hidden limit of ");
    substdio_put(subfderr,num,fmt_ulong(num,hiddenlimit));
    substdio_puts(subfderr," descriptors.\n\
This means that the qmail daemons could crash if you set the run-time\n\
concurrency higher than ");
    substdio_put(subfderr,num,fmt_ulong(num,maxnumd));
    substdio_puts(subfderr,". So I'm going to insist that the concurrency\n\
limit in conf-spawn be at most ");
    substdio_put(subfderr,num,fmt_ulong(num,maxnumd));
    substdio_puts(subfderr,". Right now it's ");
    substdio_put(subfderr,num,fmt_ulong(num,(unsigned long) auto_spawn));
    substdio_puts(subfderr,".\n");
    substdio_flush(subfderr);
    _exit(1);
  }
  _exit(0);
}