io_remove(client->common.io);
client->common.io = client->common.fd == -1 ? NULL :
io_add(client->common.fd, IO_READ, client_input, client);
+
+ client_unref(client);
}
static void master_callback(struct client *_client, int success)
disconnect the client. */
client->authenticating = FALSE;
client_send_tagline(client, "OK Logged in.");
+ client_unref(client);
}
}
buffer_append_c(client->plain_login, '\0');
buffer_append(client->plain_login, pass, strlen(pass));
+ client_ref(client);
client->common.auth_request =
auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
AUTH_PROTOCOL_IMAP, login_callback,
if (client->common.auth_request == NULL) {
client_send_tagline(client, t_strconcat(
"NO Login failed: ", error, NULL));
+ client_unref(client);
return TRUE;
}
disconnect the client. */
client->authenticating = FALSE;
client_send_tagline(client, "OK Logged in.");
+ client_unref(client);
}
}
return TRUE;
}
+ client_ref(client);
client->common.auth_request =
auth_client_request_new(auth_client, mech->mech,
AUTH_PROTOCOL_IMAP,
} else {
client_send_tagline(client, t_strconcat(
"NO Authentication failed: ", error, NULL));
+ client_unref(client);
}
return TRUE;
static struct hash_table *clients;
static struct timeout *to_idle;
-static int client_unref(struct imap_client *client);
-
static void client_set_title(struct imap_client *client)
{
const char *addr;
return;
}
- client->refcount++;
+ client_ref(client);
o_stream_cork(client->output);
while (client_handle_input(client)) ;
client_unref(client);
}
-static int client_unref(struct imap_client *client)
+void client_ref(struct imap_client *client)
+{
+ client->refcount++;
+}
+
+int client_unref(struct imap_client *client)
{
if (--client->refcount > 0)
return TRUE;
int client_read(struct imap_client *client);
void client_input(void *context);
+void client_ref(struct imap_client *client);
+int client_unref(struct imap_client *client);
+
void clients_init(void);
void clients_deinit(void);
}
static void request_hash_remove(void *key __attr_unused__, void *value,
- void *context __attr_unused__)
+ void *context)
{
struct auth_request *request = value;
-
- request->callback(request, NULL, NULL, request->context);
- request->conn = NULL;
+ struct auth_server_connection *conn = context;
+
+ if (request->conn == conn) {
+ if (request->next_conn == NULL) {
+ request->callback(request, NULL, NULL,
+ request->context);
+ request->conn = NULL;
+ } else {
+ request->conn = request->next_conn;
+ request->next_conn = NULL;
+ }
+ } else {
+ request->next_conn = NULL;
+ }
}
void auth_server_requests_remove_all(struct auth_server_connection *conn)
{
- hash_foreach(conn->requests, request_hash_remove, NULL);
+ hash_foreach(conn->requests, request_hash_remove, conn);
}
struct auth_request *
if (request->next_conn != NULL)
hash_remove(request->next_conn->requests, id);
+ request->callback(request, NULL, NULL, request->context);
+
i_free(request->plaintext_data);
i_free(request);
}
return TRUE;
}
- ret = mail_cache_open_and_verify(cache, FALSE);
+ ret = mail_cache_open_and_verify(cache, TRUE);
if (ret != 0)
return ret > 0;
io_remove(client->common.io);
client->common.io = client->common.fd == -1 ? NULL :
io_add(client->common.fd, IO_READ, client_input, client);
+
+ client_unref(client);
}
static void master_callback(struct client *_client, int success)
/* success, we should be able to log in. if we fail, just
disconnect the client. */
client_send_line(client, "+OK Logged in.");
+ client_unref(client);
}
}
buffer_append_c(client->plain_login, '\0');
buffer_append(client->plain_login, args, strlen(args));
+ client_ref(client);
client->common.auth_request =
auth_client_request_new(auth_client, AUTH_MECH_PLAIN,
AUTH_PROTOCOL_POP3,
} else {
client_send_line(client,
t_strconcat("-ERR Login failed: ", error, NULL));
+ client_unref(client);
return TRUE;
}
}
/* success, we should be able to log in. if we fail, just
disconnect the client. */
client_send_line(client, "+OK Logged in.");
+ client_unref(client);
}
}
return TRUE;
}
+ client_ref(client);
client->common.auth_request =
auth_client_request_new(auth_client, mech->mech,
AUTH_PROTOCOL_POP3,
} else {
client_send_line(client, t_strconcat(
"-ERR Authentication failed: ", error, NULL));
+ client_unref(client);
}
return TRUE;
static struct hash_table *clients;
static struct timeout *to_idle;
-static int client_unref(struct pop3_client *client);
-
static void client_set_title(struct pop3_client *client)
{
const char *addr;
return;
}
- client->refcount++;
+ client_ref(client);
o_stream_cork(client->output);
while (!client->output->closed &&
client_unref(client);
}
-static int client_unref(struct pop3_client *client)
+void client_ref(struct pop3_client *client)
+{
+ client->refcount++;
+}
+
+int client_unref(struct pop3_client *client)
{
if (--client->refcount > 0)
return TRUE;
int client_read(struct pop3_client *client);
void client_input(void *context);
+void client_ref(struct pop3_client *client);
+int client_unref(struct pop3_client *client);
+
void clients_init(void);
void clients_deinit(void);