dovecot-2.0: ssl-params: Generate missing SSL parameters immedia...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Aug 9 20:12:15 EEST 2010
details: http://hg.dovecot.org/dovecot-2.0/rev/b8a09fa4acc4
changeset: 11969:b8a09fa4acc4
user: Timo Sirainen <tss at iki.fi>
date: Mon Aug 09 18:12:12 2010 +0100
description:
ssl-params: Generate missing SSL parameters immediately at Dovecot startup.
(Instead of waiting until the first SSL client connection arrives.)
diffstat:
src/ssl-params/main.c | 14 +++++++++++++-
src/ssl-params/ssl-params-settings.c | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diffs (65 lines):
diff -r 351948b4dc6c -r b8a09fa4acc4 src/ssl-params/main.c
--- 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);
}
diff -r 351948b4dc6c -r b8a09fa4acc4 src/ssl-params/ssl-params-settings.c
--- 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 = "",
More information about the dovecot-cvs
mailing list