]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
login-common: Move code in client_destroy_internal_failure() to its only caller
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 1 Nov 2017 19:15:53 +0000 (21:15 +0200)
committerTimo Sirainen <tss@dovecot.fi>
Mon, 6 Nov 2017 23:09:00 +0000 (01:09 +0200)
No need to have a function that has only a single caller.

src/login-common/client-common-auth.c
src/login-common/client-common.c
src/login-common/client-common.h

index d093aa0246e09b6d57163396736163cfcd9dce69..752b5efcd0da72a451dd1f8e045c0bdf53458c81 100644 (file)
@@ -727,13 +727,19 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
                if (shutdown(client->fd, SHUT_RDWR) < 0 && errno != ENOTCONN)
                        i_error("shutdown() failed: %m");
 
-               if (data == NULL)
-                       client_destroy_internal_failure(client);
-               else {
+               if (data != NULL) {
                        /* e.g. mail_max_userip_connections is reached */
-                       client->no_extra_disconnect_reason = TRUE;
-                       client_destroy(client, data);
+               } else {
+                       /* The error should have been logged already.
+                          The client will only see a generic internal error. */
+                       client_notify_disconnect(client, CLIENT_DISCONNECT_INTERNAL_ERROR,
+                               "Internal login failure. "
+                               "Refer to server log for more information.");
+                       data = t_strdup_printf("Internal login failure (pid=%s id=%u)",
+                                              my_pid, client->master_auth_id);
                }
+               client->no_extra_disconnect_reason = TRUE;
+               client_destroy(client, data);
                break;
        case SASL_SERVER_REPLY_CONTINUE:
                i_assert(client->v.auth_send_challenge != NULL);
index a510ddf5299218a8cef70ed4e06dc8c930844fd3..412c9cd73026645d62c17f6cc0b418c667ba76fb 100644 (file)
@@ -308,16 +308,6 @@ void client_destroy_success(struct client *client, const char *reason)
        client_destroy(client, reason);
 }
 
-void client_destroy_internal_failure(struct client *client)
-{
-       client_notify_disconnect(client, CLIENT_DISCONNECT_INTERNAL_ERROR,
-               "Internal login failure. "
-               "Refer to server log for more information.");
-       client_destroy(client, t_strdup_printf(
-               "Internal login failure (pid=%s id=%u)",
-               my_pid, client->master_auth_id));
-}
-
 void client_ref(struct client *client)
 {
        client->refcount++;
index 10e6def2b6066b7a4ff9408132f3dbf06208af56..6a84c8f09b7d668b8a0628fe78c1dcdb57be9b1c 100644 (file)
@@ -244,7 +244,6 @@ client_create(int fd, bool ssl, pool_t pool,
              void **other_sets);
 void client_destroy(struct client *client, const char *reason);
 void client_destroy_success(struct client *client, const char *reason);
-void client_destroy_internal_failure(struct client *client);
 
 void client_ref(struct client *client);
 bool client_unref(struct client **client) ATTR_NOWARN_UNUSED_RESULT;