Better debug messages for kqueue event insertion and signal pipes
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 17 Nov 2014 06:23:02 +0000 (01:23 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 17 Nov 2014 06:35:33 +0000 (01:35 -0500)
src/lib/event.c
src/main/process.c

index 81d067e..19b565b 100644 (file)
@@ -372,7 +372,7 @@ int fr_event_fd_insert(fr_event_list_t *el, int type, int fd,
                 */
                EV_SET(&evset, fd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, &el->readers[j]);
                if (kevent(el->kq, &evset, 1, NULL, 0, NULL) < 0) {
-                       fprintf(stderr, "SHIT %d %s\n", __LINE__, strerror(errno));
+                       fr_strerror_printf("Failed inserting event for FD %i: %s", fd, fr_syserror(errno));
                        return 0;
                }
 
index bf4aa2e..0a092cd 100644 (file)
@@ -4973,32 +4973,28 @@ int radius_event_start(CONF_SECTION *cs, bool have_children)
         *      signal handlers.
         */
        if (pipe(self_pipe) < 0) {
-               ERROR("radiusd: Error opening internal pipe: %s",
-                      fr_syserror(errno));
+               ERROR("Error opening internal pipe: %s", fr_syserror(errno));
                fr_exit(1);
        }
        if ((fcntl(self_pipe[0], F_SETFL, O_NONBLOCK) < 0) ||
            (fcntl(self_pipe[0], F_SETFD, FD_CLOEXEC) < 0)) {
-               ERROR("radiusd: Error setting internal flags: %s",
-                      fr_syserror(errno));
+               ERROR("Error setting internal flags: %s", fr_syserror(errno));
                fr_exit(1);
        }
        if ((fcntl(self_pipe[1], F_SETFL, O_NONBLOCK) < 0) ||
            (fcntl(self_pipe[1], F_SETFD, FD_CLOEXEC) < 0)) {
-               ERROR("radiusd: Error setting internal flags: %s",
-                      fr_syserror(errno));
+               ERROR("Error setting internal flags: %s", fr_syserror(errno));
                fr_exit(1);
        }
+       DEBUG4("Created signal pipe.  Read end FD %i, write end FD %i", self_pipe[0], self_pipe[1]);
 
-       if (!fr_event_fd_insert(el, 0, self_pipe[0],
-                                 event_signal_handler, el)) {
-               ERROR("Failed creating handler for signals");
+       if (!fr_event_fd_insert(el, 0, self_pipe[0], event_signal_handler, el)) {
+               ERROR("Failed creating signal pipe handler: %s", fr_strerror());
                fr_exit(1);
        }
 #endif
 
-       DEBUG("%s: #### Opening IP addresses and Ports ####",
-              main_config.name);
+       DEBUG("%s: #### Opening IP addresses and Ports ####", main_config.name);
 
        /*
        *       The server temporarily switches to an unprivileged