From: Stephan Bosch Date: Fri, 10 Nov 2017 16:18:28 +0000 (+0100) Subject: login-common: Added client_disconnect(), which allows explicitly disconnecting the... X-Git-Tag: 2.3.0.rc1~144 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfafc4ac89195b8cdd48afa619599d5b392ef479;p=thirdparty%2Fdovecot%2Fcore.git login-common: Added client_disconnect(), which allows explicitly disconnecting the client before it is destroyed. This is sometimes needed to make sure the SSL layer is closed properly before destroying the underlying connection. --- diff --git a/src/login-common/client-common.c b/src/login-common/client-common.c index 8e0cdb5bde..7171a41e71 100644 --- a/src/login-common/client-common.c +++ b/src/login-common/client-common.c @@ -228,15 +228,11 @@ void client_init(struct client *client, void **other_sets) login_refresh_proctitle(); } -void client_destroy(struct client *client, const char *reason) +void client_disconnect(struct client *client, const char *reason) { - i_assert(client->create_finished); - - if (client->destroyed) + if (client->disconnected) return; - client->destroyed = TRUE; - - pool_unref(&client->preproxy_pool); + client->disconnected = TRUE; if (!client->login_success && !client->no_extra_disconnect_reason && reason != NULL) { @@ -248,10 +244,6 @@ void client_destroy(struct client *client, const char *reason) if (reason != NULL) client_log(client, reason); - if (last_client == client) - last_client = client->prev; - DLLIST_REMOVE(&clients, client); - if (client->output != NULL) o_stream_uncork(client->output); if (!client->login_success) { @@ -272,6 +264,23 @@ void client_destroy(struct client *client, const char *reason) client_fd_proxies_count++; } } +} + +void client_destroy(struct client *client, const char *reason) +{ + i_assert(client->create_finished); + + if (client->destroyed) + return; + client->destroyed = TRUE; + + client_disconnect(client, reason); + + pool_unref(&client->preproxy_pool); + + if (last_client == client) + last_client = client->prev; + DLLIST_REMOVE(&clients, client); if (client->master_tag != 0) { i_assert(client->auth_request == NULL); diff --git a/src/login-common/client-common.h b/src/login-common/client-common.h index a947cef351..f1f7c7d14a 100644 --- a/src/login-common/client-common.h +++ b/src/login-common/client-common.h @@ -203,6 +203,7 @@ struct client { unsigned int director_username_hash_cache; bool create_finished:1; + bool disconnected:1; bool destroyed:1; bool input_blocked:1; bool login_success:1; @@ -250,6 +251,7 @@ client_alloc(int fd, pool_t pool, const struct login_settings *set, const struct master_service_ssl_settings *ssl_set); void client_init(struct client *client, void **other_sets); +void client_disconnect(struct client *client, const char *reason); void client_destroy(struct client *client, const char *reason); /* Destroy the client after a successful login. Either the client fd was sent to the post-login process, or the connection will be proxied. */