]> granicus.if.org Git - pgbouncer/commitdiff
Increase size of various startup-related buffers.
authorMarko Kreen <markokr@gmail.com>
Fri, 23 Apr 2010 13:48:13 +0000 (13:48 +0000)
committerMarko Kreen <markokr@gmail.com>
Fri, 23 Apr 2010 13:48:13 +0000 (13:48 +0000)
Also bring them under single define.

include/bouncer.h
src/admin.c
src/proto.c
src/takeover.c
src/varcache.c

index 02c621a54b99afcd5c85f2c1982a9edacab27437..8f46a4511bc3eae77a22fc930e83b557f0768a2d 100644 (file)
@@ -120,6 +120,9 @@ extern int cf_sbuf_len;
 
 #define BACKENDKEY_LEN 8
 
+/* buffer size for startup noise */
+#define STARTUP_BUF    1024
+
 /*
  * Remote/local address
  */
@@ -170,7 +173,7 @@ struct PgPool {
        PgStats older_stats;
 
        /* database info to be sent to client */
-       uint8_t welcome_msg[256];       /* ServerParams without VarCache ones */
+       uint8_t welcome_msg[STARTUP_BUF]; /* ServerParams without VarCache ones */
        unsigned welcome_msg_len;
 
        VarCache orig_vars;             /* default params from server */
@@ -226,7 +229,7 @@ struct PgDatabase {
        bool db_auto;           /* is the database auto-created by autodb_connstr */
        bool admin;             /* internal console db */
 
-       uint8_t startup_params[256]; /* partial StartupMessage (without user) be sent to server */
+       uint8_t startup_params[STARTUP_BUF]; /* partial StartupMessage (without user) be sent to server */
        unsigned startup_params_len;
 
        PgUser *forced_user;    /* if not NULL, the user/psw is forced */
index 25e0d47b364a10dc54b6d5030c80f64be26d6ad0..409963fb3045a0d7ae4e7c99680c437d433023b2 100644 (file)
@@ -236,7 +236,7 @@ static bool send_one_fd(PgSocket *admin,
        struct cmsghdr *cmsg;
        int res;
        struct iovec iovec;
-       uint8_t pktbuf[1024];
+       uint8_t pktbuf[STARTUP_BUF * 2];
        uint8_t cntbuf[CMSG_SPACE(sizeof(int))];
 
        iovec.iov_base = pktbuf;
index 2c18c803d4610fd3223ae8d3a8e812999093d867..8c6d379ced44565e0e1714b18fe42a2fa99e8c55 100644 (file)
@@ -190,7 +190,7 @@ void finish_welcome_msg(PgSocket *server)
 bool welcome_client(PgSocket *client)
 {
        int res;
-       uint8_t buf[1024];
+       uint8_t buf[STARTUP_BUF];
        PktBuf msg;
        PgPool *pool = client->pool;
 
@@ -321,7 +321,7 @@ bool send_startup_packet(PgSocket *server)
        PgDatabase *db = server->pool->db;
        const char *username = server->pool->user->name;
        PktBuf pkt;
-       uint8_t buf[512];
+       uint8_t buf[STARTUP_BUF];
 
        pktbuf_static(&pkt, buf, sizeof(buf));
        pktbuf_write_StartupMessage(&pkt, username,
index 1a3efe3620baf320600d9d6060ce6fef7daa1dc6..ef18f6c7c3c90bffd58bf827866b9b0fb09a5ded 100644 (file)
@@ -266,7 +266,7 @@ static void takeover_parse_data(PgSocket *bouncer,
 static void takeover_recv_cb(int sock, short flags, void *arg)
 {
        PgSocket *bouncer = container_of(arg, PgSocket, sbuf);
-       uint8_t data_buf[2048];
+       uint8_t data_buf[STARTUP_BUF * 2];
        uint8_t cnt_buf[128];
        struct msghdr msg;
        struct iovec io;
index e8ad349b0e12737c1466511d39c3b1f98df3615c..d6f54f93b2bb5725f1ba224661181ca4f01d986a 100644 (file)
@@ -132,7 +132,7 @@ static int apply_var(PktBuf *pkt, const char *key,
 bool varcache_apply(PgSocket *server, PgSocket *client, bool *changes_p)
 {
        PktBuf pkt;
-       uint8_t buf[1024];
+       uint8_t buf[STARTUP_BUF];
        int changes = 0;
        const char *cval, *sval;
        const struct var_lookup *lk;