]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login proxy: Added asserts to track that num_waiting_connections are correct.
authorTimo Sirainen <tss@iki.fi>
Thu, 3 Sep 2015 22:18:04 +0000 (01:18 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 3 Sep 2015 22:18:04 +0000 (01:18 +0300)
src/login-common/login-proxy-state.c
src/login-common/login-proxy.c

index ee14bf8b68d8b26624170b619d3c6d0df51f0176..e6004ab3e64c5e377bdbde50143a5a18d903f8aa 100644 (file)
@@ -66,9 +66,17 @@ static void login_proxy_state_close(struct login_proxy_state *state)
 void login_proxy_state_deinit(struct login_proxy_state **_state)
 {
        struct login_proxy_state *state = *_state;
+       struct hash_iterate_context *iter;
+       struct login_proxy_record *rec;
 
        *_state = NULL;
 
+       /* sanity check: */
+       iter = hash_table_iterate_init(state->hash);
+       while (hash_table_iterate(iter, state->hash, &rec, &rec))
+               i_assert(rec->num_waiting_connections == 0);
+       hash_table_iterate_deinit(&iter);
+
        if (state->to_reopen != NULL)
                timeout_remove(&state->to_reopen);
        login_proxy_state_close(state);
index 88fc005232b3359cd8910cff07b73e8c528ec9b8..560df7fae92118f573ccd93ab62e64fb9efb258c 100644 (file)
@@ -202,6 +202,7 @@ static void proxy_fail_connect(struct login_proxy *proxy)
        } else {
                proxy->state_rec->last_failure = ioloop_timeval;
        }
+       i_assert(proxy->state_rec->num_waiting_connections > 0);
        proxy->state_rec->num_waiting_connections--;
        proxy->state_rec = NULL;
 }
@@ -278,6 +279,7 @@ static void proxy_wait_connect(struct login_proxy *proxy)
        }
        proxy->connected = TRUE;
        proxy->state_rec->last_success = ioloop_timeval;
+       i_assert(proxy->state_rec->num_waiting_connections > 0);
        proxy->state_rec->num_waiting_connections--;
        proxy->state_rec = NULL;
 
@@ -399,8 +401,10 @@ static void login_proxy_disconnect(struct login_proxy *proxy)
        if (proxy->to_notify != NULL)
                timeout_remove(&proxy->to_notify);
 
-       if (proxy->state_rec != NULL)
+       if (proxy->state_rec != NULL) {
+               i_assert(proxy->state_rec->num_waiting_connections > 0);
                proxy->state_rec->num_waiting_connections--;
+       }
 
        if (proxy->server_io != NULL)
                io_remove(&proxy->server_io);