From: Adam Dickmeiss Date: Fri, 7 Mar 2014 13:50:16 +0000 (+0100) Subject: Inactive clients gets there connections closed X-Git-Tag: v1.12.0~29 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=15e9827798d09d1afda3304d021bf464fb997624;p=pazpar2-moved-to-github.git Inactive clients gets there connections closed The trick is to set a 1 second timeout on the channel. --- 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);