From: Adam Dickmeiss Date: Tue, 4 Mar 2014 13:05:44 +0000 (+0100) Subject: Discover lost connections immediately X-Git-Tag: v1.12.0~33 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=2648ba71df53787dcab5e4e2bb55a55cc5ad4143;p=pazpar2-moved-to-github.git Discover lost connections immediately ZOOM C will return mask of 0, when it is "idle". We fake it to be select on read so that we can detect when a session is lost. --- diff --git a/src/connection.c b/src/connection.c index 93b9020..508557c 100644 --- a/src/connection.c +++ b/src/connection.c @@ -259,6 +259,19 @@ static void non_block_events(struct connection *co) } } +static void iochan_update(struct connection *co) +{ + if (co->link) + { + int m = ZOOM_connection_get_mask(co->link); + + if (m == 0) + m = ZOOM_SELECT_READ; + iochan_setflags(co->iochan, m); + iochan_setfd(co->iochan, ZOOM_connection_get_socket(co->link)); + } +} + void connection_continue(struct connection *co) { int r = ZOOM_connection_exec_task(co->link); @@ -271,10 +284,7 @@ void connection_continue(struct connection *co) client_unlock(cl); } else - { - iochan_setflags(co->iochan, ZOOM_connection_get_mask(co->link)); - iochan_setfd(co->iochan, ZOOM_connection_get_socket(co->link)); - } + iochan_update(co); } static void connection_handler(IOCHAN iochan, int event) @@ -302,6 +312,11 @@ static void connection_handler(IOCHAN iochan, int event) } else { + if (ZOOM_connection_is_idle(co->link)) + { + connection_destroy(co); + return; + } client_lock(cl); non_block_events(co); @@ -310,11 +325,7 @@ static void connection_handler(IOCHAN iochan, int event) non_block_events(co); client_unlock(cl); - if (co->link) - { - iochan_setflags(iochan, ZOOM_connection_get_mask(co->link)); - iochan_setfd(iochan, ZOOM_connection_get_socket(co->link)); - } + iochan_update(co); } }