summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 0850a29..dafeaee 100644
--- a/src/main.c
+++ b/src/main.c
@@ -19,9 +19,11 @@
#include "conntrackd.h"
#include "log.h"
+#include "helper.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <errno.h>
#include <fcntl.h>
#include <sys/utsname.h>
#include <string.h>
@@ -31,7 +33,7 @@
#include <limits.h>
struct ct_general_state st;
-union ct_state state;
+struct ct_state state;
static const char usage_daemon_commands[] =
"Daemon mode commands:\n"
@@ -49,6 +51,7 @@ static const char usage_client_commands[] =
"dump statistics\n"
" -R [ct|expect], resync with kernel conntrack table\n"
" -n, request resync with other node (only FT-FW and NOTRACK modes)\n"
+ " -B, force a bulk send to other replica firewalls\n"
" -x, dump cache in XML format (requires -i or -e)\n"
" -t, reset the kernel timeout (see PurgeTimeout clause)\n"
" -v, display conntrackd version\n"
@@ -110,6 +113,23 @@ set_action_by_table(int i, int argc, char *argv[],
return i;
}
+static void
+set_nice_value(int nv)
+{
+ errno = 0;
+ if (nice(nv) == -1 && errno) /* warn only */
+ fprintf(stderr, "Cannot set nice level %d: %s\n",
+ nv, strerror(errno));
+}
+
+static void
+do_chdir(const char *d)
+{
+ if (chdir(d))
+ fprintf(stderr, "Cannot change current directory to %s: %s\n",
+ d, strerror(errno));
+}
+
int main(int argc, char *argv[])
{
int ret, i, action = -1;
@@ -354,7 +374,7 @@ int main(int argc, char *argv[])
/*
* Setting process priority and scheduler
*/
- nice(CONFIG(nice));
+ set_nice_value(CONFIG(nice));
if (CONFIG(sched).type != SCHED_OTHER) {
struct sched_param schedparam = {
@@ -380,7 +400,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- chdir("/");
+ do_chdir("/");
close(STDIN_FILENO);
/* Daemonize conntrackd */
@@ -405,6 +425,6 @@ int main(int argc, char *argv[])
/*
* run main process
*/
- run();
+ select_main_loop();
return 0;
}