Skip to content

Commit

Permalink
lib-master: Keep linked list of master_login_clients per connection
Browse files Browse the repository at this point in the history
This allows improving logging on connection errors.
  • Loading branch information
sirainen committed Jun 8, 2018
1 parent f37d916 commit 54c4210
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib-master/master-login.c
Expand Up @@ -23,6 +23,7 @@ struct master_login_connection {
struct master_login_connection *prev, *next;

struct master_login *login;
struct master_login_client *clients;
int refcount;
int fd;
struct io *io;
Expand Down Expand Up @@ -191,6 +192,7 @@ static void master_login_client_free(struct master_login_client **_client)
i_assert(client->conn->refcount > 1);
client->conn->refcount--;
}
DLLIST_REMOVE(&client->conn->clients, client);
master_login_conn_unref(&client->conn);
i_free(client->session_id);
i_free(client);
Expand Down Expand Up @@ -437,6 +439,7 @@ static void master_login_conn_input(struct master_login_connection *conn)
client->session_id = i_strndup(data, session_len);
memcpy(client->data, data+i, req.data_size);
conn->refcount++;
DLLIST_PREPEND(&conn->clients, client);

master_login_auth_request(login->auth, &req,
master_login_auth_callback, client);
Expand Down Expand Up @@ -483,6 +486,7 @@ static void master_login_conn_unref(struct master_login_connection **_conn)
return;

*_conn = NULL;
i_assert(conn->clients == NULL);
master_login_conn_close(conn);
o_stream_unref(&conn->output);

Expand Down
1 change: 1 addition & 0 deletions src/lib-master/master-login.h
Expand Up @@ -6,6 +6,7 @@
#define MASTER_POSTLOGIN_TIMEOUT_DEFAULT 60

struct master_login_client {
struct master_login_client *prev, *next;
struct master_login_connection *conn;
int fd;

Expand Down

0 comments on commit 54c4210

Please sign in to comment.