From 6899d0123dc269e9a675aa6a6134dcda390b11f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Tue, 9 May 2017 16:22:37 +0100 Subject: [PATCH] Do not bother to write to a dying connection --- servers/lloadd/client.c | 6 ++++-- servers/lloadd/upstream.c | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/servers/lloadd/client.c b/servers/lloadd/client.c index 0fcfd6f65c..51f7c78467 100644 --- a/servers/lloadd/client.c +++ b/servers/lloadd/client.c @@ -200,9 +200,11 @@ client_write_cb( evutil_socket_t s, short what, void *arg ) { Connection *c = arg; - /* What if the shutdown is already in progress and we get to lock the - * connection? */ CONNECTION_LOCK(c); + if ( !c->c_live ) { + CONNECTION_UNLOCK(c); + return; + } CONNECTION_UNLOCK_INCREF(c); ldap_pvt_thread_mutex_lock( &c->c_io_mutex ); diff --git a/servers/lloadd/upstream.c b/servers/lloadd/upstream.c index 9aa3bd7d64..6a30e82c1e 100644 --- a/servers/lloadd/upstream.c +++ b/servers/lloadd/upstream.c @@ -670,6 +670,10 @@ upstream_write_cb( evutil_socket_t s, short what, void *arg ) Connection *c = arg; CONNECTION_LOCK(c); + if ( !c->c_live ) { + CONNECTION_UNLOCK(c); + return; + } CONNECTION_UNLOCK_INCREF(c); ldap_pvt_thread_mutex_lock( &c->c_io_mutex );