master-service.c revision 9217d2426b4f8ece47441357f35d8bb34d97c4eb
/* getenv(MASTER_CONFIG_FILE_ENV) provides path to configuration file/socket */ /* getenv(MASTER_DOVECOT_VERSION_ENV) provides master's version number */ /* when we're full of connections, how often to check if login state has changed. we normally notice it immediately because of a signal, so this is just a fallback against race conditions. */ /* If die callback hasn't managed to stop the service for this many seconds, /* SIGINT comes either from master process or from keyboard. we don't want to log it in either case.*/ i_warning(
"Killed with signal %d (by pid=%s uid=%s code=%s)",
/* never die when idling */ /* SIGINT came from master. die only if we're not handling any clients currently. */ i_fatal(
"Dovecot version mismatch: " "(if you don't care, set version_ignore=yes)",
/* make sure we can dump core, at least until privileges are dropped. (i'm not really sure why this is needed, because doing the same just before exec doesn't help, and exec shouldn't affect this with /* NOTE: we start rooted, so keep the code minimal until restrict_access_by_env() is called */ /* Set a logging prefix temporarily. This will be ignored once the log is properly initialized */ /* ignore these signals as early as possible */ /* keep getopt_str first in case it contains "+" */ /* set up some kind of logging until we know exactly how and where /* initialize master_status structure */ /* set the default limit */ /* seve the process limit */ /* set the default service count */ /* set the idle kill timeout */ /* since we're going to keep the config socket open anyway, open it now so we can read settings even after privileges /* logging via log service */ /* error logging goes to file or stderr */ /* something gets logged to syslog */ /* set error handlers back to file */ /* note that we don't have any settings yet. we're just finding out hardcoded state_dir path. */ /* status fd is a write-only pipe, so if we're here it means the master wants us to die (or died itself). don't die until all service connections are finished. */ /* the log fd may also be closed already, don't die when trying to /* set default signal handlers */ i_fatal(
"Must be started by dovecot master process");
/* start listening errors for status fd, it means master died */ /* we already have a connection to be served */ /* make sure we stop after servicing current connections */ /* notify master that we're not accepting any more /* anvil process was probably recreated, don't bother logging an error about losing connection to it */ i_error(
"write(anvil) failed: %m");
i_error(
"write(anvil) failed: EOF");
/* we're not going to accept any more connections after this. go ahead and close the connection early. */ /* we can listen again */ /* we've finished handling all clients, and a) master has closed the connection b) there are no listeners (std-client?) */ /* some processes should now be able to handle new connections, although we can't. but there may be race conditions, so make sure that we'll check again soon if the state has changed to "full" without our knowledge. */ /* make sure we're listening for more connections */ i_error(
"lseek(login notify fd) failed: %m");
i_error(
"close(master config fd) failed: %m");
/* we are full. stop listening for now, unless overflow callback destroys one of the existing connections */ /* it's not a socket. should be a fifo. */ /* BSDI fails accept(fifo) with EINVAL. */ i_error(
"net_accept() failed: %m");
/* try again later after one of the existing /* use the "listener" as the connection fd and stop the i_error(
"close(service connection) failed: %m");
/* reading FIFOs stays open forever, don't count them /* close via listeners. some fds might be pipes that are currently handled as clients. we don't want to close them. */ i_error(
"close(listener %d) failed: %m",
i_error(
"close(listener %d) failed: %m",
fd);
/* a) closed, b) updating to same state */ /* delayed important update sent successfully */ i_error(
"write(master_status_fd) returned %d", (
int)
ret);
i_error(
"write(master_status_fd) failed: %m");
/* reader is busy, but it's important to get this notification through. send it when possible. */