]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Add client_create_finish() to finish namespace creation.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 15 Feb 2018 16:15:16 +0000 (18:15 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 16 Feb 2018 13:19:20 +0000 (15:19 +0200)
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-master-client.c
src/imap/main.c

index 175c356817d6528d46c9ed86775c08265fab03e1..e8cc6069a20db0fc835e1302dbb94d7283b741a1 100644 (file)
@@ -223,6 +223,13 @@ struct client *client_create(int fd_in, int fd_out, const char *session_id,
        return client;
 }
 
+int client_create_finish(struct client *client, const char **error_r)
+{
+       if (mail_namespaces_init(client->user, error_r) < 0)
+               return -1;
+       return 0;
+}
+
 void client_command_cancel(struct client_command_context **_cmd)
 {
        struct client_command_context *cmd = *_cmd;
index fc5edb7ba166fa9ae77afb27b97a6617e9a2c4b2..d53dc1624d66b8cb77935788f63f45ca600735e8 100644 (file)
@@ -257,6 +257,8 @@ struct client *client_create(int fd_in, int fd_out, const char *session_id,
                             struct mail_storage_service_user *service_user,
                             const struct imap_settings *set,
                             const struct smtp_submit_settings *smtp_set);
+/* Finish creating the client. Returns 0 if ok, -1 if there's an error. */
+int client_create_finish(struct client *client, const char **error_r);
 void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 
 /* Disconnect client connection */
index f487d2c4e1784a0f78a89d2f53c7661e0fb2ef15..d7dd8359e67670a5f2470a5cefdb3a0824b8892f 100644 (file)
@@ -233,9 +233,8 @@ imap_master_client_input_args(struct connection *conn, const char *const *args,
        }
        client->imap_client_created = TRUE;
 
-       if (mail_namespaces_init(imap_client->user, &error) < 0) {
-               i_error("imap-master(%s): mail_namespaces_init() failed: %s",
-                       input.username, error);
+       if (client_create_finish(imap_client, &error) < 0) {
+               i_error("imap-master(%s): %s", input.username, error);
                client_destroy(imap_client, error);
                return -1;
        }
index 782da13d580c86e721286f86921a4df29d179949..9b5e435ea0e2385e64953b4f90e93f90e511cf71 100644 (file)
@@ -319,7 +319,7 @@ static void main_stdio_run(const char *username)
                client_add_input_capability(client, input_buf->data, input_buf->used);
        }
 
-       if (mail_namespaces_init(client->user, &error) < 0)
+       if (client_create_finish(client, &error) < 0)
                i_fatal("%s", error);
        client_add_input_finalize(client);
        /* client may be destroyed now */
@@ -369,7 +369,7 @@ login_client_connected(const struct master_login_client *login_client,
                         login_client->auth_req.data_size);
 
        /* finish initializing the user (see comment in main()) */
-       if (mail_namespaces_init(client->user, &error) < 0) {
+       if (client_create_finish(client, &error) < 0) {
                if (write_full(login_client->fd, MSG_BYE_INTERNAL_ERROR,
                               strlen(MSG_BYE_INTERNAL_ERROR)) < 0)
                        if (errno != EAGAIN && errno != EPIPE)