From: Marko Kreen Date: Fri, 6 Nov 2015 17:56:10 +0000 (+0200) Subject: Postpone change of expect_rfq_count X-Git-Tag: pgbouncer_1_7~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=700419d570bb34cd8e94239ffe1165cdc1fb0737;p=pgbouncer Postpone change of expect_rfq_count When changed too early and client socket is paused, then packet will processed again when socket is woken up and expect_rfq_count will be too high. --- diff --git a/src/client.c b/src/client.c index 5951d39..24a0981 100644 --- a/src/client.c +++ b/src/client.c @@ -579,6 +579,7 @@ static bool handle_client_startup(PgSocket *client, PktHdr *pkt) static bool handle_client_work(PgSocket *client, PktHdr *pkt) { SBuf *sbuf = &client->sbuf; + int rfq_delta = 0; switch (pkt->type) { @@ -593,7 +594,7 @@ static bool handle_client_work(PgSocket *client, PktHdr *pkt) /* request immediate response from server */ case 'S': /* Sync */ - client->expect_rfq_count++; + rfq_delta++; break; case 'H': /* Flush */ break; @@ -638,6 +639,11 @@ static bool handle_client_work(PgSocket *client, PktHdr *pkt) if (!find_server(client)) return false; + /* postpone rfq change until certain that client will not be paused */ + if (rfq_delta) { + client->expect_rfq_count += rfq_delta; + } + client->pool->stats.client_bytes += pkt->len; /* tag the server as dirty */