aboutsummaryrefslogtreecommitdiffstats
path: root/src/controller.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-09-02 20:24:41 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-09-02 20:24:41 +0400
commit07a2e0b3c8ac8249f35423ab79b23b6b5ab11c51 (patch)
tree231437d521e228e95de289f15b1fcc4878db4b03 /src/controller.c
parent5086821ae43d0283ed8b839c847ca267c3c81d2c (diff)
downloadrspamd-07a2e0b3c8ac8249f35423ab79b23b6b5ab11c51.tar.gz
rspamd-07a2e0b3c8ac8249f35423ab79b23b6b5ab11c51.zip
* Many fixes to statfile syncronization system
* Fixed statfile pool initialization and synchronization with disk
Diffstat (limited to 'src/controller.c')
-rw-r--r--src/controller.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/controller.c b/src/controller.c
index f3cdc74de..bbf50d646 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -87,6 +87,7 @@ static GCompletion *comp;
static time_t start_time;
static char greetingbuf[1024];
+static sig_atomic_t wanna_die = 0;
extern rspamd_hash_t *counters;
static gboolean controller_write_socket (void *arg);
@@ -99,13 +100,23 @@ static void
sig_handler (int signo, siginfo_t *info, void *unused)
#endif
{
+ struct timeval tv;
switch (signo) {
case SIGUSR1:
reopen_log ();
break;
case SIGINT:
case SIGTERM:
- _exit (1);
+ if (!wanna_die) {
+ wanna_die = 1;
+ tv.tv_sec = 0;
+ tv.tv_usec = 0;
+ event_loopexit (&tv);
+
+#ifdef WITH_GPERF_TOOLS
+ ProfilerStop ();
+#endif
+ }
break;
}
}
@@ -308,17 +319,19 @@ process_sync_command (struct controller_session *session, char **args)
while (binlog_sync (binlog, rev, &time, &data)) {
r = rspamd_snprintf (out_buf, sizeof (out_buf), "%ul %ul %ul" CRLF, (long unsigned)rev, (long unsigned)time, (long unsigned)data->len);
- if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, TRUE, FALSE)) {
+ if (! rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE)) {
if (data != NULL) {
g_free (data);
}
return FALSE;
}
- if (!rspamd_dispatcher_write (session->dispatcher, data->data, data->len, TRUE, FALSE)) {
- if (data != NULL) {
- g_free (data);
+ if (data->data != NULL) {
+ if (!rspamd_dispatcher_write (session->dispatcher, data->data, data->len, TRUE, FALSE)) {
+ if (data != NULL) {
+ g_free (data);
+ }
+ return FALSE;
}
- return FALSE;
}
rev ++;
}
@@ -645,6 +658,12 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control
}
return TRUE;
}
+ else {
+ if (! rspamd_dispatcher_write (session->dispatcher, CRLF, sizeof (CRLF) - 1, FALSE, TRUE)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
break;
case COMMAND_HELP:
r = rspamd_snprintf (out_buf, sizeof (out_buf),