From 4aded37a3901a1f076f3b88834c3dfd994086e62 Mon Sep 17 00:00:00 2001 From: Radovan Sroka Date: Wed, 13 Mar 2019 17:49:21 +0100 Subject: [PATCH 05/11] Move some debug messages under #ifdef DEBUG (#24) --- src/database.c | 25 ++++++++++++++++++------- src/fapolicyd.c | 5 +++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/database.c b/src/database.c index 1b3dc1a..2a0c029 100644 --- a/src/database.c +++ b/src/database.c @@ -732,7 +732,9 @@ static void *update_thread_main(void *arg) struct daemon_conf *config = (struct daemon_conf *)arg; - msg(LOG_INFO, "Update thread main started"); +#ifdef DEBUG + msg(LOG_DEBUG, "Update thread main started"); +#endif /* Make sure that there is no such file/fifo */ unlink(fifo_path); @@ -752,18 +754,25 @@ static void *update_thread_main(void *arg) while (!stop) { rc = poll(pfd, 1, 1000); - msg(LOG_DEBUG, "Update poll interupted"); + +#ifdef DEBUG + msg(LOG_DEBUG, "Update poll interrupted"); +#endif if (rc < 0) { if (errno == EINTR) { +#ifdef DEBUG msg(LOG_DEBUG, "update poll rc = EINTR"); +#endif continue; } else { msg(LOG_ERR, "Update poll error (%s)", strerror_r(errno, err_buff, BUFFER_SIZE)); goto err_out; } } else if (rc == 0) { +#ifdef DEBUG msg(LOG_DEBUG, "Update poll timeout expired"); +#endif continue; } else { if (pfd[0].revents & POLLIN) { @@ -776,12 +785,14 @@ static void *update_thread_main(void *arg) } if (count == 0) { - msg(LOG_DEBUG, "Buffer contains zero bytes!"); +#ifdef DEBUG + msg(LOG_DEBUG, "Buffer contains zero bytes!"); +#endif continue; } - +#ifdef DEBUG msg(LOG_DEBUG, "Buffer contains: \"%s\"", buff); - +#endif int check = 1; for (int i = 0 ; i < count ; i++) { if (buff[i] != '1' && buff[i] != '\n' && buff[i] != '\0') { @@ -792,7 +803,7 @@ static void *update_thread_main(void *arg) } if (check) { - msg(LOG_DEBUG, "It looks like there was an update of the system... Syncing DB."); + msg(LOG_INFO, "It looks like there was an update of the system... Syncing DB."); if ((rc = update_database(config))) { msg(LOG_ERR, "Cannot update a database!"); @@ -800,7 +811,7 @@ static void *update_thread_main(void *arg) unlink(fifo_path); exit(rc); } else { - msg(LOG_DEBUG, "Updated"); + msg(LOG_INFO, "Updated"); } } } diff --git a/src/fapolicyd.c b/src/fapolicyd.c index 53d4273..6e1e987 100644 --- a/src/fapolicyd.c +++ b/src/fapolicyd.c @@ -389,8 +389,9 @@ int main(int argc, char *argv[]) while (!stop) { rc = poll(pfd, 1, -1); - msg(LOG_DEBUG, "Main poll interupted"); - +#ifdef DEBUG + msg(LOG_DEBUG, "Main poll interrupted"); +#endif if (rc < 0) { if (errno == EINTR) continue; -- 2.20.1