]> granicus.if.org Git - pgbouncer/commitdiff
handle_client_work - move logic out of switch
authorMarko Kreen <markokr@gmail.com>
Sat, 8 Aug 2015 09:21:52 +0000 (12:21 +0300)
committerMarko Kreen <markokr@gmail.com>
Sat, 8 Aug 2015 09:21:52 +0000 (12:21 +0300)
src/client.c

index 43784746cb8971d3df518dea4862149c0f609f02..973785bef054a2d18779ce06aa4113fd9f806f0e 100644 (file)
@@ -628,28 +628,6 @@ static bool handle_client_work(PgSocket *client, PktHdr *pkt)
        case 'B':               /* Bind */
        case 'D':               /* Describe */
        case 'd':               /* CopyData(F/B) */
-
-               /* update stats */
-               if (!client->query_start) {
-                       client->pool->stats.request_count++;
-                       client->query_start = get_cached_time();
-               }
-
-               if (client->pool->db->admin)
-                       return admin_handle_client(client, pkt);
-
-               /* acquire server */
-               if (!find_server(client))
-                       return false;
-
-               client->pool->stats.client_bytes += pkt->len;
-
-               /* tag the server as dirty */
-               client->link->ready = false;
-               client->link->idle_tx = false;
-
-               /* forward the packet */
-               sbuf_prepare_send(sbuf, &client->link->sbuf, pkt->len);
                break;
 
        /* client wants to go away */
@@ -661,6 +639,29 @@ static bool handle_client_work(PgSocket *client, PktHdr *pkt)
                disconnect_client(client, false, "client close request");
                return false;
        }
+
+       /* update stats */
+       if (!client->query_start) {
+               client->pool->stats.request_count++;
+               client->query_start = get_cached_time();
+       }
+
+       if (client->pool->db->admin)
+               return admin_handle_client(client, pkt);
+
+       /* acquire server */
+       if (!find_server(client))
+               return false;
+
+       client->pool->stats.client_bytes += pkt->len;
+
+       /* tag the server as dirty */
+       client->link->ready = false;
+       client->link->idle_tx = false;
+
+       /* forward the packet */
+       sbuf_prepare_send(sbuf, &client->link->sbuf, pkt->len);
+
        return true;
 }