Inactive clients gets there connections closed
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 7 Mar 2014 13:50:16 +0000 (14:50 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 7 Mar 2014 13:50:16 +0000 (14:50 +0100)
The trick is to set a 1 second timeout on the channel.

src/client.c
src/client.h
src/connection.c
src/connection.h
src/session.c

index d6a815b..3b1e93a 100644 (file)
@@ -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)
 {
index cb9d3ee..bca9c46 100644 (file)
@@ -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,
index d561906..630db75 100644 (file)
@@ -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)
 {
index 305b9bd..fe4f83a 100644 (file)
@@ -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
 
index 38764c3..17647d6 100644 (file)
@@ -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);