Mercurial > dovecot > core-2.2
changeset 11969:b8a09fa4acc4
ssl-params: Generate missing SSL parameters immediately at Dovecot startup.
(Instead of waiting until the first SSL client connection arrives.)
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 09 Aug 2010 18:12:12 +0100 |
parents | 351948b4dc6c |
children | 59b0e70c8f14 |
files | src/ssl-params/main.c src/ssl-params/ssl-params-settings.c |
diffstat | 2 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ssl-params/main.c Mon Aug 09 18:11:18 2010 +0100 +++ b/src/ssl-params/main.c Mon Aug 09 18:12:12 2010 +0100 @@ -12,6 +12,7 @@ #include <sys/wait.h> #define SSL_BUILD_PARAM_FNAME "ssl-parameters.dat" +#define STARTUP_IDLE_TIMEOUT_MSECS 1000 struct client { int fd; @@ -21,6 +22,7 @@ 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_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 @@ 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_deinit(void) { ssl_params_deinit(¶m); + if (to_startup != NULL) + timeout_remove(&to_startup); if (array_is_created(&delayed_fds)) array_free(&delayed_fds); }
--- a/src/ssl-params/ssl-params-settings.c Mon Aug 09 18:11:18 2010 +0100 +++ b/src/ssl-params/ssl-params-settings.c Mon Aug 09 18:12:12 2010 +0100 @@ -26,7 +26,7 @@ struct service_settings ssl_params_service_settings = { .name = "ssl-params", .protocol = "", - .type = "", + .type = "startup", .executable = "ssl-params", .user = "", .group = "",