From: Timo Sirainen Date: Mon, 9 Aug 2010 17:12:12 +0000 (+0100) Subject: ssl-params: Generate missing SSL parameters immediately at Dovecot startup. X-Git-Tag: 2.0.rc5~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=78ef6bc5bbe372c119b8b790be19ad3026830507;p=thirdparty%2Fdovecot%2Fcore.git ssl-params: Generate missing SSL parameters immediately at Dovecot startup. (Instead of waiting until the first SSL client connection arrives.) --- diff --git a/src/ssl-params/main.c b/src/ssl-params/main.c index 76cd4b8060..17c66d36b5 100644 --- a/src/ssl-params/main.c +++ b/src/ssl-params/main.c @@ -12,6 +12,7 @@ #include #define SSL_BUILD_PARAM_FNAME "ssl-parameters.dat" +#define STARTUP_IDLE_TIMEOUT_MSECS 1000 struct client { int fd; @@ -21,6 +22,7 @@ struct client { static ARRAY_DEFINE(delayed_fds, int); struct ssl_params *param; static buffer_t *ssl_params; +static struct timeout *to_startup; static void client_deinit(struct ostream *output) { @@ -56,6 +58,8 @@ static void client_handle(int fd) static void client_connected(struct master_service_connection *conn) { + if (to_startup != NULL) + timeout_remove(&to_startup); master_service_client_connection_accept(conn); if (ssl_params->used == 0) { /* waiting for parameter building to finish */ @@ -74,8 +78,14 @@ static void ssl_params_callback(const unsigned char *data, size_t size) buffer_set_used_size(ssl_params, 0); buffer_append(ssl_params, data, size); - if (!array_is_created(&delayed_fds)) + if (!array_is_created(&delayed_fds)) { + /* master ran us at startup to make sure ssl parameters + are generated asap. we may not be needed for a while + (or ever), so kill ourself now. */ + to_startup = timeout_add(STARTUP_IDLE_TIMEOUT_MSECS, + master_service_stop, master_service); return; + } array_foreach(&delayed_fds, fds) client_handle(*fds); @@ -108,6 +118,8 @@ static void main_init(const struct ssl_params_settings *set) static void main_deinit(void) { ssl_params_deinit(¶m); + if (to_startup != NULL) + timeout_remove(&to_startup); if (array_is_created(&delayed_fds)) array_free(&delayed_fds); } diff --git a/src/ssl-params/ssl-params-settings.c b/src/ssl-params/ssl-params-settings.c index bf7a9dd452..75d26d0a98 100644 --- a/src/ssl-params/ssl-params-settings.c +++ b/src/ssl-params/ssl-params-settings.c @@ -26,7 +26,7 @@ static buffer_t ssl_params_unix_listeners_buf = { struct service_settings ssl_params_service_settings = { .name = "ssl-params", .protocol = "", - .type = "", + .type = "startup", .executable = "ssl-params", .user = "", .group = "",