dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone
Blob Blame History Raw
From ac77db34a46e36f42e917f1b6d66fee39234d5f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
Date: Mon, 10 Aug 2015 18:35:16 +0200
Subject: [PATCH 93/96] DEBUG: Add new debug category for fail over.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
(cherry picked from commit c4fb8f55f2894de431478ccfec63f9a97e090d0e)
---
 src/providers/data_provider_fo.c | 30 ++++++++++++++++++++++++++----
 src/providers/dp_backend.h       | 15 +++++++++++----
 src/tests/debug-tests.c          |  2 +-
 src/util/debug.c                 |  2 +-
 src/util/util.h                  |  1 +
 5 files changed, 40 insertions(+), 10 deletions(-)

diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
index dab796d4647a552c2fd1c626c490278de91c2e81..41d70de065260f31dcea4c2b664a1f436823ccc1 100644
--- a/src/providers/data_provider_fo.c
+++ b/src/providers/data_provider_fo.c
@@ -743,13 +743,35 @@ void reset_fo(struct be_ctx *be_ctx)
     fo_reset_services(be_ctx->be_fo->fo_ctx);
 }
 
-void be_fo_set_port_status(struct be_ctx *ctx,
-                           const char *service_name,
-                           struct fo_server *server,
-                           enum port_status status)
+void _be_fo_set_port_status(struct be_ctx *ctx,
+                            const char *service_name,
+                            struct fo_server *server,
+                            enum port_status status,
+                            int line,
+                            const char *file,
+                            const char *function)
 {
     struct be_svc_data *be_svc;
 
+    /* Print debug info */
+    switch (status) {
+    case PORT_NEUTRAL:
+        DEBUG(SSSDBG_BE_FO,
+              "Setting status: PORT_NEUTRAL. Called from: %s: %s: %d\n",
+              file, function, line);
+        break;
+    case PORT_WORKING:
+        DEBUG(SSSDBG_BE_FO,
+              "Setting status: PORT_WORKING. Called from: %s: %s: %d\n",
+              file, function, line);
+        break;
+    case PORT_NOT_WORKING:
+        DEBUG(SSSDBG_BE_FO,
+              "Setting status: PORT_NOT_WORKING. Called from: %s: %s: %d\n",
+              file, function, line);
+        break;
+    }
+
     be_svc = be_fo_find_svc_data(ctx, service_name);
     if (be_svc == NULL) {
         DEBUG(SSSDBG_OP_FAILURE,
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
index 4d54bf547682379bcb8cf855b8fae39214495728..4bffcee9e8739302343b7813d3540eb43e966581 100644
--- a/src/providers/dp_backend.h
+++ b/src/providers/dp_backend.h
@@ -260,10 +260,17 @@ struct tevent_req *be_resolve_server_send(TALLOC_CTX *memctx,
                                           bool first_try);
 int be_resolve_server_recv(struct tevent_req *req, struct fo_server **srv);
 
-void be_fo_set_port_status(struct be_ctx *ctx,
-                           const char *service_name,
-                           struct fo_server *server,
-                           enum port_status status);
+#define be_fo_set_port_status(ctx, service_name, server, status) \
+    _be_fo_set_port_status(ctx, service_name, server, status, \
+                           __LINE__, __FILE__, __FUNCTION__)
+
+void _be_fo_set_port_status(struct be_ctx *ctx,
+                            const char *service_name,
+                            struct fo_server *server,
+                            enum port_status status,
+                            int line,
+                            const char *file,
+                            const char *function);
 
 /*
  * Instruct fail-over to try next server on the next connect attempt.
diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c
index 2b91c149d79483316794240498e7fe33545dede0..067209b1dda1c445b971bcec7108d0b886d55e53 100644
--- a/src/tests/debug-tests.c
+++ b/src/tests/debug-tests.c
@@ -48,7 +48,7 @@ START_TEST(test_debug_convert_old_level_old_format)
         SSSDBG_TRACE_FUNC,
         SSSDBG_TRACE_LIBS,
         SSSDBG_TRACE_INTERNAL,
-        SSSDBG_TRACE_ALL
+        SSSDBG_TRACE_ALL | SSSDBG_BE_FO
     };
 
     for (old_level = 0; old_level <= 9; old_level++) {
diff --git a/src/util/debug.c b/src/util/debug.c
index bf83624c98769c4c53d9c25522712a9705b26ed2..69df54386101973548108c3194a1bfd111f046f0 100644
--- a/src/util/debug.c
+++ b/src/util/debug.c
@@ -114,7 +114,7 @@ int debug_convert_old_level(int old_level)
         new_level |= SSSDBG_TRACE_INTERNAL;
 
     if (old_level >= 9)
-        new_level |= SSSDBG_TRACE_ALL;
+        new_level |= SSSDBG_TRACE_ALL | SSSDBG_BE_FO;
 
     return new_level;
 }
diff --git a/src/util/util.h b/src/util/util.h
index 4655e90a89b0ff3c457b80c943aefc4d6cf8e21f..f9fe1ca7189c6b2cdcb29f143005b20a2d969fee 100644
--- a/src/util/util.h
+++ b/src/util/util.h
@@ -92,6 +92,7 @@ int get_fd_from_debug_file(void);
 #define SSSDBG_TRACE_LIBS     0x1000   /* level 7 */
 #define SSSDBG_TRACE_INTERNAL 0x2000   /* level 8 */
 #define SSSDBG_TRACE_ALL      0x4000   /* level 9 */
+#define SSSDBG_BE_FO          0x8000   /* level 9 */
 #define SSSDBG_IMPORTANT_INFO SSSDBG_OP_FAILURE
 
 #define SSSDBG_INVALID        -1
-- 
2.4.3