Mercurial > dovecot > core-2.2
changeset 1363:383e4b9e347c HEAD
Crashfix if there was some errors while opening mailbox
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 16 Apr 2003 17:24:12 +0300 |
parents | 085c5b7a69ad |
children | 33426716797a |
files | src/pop3/client.c src/pop3/client.h src/pop3/main.c |
diffstat | 3 files changed, 19 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/src/pop3/client.c Wed Apr 16 16:57:21 2003 +0300 +++ b/src/pop3/client.c Wed Apr 16 17:24:12 2003 +0300 @@ -103,7 +103,7 @@ return FALSE; } -struct client *client_create(int hin, int hout, struct mailbox *mailbox) +struct client *client_create(int hin, int hout, struct mail_storage *storage) { struct client *client; @@ -119,21 +119,24 @@ client->io = io_add(hin, IO_READ, client_input, client); client->last_input = ioloop_time; + client->storage = storage; - client->storage = mailbox->storage; - client->mailbox = mailbox; + storage->set_callbacks(storage, &mail_storage_callbacks, client); - mailbox->storage->set_callbacks(mailbox->storage, - &mail_storage_callbacks, client); + client->mailbox = storage->open_mailbox(storage, "INBOX", FALSE, FALSE); + if (client->mailbox == NULL) { + client_send_line(client, "-ERR No INBOX for user."); + return NULL; + } + + if (!init_mailbox(client)) { + client_destroy(client); + return NULL; + } i_assert(my_client == NULL); my_client = client; - if (!init_mailbox(client)) { - client_destroy(client); - client = NULL; - } - return client; }
--- a/src/pop3/client.h Wed Apr 16 16:57:21 2003 +0300 +++ b/src/pop3/client.h Wed Apr 16 17:24:12 2003 +0300 @@ -27,7 +27,7 @@ /* Create new client with specified input/output handles. socket specifies if the handle is a socket. */ -struct client *client_create(int hin, int hout, struct mailbox *mailbox); +struct client *client_create(int hin, int hout, struct mail_storage *storage); void client_destroy(struct client *client); /* Disconnect client connection */
--- a/src/pop3/main.c Wed Apr 16 16:57:21 2003 +0300 +++ b/src/pop3/main.c Wed Apr 16 17:24:12 2003 +0300 @@ -56,11 +56,10 @@ restrict_access_by_env(!IS_STANDALONE()); } -static void main_init(void) +static int main_init(void) { struct client *client; struct mail_storage *storage; - struct mailbox *mailbox; const char *mail; lib_init_signals(sig_quit); @@ -95,11 +94,8 @@ } } - mailbox = storage->open_mailbox(storage, "INBOX", FALSE, FALSE); - if (mailbox == NULL) - i_fatal("No INBOX for user"); - - client = client_create(0, 1, mailbox); + client = client_create(0, 1, storage); + return client != NULL; } static void main_deinit(void) @@ -129,8 +125,8 @@ process_title_init(argv, envp); ioloop = io_loop_create(system_pool); - main_init(); - io_loop_run(ioloop); + if (main_init()) + io_loop_run(ioloop); main_deinit(); io_loop_destroy(ioloop);