From 15e9827798d09d1afda3304d021bf464fb997624 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 7 Mar 2014 14:50:16 +0100 Subject: [PATCH] Inactive clients gets there connections closed The trick is to set a 1 second timeout on the channel. --- src/client.c | 6 ++++++ src/client.h | 1 + src/connection.c | 5 +++++ src/connection.h | 1 + src/session.c | 1 + 5 files changed, 14 insertions(+) diff --git a/src/client.c b/src/client.c index d6a815b..3b1e93a 100644 --- a/src/client.c +++ b/src/client.c @@ -1082,6 +1082,12 @@ void client_disconnect(struct client *cl) client_set_connection(cl, 0); } +void client_mark_dead(struct client *cl) +{ + if (cl->connection) + connection_mark_dead(cl->connection); +} + // Initialize CCL map for a target static CCL_bibset prepare_cclmap(struct client *cl, CCL_bibset base_bibset) { diff --git a/src/client.h b/src/client.h index cb9d3ee..bca9c46 100644 --- a/src/client.h +++ b/src/client.h @@ -69,6 +69,7 @@ int client_destroy(struct client *c); void client_set_connection(struct client *cl, struct connection *con); void client_disconnect(struct client *cl); +void client_mark_dead(struct client *cl); int client_prep_connection(struct client *cl, int operation_timeout, int session_timeout, iochan_man_t iochan, diff --git a/src/connection.c b/src/connection.c index d561906..630db75 100644 --- a/src/connection.c +++ b/src/connection.c @@ -108,6 +108,11 @@ ZOOM_connection connection_get_link(struct connection *co) return co->link; } +void connection_mark_dead(struct connection *co) +{ + iochan_settimeout(co->iochan, 1); +} + // Close connection and recycle structure static void connection_destroy(struct connection *co) { diff --git a/src/connection.h b/src/connection.h index 305b9bd..fe4f83a 100644 --- a/src/connection.h +++ b/src/connection.h @@ -31,6 +31,7 @@ struct connection; ZOOM_connection connection_get_link(struct connection *co); void connection_continue(struct connection *co); +void connection_mark_dead(struct connection *co); #endif diff --git a/src/session.c b/src/session.c index 38764c3..17647d6 100644 --- a/src/session.c +++ b/src/session.c @@ -556,6 +556,7 @@ static void session_remove_cached_clients(struct session *se) client_lock(l->client); client_set_session(l->client, 0); client_set_database(l->client, 0); + client_mark_dead(l->client); client_unlock(l->client); client_destroy(l->client); xfree(l); -- 1.7.10.4