/* * Copyright (C) 2000, iAgora LLC. * Written by Roger Espel Llima for iAgora LLC, 28-NOV-2000. * * This program is Free Software. You can redistribute and/or modify it * under the terms specified in the file ``LICENSE'', which is part of * the lingerd distribution. (For the impatient: it's an Apache-style * license, without the advertising clause.) * */ /* * Common definitions betweeen lingerd and the Apache lingerd patches. */ /* * Name of the Unix-domain socket that lingerd uses to wait for client * connections. This must be somewhere in the filesystem where lingerd * can write; it's better to put it in some non-world-writable * directory, but /tmp will do as a default. If you change it, edit * apache-1.3/ap_lingerd.h too. */ #define SOCKPATH "/var/run/lingerd/lingerd.sock" /* * Definitions specific to lingerd, not used by the Apache patches. */ #ifdef IN_LINGERD /* * Name of the file to write the pid of the daemon to. Set to NULL if * you don't want a pidfile at all. */ #define PID_FILE "/var/run/lingerd/lingerd.pid" /* * What syslog facility to log errors to. You can set where these * errors actually go by editing /etc/syslog.conf. * * If your syslog.conf sends LOG_DAEMON stuff to all of /var/log/syslog, * /var/log/daemon.log and /var/log/messages (mine did, go figure why), * you might want to change it to log to one place only. */ #define LOG_FACILITY LOG_DAEMON /* * Initial linger time in seconds; this is incremented every time a * read() from the socket succeeds. */ #define LINGER_TIME 2 /* * Hard limit to the total linger time on a single socket. */ #define LINGER_MAX 30 /* * Every once in a while lingerd logs some statistics about its work. * This is done once per hour by default. Set it to a negative number * to disable statistics. */ #define STAT_PERIOD 3600 /* * Refuse to run if we can only hold fewer than this many sockets open. * This is mostly for sanity, and to make sure we don't run a crippled * linger daemon. */ #define MIN_FD_LIMIT 1024 /* * Hardcoded limit to the number of fd's we'll handle, just in case * getrlimit() returns astronomically high results, as it is reported to * do on GNU/Hurd. */ #define MAX_FD_LIMIT (16*1024) /* * Number of socket slots to set aside, out of the array, for things * like std{in,out,err} and syslog. */ #define SOCK_SETASIDE 8 /* * The time granularity, in milliseconds. We check the status of all * sockets everytime there's activity on a socket, or at least every * this many milliseconds. Don't bother setting this very low because * all timeouts are counted in whole seconds anyway. */ #define POLL_TIMEOUT 500 /* * This is the timeout for poll(), in milliseconds, when there are * no lingering sockets at all. It should be bigger than the * regular POLL_TIMEOUT, but much smaller than 1000*STAT_PERIOD. */ #define SLOW_TIMEOUT 20000 /* * Maximum backlog of pending clients for the listen() call. Not * really very important here, because we get relatively few clients * (Apache processes are clients, individual linger sockets aren't). */ #define BACKLOG 20 /* * Name of the program, for logging purposes. */ #define MY_NAME "lingerd" #endif /* IN_LINGERD */ /* * Definitions specific to the Apache patches for lingerd */ #ifdef IN_APACHE /* * If the connection to the linger daemon fails, how long to wait before * trying again. * * Note that, if lingerd isn't running when Apache starts, or if you * restart lingerd without restarting Apache, each Apache process will * connect to lignerd separately, so you will get a connection attempt * _per child_ every this many seconds. * */ #define TRY_CONN_PERIOD 10 /* * If Apache can't contact the daemon, should it linger on sockets * itself (which is slow), or not (which is unsafe)? Leave this on (1) * while testing lingerd, but turn it off (0) once you come to trust it * and depend on the diminished server load. */ #define LINGER_ON_FAILURE 1 #endif /* IN_APACHE */ /* * ================================================= * END OF USER-CONFIGURABLE DEFINITIONS * ================================================= */ /* * Some definitions related to fd-passing. */ /* * FD passing; supporting Linux glibc 2.x (the BSD4.4 way) and Solaris 2.[78] * (the BSD 4.[23] way) for the moment. */ /* * Testing for __sun for lack of anything better; this test borrowed from * the Perl module Socket-PassAccessRights-0.0.3. */ #if defined(__sun) && !defined(NEW_FD_PASSING) && !defined(OLD_FD_PASSING) # define OLD_FD_PASSING #endif /* * With BSD4.4-style fd passing, some macros are sometimes missing; * define them if we can. */ #ifndef OLD_FD_PASSING /* * This is arguably broken; most cmsghdr's don't have cmsg_data as a member * structure, since it would have to be of length 0. But most cmsghdr's * do have the macro CMSG_DATA already. */ # ifndef CMSG_DATA # define CMSG_DATA(cmsg) ((cmsg)->cmsg_data) # endif /* * Length of the SCM_RIGHTS control structure, with one fd */ # ifdef CMSG_SPACE # define CONTROLLEN (CMSG_SPACE(sizeof(int))) # else # define CONTROLLEN (sizeof(struct cmsghdr) + sizeof(int)) # endif /* * A type big enough to hold a struct cmsghdr with its data. */ typedef union { struct cmsghdr hdr; char buf[CONTROLLEN]; } lingerd_cmsghdr; #endif /* OLD_FD_PASSING */