dns: dlz_bind9 reference count logging
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Mon, 15 Oct 2018 03:52:40 +0000 (16:52 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 17 Oct 2018 03:40:06 +0000 (05:40 +0200)
dlz_bind9 has to count the number of times the plugin is 'created' by bind's
plugin manager so it doesn't repeat setup.  Logging doesn't reflect this
reference counting logic properly and so messages like "samba_dlz: shutdown"
can, confusingly, come up when the database connection has not actually been
severed.  This patch adds the necessary logging.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13655
Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dns_server/dlz_bind9.c

index 054f13e6103becb315e6decc977827690d19931d..43f3e57c789a1c43ad4f801e437830a2645f6e30 100644 (file)
@@ -618,6 +618,9 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
        char *errstring = NULL;
 
        if (dlz_bind9_state != NULL) {
+               dlz_bind9_state->log(ISC_LOG_ERROR,
+                                    "samba_dlz: dlz_create ignored, #refs=%d",
+                                    dlz_bind9_state_ref_count);
                *dbdata = dlz_bind9_state;
                dlz_bind9_state_ref_count++;
                return ISC_R_SUCCESS;
@@ -743,6 +746,10 @@ _PUBLIC_ isc_result_t dlz_create(const char *dlzname,
        return ISC_R_SUCCESS;
 
 failed:
+       state->log(ISC_LOG_INFO,
+                  "samba_dlz: FAILED dlz_create call result=%d #refs=%d",
+                  result,
+                  dlz_bind9_state_ref_count);
        talloc_free(state);
        return result;
 }
@@ -753,13 +760,17 @@ failed:
 _PUBLIC_ void dlz_destroy(void *dbdata)
 {
        struct dlz_bind9_data *state = talloc_get_type_abort(dbdata, struct dlz_bind9_data);
-       state->log(ISC_LOG_INFO, "samba_dlz: shutting down");
 
        dlz_bind9_state_ref_count--;
        if (dlz_bind9_state_ref_count == 0) {
+               state->log(ISC_LOG_INFO, "samba_dlz: shutting down");
                talloc_unlink(state, state->samdb);
                talloc_free(state);
                dlz_bind9_state = NULL;
+       } else {
+               state->log(ISC_LOG_INFO,
+                          "samba_dlz: dlz_destroy called. %d refs remaining.",
+                          dlz_bind9_state_ref_count);
        }
 }