dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0093-DEBUG-Add-new-debug-category-for-fail-over.patch

6cf099
From ac77db34a46e36f42e917f1b6d66fee39234d5f8 Mon Sep 17 00:00:00 2001
6cf099
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
6cf099
Date: Mon, 10 Aug 2015 18:35:16 +0200
6cf099
Subject: [PATCH 93/96] DEBUG: Add new debug category for fail over.
6cf099
MIME-Version: 1.0
6cf099
Content-Type: text/plain; charset=UTF-8
6cf099
Content-Transfer-Encoding: 8bit
6cf099
6cf099
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
6cf099
(cherry picked from commit c4fb8f55f2894de431478ccfec63f9a97e090d0e)
6cf099
---
6cf099
 src/providers/data_provider_fo.c | 30 ++++++++++++++++++++++++++----
6cf099
 src/providers/dp_backend.h       | 15 +++++++++++----
6cf099
 src/tests/debug-tests.c          |  2 +-
6cf099
 src/util/debug.c                 |  2 +-
6cf099
 src/util/util.h                  |  1 +
6cf099
 5 files changed, 40 insertions(+), 10 deletions(-)
6cf099
6cf099
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
6cf099
index dab796d4647a552c2fd1c626c490278de91c2e81..41d70de065260f31dcea4c2b664a1f436823ccc1 100644
6cf099
--- a/src/providers/data_provider_fo.c
6cf099
+++ b/src/providers/data_provider_fo.c
6cf099
@@ -743,13 +743,35 @@ void reset_fo(struct be_ctx *be_ctx)
6cf099
     fo_reset_services(be_ctx->be_fo->fo_ctx);
6cf099
 }
6cf099
 
6cf099
-void be_fo_set_port_status(struct be_ctx *ctx,
6cf099
-                           const char *service_name,
6cf099
-                           struct fo_server *server,
6cf099
-                           enum port_status status)
6cf099
+void _be_fo_set_port_status(struct be_ctx *ctx,
6cf099
+                            const char *service_name,
6cf099
+                            struct fo_server *server,
6cf099
+                            enum port_status status,
6cf099
+                            int line,
6cf099
+                            const char *file,
6cf099
+                            const char *function)
6cf099
 {
6cf099
     struct be_svc_data *be_svc;
6cf099
 
6cf099
+    /* Print debug info */
6cf099
+    switch (status) {
6cf099
+    case PORT_NEUTRAL:
6cf099
+        DEBUG(SSSDBG_BE_FO,
6cf099
+              "Setting status: PORT_NEUTRAL. Called from: %s: %s: %d\n",
6cf099
+              file, function, line);
6cf099
+        break;
6cf099
+    case PORT_WORKING:
6cf099
+        DEBUG(SSSDBG_BE_FO,
6cf099
+              "Setting status: PORT_WORKING. Called from: %s: %s: %d\n",
6cf099
+              file, function, line);
6cf099
+        break;
6cf099
+    case PORT_NOT_WORKING:
6cf099
+        DEBUG(SSSDBG_BE_FO,
6cf099
+              "Setting status: PORT_NOT_WORKING. Called from: %s: %s: %d\n",
6cf099
+              file, function, line);
6cf099
+        break;
6cf099
+    }
6cf099
+
6cf099
     be_svc = be_fo_find_svc_data(ctx, service_name);
6cf099
     if (be_svc == NULL) {
6cf099
         DEBUG(SSSDBG_OP_FAILURE,
6cf099
diff --git a/src/providers/dp_backend.h b/src/providers/dp_backend.h
6cf099
index 4d54bf547682379bcb8cf855b8fae39214495728..4bffcee9e8739302343b7813d3540eb43e966581 100644
6cf099
--- a/src/providers/dp_backend.h
6cf099
+++ b/src/providers/dp_backend.h
6cf099
@@ -260,10 +260,17 @@ struct tevent_req *be_resolve_server_send(TALLOC_CTX *memctx,
6cf099
                                           bool first_try);
6cf099
 int be_resolve_server_recv(struct tevent_req *req, struct fo_server **srv);
6cf099
 
6cf099
-void be_fo_set_port_status(struct be_ctx *ctx,
6cf099
-                           const char *service_name,
6cf099
-                           struct fo_server *server,
6cf099
-                           enum port_status status);
6cf099
+#define be_fo_set_port_status(ctx, service_name, server, status) \
6cf099
+    _be_fo_set_port_status(ctx, service_name, server, status, \
6cf099
+                           __LINE__, __FILE__, __FUNCTION__)
6cf099
+
6cf099
+void _be_fo_set_port_status(struct be_ctx *ctx,
6cf099
+                            const char *service_name,
6cf099
+                            struct fo_server *server,
6cf099
+                            enum port_status status,
6cf099
+                            int line,
6cf099
+                            const char *file,
6cf099
+                            const char *function);
6cf099
 
6cf099
 /*
6cf099
  * Instruct fail-over to try next server on the next connect attempt.
6cf099
diff --git a/src/tests/debug-tests.c b/src/tests/debug-tests.c
6cf099
index 2b91c149d79483316794240498e7fe33545dede0..067209b1dda1c445b971bcec7108d0b886d55e53 100644
6cf099
--- a/src/tests/debug-tests.c
6cf099
+++ b/src/tests/debug-tests.c
6cf099
@@ -48,7 +48,7 @@ START_TEST(test_debug_convert_old_level_old_format)
6cf099
         SSSDBG_TRACE_FUNC,
6cf099
         SSSDBG_TRACE_LIBS,
6cf099
         SSSDBG_TRACE_INTERNAL,
6cf099
-        SSSDBG_TRACE_ALL
6cf099
+        SSSDBG_TRACE_ALL | SSSDBG_BE_FO
6cf099
     };
6cf099
 
6cf099
     for (old_level = 0; old_level <= 9; old_level++) {
6cf099
diff --git a/src/util/debug.c b/src/util/debug.c
6cf099
index bf83624c98769c4c53d9c25522712a9705b26ed2..69df54386101973548108c3194a1bfd111f046f0 100644
6cf099
--- a/src/util/debug.c
6cf099
+++ b/src/util/debug.c
6cf099
@@ -114,7 +114,7 @@ int debug_convert_old_level(int old_level)
6cf099
         new_level |= SSSDBG_TRACE_INTERNAL;
6cf099
 
6cf099
     if (old_level >= 9)
6cf099
-        new_level |= SSSDBG_TRACE_ALL;
6cf099
+        new_level |= SSSDBG_TRACE_ALL | SSSDBG_BE_FO;
6cf099
 
6cf099
     return new_level;
6cf099
 }
6cf099
diff --git a/src/util/util.h b/src/util/util.h
6cf099
index 4655e90a89b0ff3c457b80c943aefc4d6cf8e21f..f9fe1ca7189c6b2cdcb29f143005b20a2d969fee 100644
6cf099
--- a/src/util/util.h
6cf099
+++ b/src/util/util.h
6cf099
@@ -92,6 +92,7 @@ int get_fd_from_debug_file(void);
6cf099
 #define SSSDBG_TRACE_LIBS     0x1000   /* level 7 */
6cf099
 #define SSSDBG_TRACE_INTERNAL 0x2000   /* level 8 */
6cf099
 #define SSSDBG_TRACE_ALL      0x4000   /* level 9 */
6cf099
+#define SSSDBG_BE_FO          0x8000   /* level 9 */
6cf099
 #define SSSDBG_IMPORTANT_INFO SSSDBG_OP_FAILURE
6cf099
 
6cf099
 #define SSSDBG_INVALID        -1
6cf099
-- 
6cf099
2.4.3
6cf099