]> granicus.if.org Git - pgbouncer/commitdiff
Postpone change of expect_rfq_count
authorMarko Kreen <markokr@gmail.com>
Fri, 6 Nov 2015 17:56:10 +0000 (19:56 +0200)
committerMarko Kreen <markokr@gmail.com>
Fri, 6 Nov 2015 17:56:10 +0000 (19:56 +0200)
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.

src/client.c

index 5951d3964cddaa90dcdbdc04c52e4d1c711e7cc5..24a0981570b6c64bbff096deef2b975fa3d002dd 100644 (file)
@@ -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 */