From aaf38beddb6b78d15c0e1cbca0857ea001c15b34 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 7 Dec 2015 18:16:44 +0000 Subject: [PATCH] Fix hs_helper startup --- src/hs_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/hs_helper.c b/src/hs_helper.c index 6bc9c3d18..0e912daa1 100644 --- a/src/hs_helper.c +++ b/src/hs_helper.c @@ -42,7 +42,7 @@ worker_t hs_helper_worker = { init_hs_helper, /* Init function */ start_hs_helper, /* Start function */ FALSE, /* No socket */ - FALSE, /* Unique */ + TRUE, /* Unique */ FALSE, /* Non threaded */ TRUE, /* Killable */ SOCK_STREAM /* TCP socket */ @@ -69,7 +69,7 @@ init_hs_helper (struct rspamd_config *cfg) ctx->cfg = cfg; ctx->hs_dir = RSPAMD_DBDIR "/"; - rspamd_rcl_register_worker_option (cfg, type, "cachedir", + rspamd_rcl_register_worker_option (cfg, type, "cache_dir", rspamd_rcl_parse_struct_string, ctx, G_STRUCT_OFFSET (struct hs_helper_ctx, hs_dir), 0); @@ -85,6 +85,7 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) struct stat st; glob_t globbuf; guint len, i; + gint rc; gchar *pattern; gboolean ret = TRUE; @@ -96,11 +97,11 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) } globbuf.gl_offs = 0; - len = strlen (ctx->hs_dir) + sizeof ("*.hs"); + len = strlen (ctx->hs_dir) + 1 + sizeof ("*.hs"); pattern = g_malloc (len); - rspamd_snprintf (pattern, len, "%s%s", ctx->hs_dir, "*.hs"); + rspamd_snprintf (pattern, len, "%s%c%s", ctx->hs_dir, G_DIR_SEPARATOR, "*.hs"); - if (glob (pattern, GLOB_DOOFFS, NULL, &globbuf) == 0) { + if ((rc = glob (pattern, GLOB_DOOFFS, NULL, &globbuf)) == 0) { for (i = 0; i < globbuf.gl_pathc; i++) { if (unlink (globbuf.gl_pathv[i]) == -1) { msg_err ("cannot unlink %s: %s", globbuf.gl_pathv[i], @@ -109,7 +110,7 @@ rspamd_hs_helper_cleanup_dir (struct hs_helper_ctx *ctx) } } } - else { + else if (rc != GLOB_NOMATCH) { msg_err ("glob %s failed: %s", pattern, strerror (errno)); ret = FALSE; } -- 2.39.5