Code

sysdbd: Ignore SIGPIPE (e.g. when a client connection was aborted).
[sysdb.git] / src / tools / sysdbd / main.c
index 195d494ffc77811e127ee7834974b4778466edf5..9828bf0881bd1c6510b8c3bef22ef567ad776fa1 100644 (file)
@@ -34,6 +34,7 @@
 #include "core/store.h"
 #include "utils/error.h"
 
+#include "frontend/connection.h"
 #include "frontend/sock.h"
 
 #include "tools/sysdbd/configfile.h"
@@ -105,7 +106,7 @@ exit_version(void)
        printf("SysDBd version "SDB_VERSION_STRING SDB_VERSION_EXTRA", "
                        "built "BUILD_DATE"\n"
                        "using libsysdb version %s%s\n"
-                       "Copyright (C) 2012-2013 "PACKAGE_MAINTAINER"\n"
+                       "Copyright (C) 2012-2014 "PACKAGE_MAINTAINER"\n"
 
                        "\nThis is free software under the terms of the BSD license, see "
                        "the source for\ncopying conditions. There is NO WARRANTY; not "
@@ -261,6 +262,10 @@ main(int argc, char **argv)
        sdb_plugin_init_all();
        plugin_main_loop.default_interval = SECS_TO_SDB_TIME(60);
 
+       /* ignore, we see this, for example, if a client disconnects without
+        * closing the connection cleanly */
+       signal(SIGPIPE, SIG_IGN);
+
        memset(&backend_thread, 0, sizeof(backend_thread));
        if (pthread_create(&backend_thread, /* attr = */ NULL,
                                backend_handler, /* arg = */ NULL)) {
@@ -278,6 +283,8 @@ main(int argc, char **argv)
                        if (sdb_fe_sock_add_listener(sock, listen_addresses[i]))
                                break;
 
+               sdb_connection_enable_logging();
+
                /* break on error */
                if (i >= listen_addresses_num)
                        sdb_fe_sock_listen_and_serve(sock, &frontend_main_loop);