Skip to content

Commit

Permalink
imap: Add client_create_finish() to finish namespace creation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen committed Feb 19, 2018
1 parent 6dee51c commit 2a2bf4b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/imap/imap-client.c
Expand Up @@ -216,6 +216,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;
Expand Down
1 change: 1 addition & 0 deletions src/imap/imap-client.h
Expand Up @@ -255,6 +255,7 @@ 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 lda_settings *lda_set);
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 */
Expand Down
5 changes: 2 additions & 3 deletions src/imap/imap-master-client.c
Expand Up @@ -231,9 +231,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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/imap/main.c
Expand Up @@ -292,7 +292,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 */
Expand Down Expand Up @@ -337,7 +337,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)
Expand Down

0 comments on commit 2a2bf4b

Please sign in to comment.