main.c revision 5f5870385cff47efd2f58e7892f251cf13761528
/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "lib-signals.h"
#include "array.h"
#include "ostream.h"
#include "restrict-access.h"
#include "master-service.h"
#include "ssl-params-settings.h"
#include "ssl-params.h"
#define SSL_BUILD_PARAM_FNAME "ssl-parameters.dat"
#define STARTUP_IDLE_TIMEOUT_MSECS 1000
struct client {
int fd;
};
static ARRAY_DEFINE(delayed_fds, int);
struct ssl_params *param;
static buffer_t *ssl_params;
static struct timeout *to_startup;
{
}
{
if (o_stream_flush(output) == 0) {
/* more to come */
return 0;
}
/* finished / disconnected */
return -1;
}
static void client_handle(int fd)
{
if (o_stream_get_buffer_used_size(output) == 0)
else {
output);
}
}
{
if (to_startup != NULL)
if (ssl_params->used == 0) {
/* waiting for parameter building to finish */
if (!array_is_created(&delayed_fds))
} else {
}
}
{
const int *fds;
if (!array_is_created(&delayed_fds)) {
/* if we don't get client connections soon, it means master
ran us at startup to make sure ssl parameters are generated
asap. if we're here because of that, don't bother hanging
around to see if we get any client connections. */
if (to_startup == NULL) {
}
return;
}
client_handle(*fds);
}
{
int status;
i_error("waitpid() failed: %m");
else if (status != 0)
else {
/* params should have been created now. try refreshing. */
}
}
{
}
static void main_deinit(void)
{
if (to_startup != NULL)
if (array_is_created(&delayed_fds))
}
{
const struct ssl_params_settings *set;
if (master_getopt(master_service) > 0)
return FATAL_DEFAULT;
#ifndef HAVE_SSL
i_fatal("Dovecot built without SSL support");
#endif
main_deinit();
return 0;
}