From 88390159a121646e8a6c00f12b615d51876e86f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Fri, 23 Jun 2017 10:31:40 +0100 Subject: [PATCH] On connection shutdown, free op from the correct side --- servers/lloadd/operation.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/servers/lloadd/operation.c b/servers/lloadd/operation.c index 8ff873a2ae..feb40c1a68 100644 --- a/servers/lloadd/operation.c +++ b/servers/lloadd/operation.c @@ -652,11 +652,29 @@ done: CLIENT_UNLOCK_OR_DESTROY(c); } +/* + * Upstream is shutting down, signal the client if necessary, but we have to + * call operation_destroy_from_upstream ourselves to detach upstream from the + * op. + * + * Only called from upstream_destroy. + */ void operation_lost_upstream( Operation *op ) { + Connection *c = op->o_upstream; + CONNECTION_LOCK(c); + op->o_upstream_refcnt++; + /* Matching the op reference on the connection as well */ + CONNECTION_UNLOCK_INCREF(c); + operation_send_reject( op, LDAP_UNAVAILABLE, "connection to the remote server has been severed", 0 ); + + CONNECTION_LOCK_DECREF(c); + op->o_upstream_refcnt--; + operation_destroy_from_upstream( op ); + CONNECTION_UNLOCK(c); } int