diff options
author | Simo Sorce <idra@samba.org> | 2008-10-07 07:43:53 -0400 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2008-10-07 07:43:53 -0400 |
commit | a53047557987563691b2ab902fe6f5103707ff8a (patch) | |
tree | 801e1f814f76f578476b825a8276f29f5c662a23 | |
parent | b4cd915ef70f74427d71cde238db56a1876b5b06 (diff) | |
download | sssd-a53047557987563691b2ab902fe6f5103707ff8a.tar.gz sssd-a53047557987563691b2ab902fe6f5103707ff8a.tar.bz2 sssd-a53047557987563691b2ab902fe6f5103707ff8a.zip |
Add primitive debugging capabilities.
So far debug goes to stderr so sssd need to be run int interactive
mode (-i option)
-rw-r--r-- | server/nss/nsssrv.c | 7 | ||||
-rw-r--r-- | server/server.mk | 2 | ||||
-rw-r--r-- | server/util/util.h | 11 |
3 files changed, 16 insertions, 4 deletions
diff --git a/server/nss/nsssrv.c b/server/nss/nsssrv.c index 176da520..5ade80ec 100644 --- a/server/nss/nsssrv.c +++ b/server/nss/nsssrv.c @@ -27,6 +27,7 @@ #include <sys/un.h> #include <string.h> #include <sys/time.h> +#include <errno.h> #include "talloc.h" #include "events.h" #include "util/util.h" @@ -167,7 +168,7 @@ static void accept_fd_handler(struct event_context *ev, len = sizeof(cctx->addr); cctx->cfd = accept(nctx->lfd, (struct sockaddr *)&cctx->addr, &len); if (cctx->cfd == -1) { - DEBUG(1, ("Accept failed [%s]", strerror(errno))); + DEBUG(0, ("Accept failed [%s]", strerror(errno))); talloc_free(cctx); return; } @@ -177,11 +178,13 @@ static void accept_fd_handler(struct event_context *ev, if (!cctx->cfde) { close(cctx->cfd); talloc_free(cctx); - DEBUG(1, ("Failed to queue client handler\n")); + DEBUG(0, ("Failed to queue client handler\n")); } talloc_set_destructor(cctx, client_destructor); + DEBUG(2, ("Client connected!\n")); + return; } diff --git a/server/server.mk b/server/server.mk index 3f2a66ba..89916af1 100644 --- a/server/server.mk +++ b/server/server.mk @@ -1,4 +1,4 @@ -SERVER_OBJ = server.o monitor.o process.o service.o service_task.o util/signal.o util/become_daemon.o nss/nsssrv.o nss/nsssrv_packet.o nss/nsssrv_cmd.o +SERVER_OBJ = server.o monitor.o process.o service.o service_task.o util/debug.o util/signal.o util/become_daemon.o nss/nsssrv.o nss/nsssrv_packet.o nss/nsssrv_cmd.o install:: all ${INSTALLCMD} -d $(DESTDIR)$(sbindir) diff --git a/server/util/util.h b/server/util/util.h index 495e3a24..1ca35930 100644 --- a/server/util/util.h +++ b/server/util/util.h @@ -1,9 +1,18 @@ #ifndef __SSSD_UTIL_H__ #define __SSSD_UTIL_H__ +#include <stdio.h> #include <stdbool.h> -#define DEBUG(level, body) +extern int debug_level; +void debug_fn(const char *format, ...); + +#define DEBUG(level, body) do { \ + if (level <= debug_level) { \ + debug_fn("%s[%s]: ", __location__, __FUNCTION__); \ + debug_fn body; \ + } \ +} while(0); #define DEBUGADD(level, body) #ifndef discard_const |