Mercurial > dovecot > core-2.2
changeset 1081:98dca3b6b209 HEAD
fixes
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sun, 02 Feb 2003 11:30:18 +0200 |
parents | 6def98421f46 |
children | c62416017121 |
files | src/auth/login-connection.c src/auth/login-connection.h src/auth/mech-digest-md5.c src/auth/mech-plain.c src/auth/mech.c |
diffstat | 5 files changed, 32 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/login-connection.c Sun Feb 02 10:11:33 2003 +0200 +++ b/src/auth/login-connection.c Sun Feb 02 11:30:18 2003 +0200 @@ -21,6 +21,8 @@ static struct auth_login_handshake_output handshake_output; static struct login_connection *connections; +static void login_connection_unref(struct login_connection *conn); + static void request_callback(struct auth_login_reply *reply, const void *data, struct login_connection *conn) { @@ -30,19 +32,23 @@ if ((size_t)ret == sizeof(*reply)) { if (reply->data_size == 0) { /* all sent */ + login_connection_unref(conn); return; } ret = o_stream_send(conn->output, data, reply->data_size); if ((size_t)ret == reply->data_size) { /* all sent */ + login_connection_unref(conn); return; } } if (ret >= 0) i_warning("Transmit buffer full for login process, killing it"); + login_connection_destroy(conn); + login_connection_unref(conn); } struct login_connection *login_connection_lookup(unsigned int pid) @@ -112,6 +118,7 @@ i_stream_skip(conn->input, sizeof(request)); /* we have a full init request */ + conn->refcount++; mech_request_new(conn, &request, request_callback); } else if (type == AUTH_LOGIN_REQUEST_CONTINUE) { struct auth_login_request_continue request; @@ -126,6 +133,7 @@ i_stream_skip(conn->input, sizeof(request) + request.data_size); /* we have a full continued request */ + conn->refcount++; mech_request_continue(conn, &request, data + sizeof(request), request_callback); @@ -171,6 +179,7 @@ i_info("Login process %d connected", fd); conn = i_new(struct login_connection, 1); + conn->refcount = 1; conn->fd = fd; conn->input = i_stream_create_file(fd, default_pool, MAX_INBUF_SIZE, @@ -207,6 +216,9 @@ { struct login_connection **pos; + if (conn->fd == -1) + return; + if (verbose) i_info("Login process %d disconnected", conn->fd); @@ -217,14 +229,27 @@ } } + i_stream_close(conn->input); + o_stream_close(conn->output); + + io_remove(conn->io); + net_disconnect(conn->fd); + conn->fd = -1; + + login_connection_unref(conn); +} + +static void login_connection_unref(struct login_connection *conn) +{ + if (--conn->refcount > 0) + return; + hash_foreach(conn->auth_requests, auth_request_hash_destroy, NULL); hash_destroy(conn->auth_requests); i_stream_unref(conn->input); o_stream_unref(conn->output); - io_remove(conn->io); - net_disconnect(conn->fd); pool_unref(conn->pool); i_free(conn); }
--- a/src/auth/login-connection.h Sun Feb 02 10:11:33 2003 +0200 +++ b/src/auth/login-connection.h Sun Feb 02 11:30:18 2003 +0200 @@ -5,6 +5,7 @@ struct login_connection { struct login_connection *next; + int refcount; int fd; struct io *io;
--- a/src/auth/mech-digest-md5.c Sun Feb 02 10:11:33 2003 +0200 +++ b/src/auth/mech-digest-md5.c Sun Feb 02 11:30:18 2003 +0200 @@ -567,8 +567,6 @@ if (parse_digest_response(auth, (const char *) data, request->data_size, &error)) { - auth_request->conn = conn; - auth_request->id = request->id; auth_request->callback = callback; auth_request->user = p_strdup(auth_request->pool,
--- a/src/auth/mech-plain.c Sun Feb 02 10:11:33 2003 +0200 +++ b/src/auth/mech-plain.c Sun Feb 02 11:30:18 2003 +0200 @@ -22,8 +22,6 @@ char *pass; size_t i, count, len; - auth_request->conn = conn; - auth_request->id = request->id; auth_request->callback = callback; /* authorization ID \0 authentication ID \0 pass.
--- a/src/auth/mech.c Sun Feb 02 10:11:33 2003 +0200 +++ b/src/auth/mech.c Sun Feb 02 11:30:18 2003 +0200 @@ -90,7 +90,10 @@ } if (auth_request != NULL) { + auth_request->conn = conn; + auth_request->id = request->id; auth_request->protocol = request->protocol; + hash_insert(conn->auth_requests, POINTER_CAST(request->id), auth_request); } @@ -112,7 +115,7 @@ } else { if (!auth_request->auth_continue(conn, auth_request, request, data, callback)) - mech_request_free(conn, auth_request, request->id); + mech_request_free(conn, auth_request, request->id); } }