From b1e921a3640db7ca4b8cea113bc3f0aedb3c02d2 Mon Sep 17 00:00:00 2001 From: ckolivas Date: Mon, 27 Oct 2014 21:46:47 +1100 Subject: [PATCH] Make the stratifier drop a client id if it's still trying to send to a client that no longer exists in the connector --- src/connector.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/connector.c b/src/connector.c index 6038506f..2acaf19c 100644 --- a/src/connector.c +++ b/src/connector.c @@ -177,18 +177,23 @@ static int drop_client(conn_instance_t *ci, client_instance_t *client) return fd; } +static void stratifier_drop_client(ckpool_t *ckp, int64_t id) +{ + char buf[256]; + + sprintf(buf, "dropclient=%ld", id); + send_proc(ckp->stratifier, buf); +} + /* Invalidate this instance. Remove them from the hashtables we look up * regularly but keep the instances in a linked list indefinitely in case we * still reference any of its members. */ static void invalidate_client(ckpool_t *ckp, conn_instance_t *ci, client_instance_t *client) { - char buf[256]; - drop_client(ci, client); if (ckp->passthrough) return; - sprintf(buf, "dropclient=%ld", client->id); - send_proc(ckp->stratifier, buf); + stratifier_drop_client(ckp, client->id); } static void send_client(conn_instance_t *ci, int64_t id, char *buf); @@ -492,12 +497,16 @@ static void send_client(conn_instance_t *ci, int64_t id, char *buf) ck_runlock(&ci->lock); if (unlikely(fd == -1)) { + ckpool_t *ckp = ci->pi->ckp; + if (client) { /* This shouldn't happen */ LOGWARNING("Client id %ld disconnected but fd already invalidated!", id); - invalidate_client(ci->pi->ckp, ci, client); - } else + invalidate_client(ckp, ci, client); + } else { LOGINFO("Connector failed to find client id %ld to send to", id); + stratifier_drop_client(ckp, id); + } free(buf); return; }