struct client *client;
const struct pop3_settings *set;
const char *error;
+ int ret;
if (mail_storage_service_lookup_next(storage_service, input,
&user, &mail_user, error_r) <= 0) {
if (set->verbose_proctitle)
verbose_proctitle = TRUE;
- if (client_create(fd_in, fd_out, input->session_id,
- mail_user, user, set, &client) < 0)
- return 0;
+ client = client_create(fd_in, fd_out, input->session_id,
+ mail_user, user, set);
+
+ if (set->pop3_lock_session && (ret = pop3_lock_session(client)) <= 0) {
+ client_send_line(client, ret < 0 ?
+ "-ERR [SYS/TEMP] Failed to create POP3 session lock." :
+ "-ERR [IN-USE] Mailbox is locked by another POP3 session.");
+ client_destroy(client, "Couldn't lock POP3 session");
+ return -1;
+ }
+
if (!IS_STANDALONE())
client_send_line(client, "+OK Logged in.");
if (client_init_mailbox(client, &error) == 0)
}
}
-static int pop3_lock_session(struct client *client)
+int pop3_lock_session(struct client *client)
{
const struct mail_storage_settings *mail_set =
mail_storage_service_user_get_mail_set(client->service_user);
return ret;
}
-int client_create(int fd_in, int fd_out, const char *session_id,
- struct mail_user *user,
- struct mail_storage_service_user *service_user,
- const struct pop3_settings *set, struct client **client_r)
+struct client *client_create(int fd_in, int fd_out, const char *session_id,
+ struct mail_user *user,
+ struct mail_storage_service_user *service_user,
+ const struct pop3_settings *set)
{
struct client *client;
pool_t pool;
- int ret;
/* always use nonblocking I/O */
net_set_nonblock(fd_in, TRUE);
if (hook_client_created != NULL)
hook_client_created(&client);
- if (set->pop3_lock_session && (ret = pop3_lock_session(client)) <= 0) {
- client_send_line(client, ret < 0 ?
- "-ERR [SYS/TEMP] Failed to create POP3 session lock." :
- "-ERR [IN-USE] Mailbox is locked by another POP3 session.");
- client_destroy(client, "Couldn't lock POP3 session");
- return -1;
- }
-
- *client_r = client;
- return 0;
-
+ return client;
}
int client_init_mailbox(struct client *client, const char **error_r)
/* Create new client with specified input/output handles. socket specifies
if the handle is a socket. */
-int client_create(int fd_in, int fd_out, const char *session_id,
- struct mail_user *user,
- struct mail_storage_service_user *service_user,
- const struct pop3_settings *set, struct client **client_r);
+struct client *client_create(int fd_in, int fd_out, const char *session_id,
+ struct mail_user *user,
+ struct mail_storage_service_user *service_user,
+ const struct pop3_settings *set);
int client_init_mailbox(struct client *client, const char **error_r);
void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
void clients_destroy_all(struct mail_storage_service_ctx *storage_service);
+int pop3_lock_session(struct client *client);
+
#endif