#include <sys/wait.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;
static void client_deinit(struct ostream *output)
{
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 */
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);
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);
}