pgpool2.git / summary / log / commit / refs

commit    3043b797bd8be97d415d13fae03bb16b0554e207
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Sun Aug 12 07:47:38 2012 +0000

    Fix send_cached_messages. Before it had 8192 bytes fix length buffer
    for each row data and if data execeeded 8192 bytes, it just crashed.
    To fix this, eliminate copying raw data which is passed as an argument
    to buffer and pass the pointer to send_message.


pool_memqcache.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/pool_memqcache.c b/pool_memqcache.c index 9ef1e885c..a31a8e741 100644 --- a/pool_memqcache.c +++ b/pool_memqcache.c @@ -460,24 +460,22 @@ static int send_cached_messages(POOL_CONNECTION *frontend, const char *qcache, i int msg = 0; int i = 0; int is_prepared_stmt = 0; + int len; + const char *p; while (i < qcachelen) { char tmpkind; int tmplen; - char tmpbuf[MAX_VALUE]; tmpkind = qcache[i]; - - i += 1; + i++; memcpy(&tmplen, qcache+i, sizeof(tmplen)); i += sizeof(tmplen); - - tmplen = ntohl(tmplen); - - memcpy(tmpbuf, qcache+i, tmplen - sizeof(tmplen)); - i += tmplen - sizeof(tmplen); + len = ntohl(tmplen); + p = qcache + i; + i += len - sizeof(tmplen); /* No need to cache PARSE and BIND responses */ if (tmpkind == '1' || tmpkind == '2') @@ -496,8 +494,8 @@ static int send_cached_messages(POOL_CONNECTION *frontend, const char *qcache, i } /* send message to frontend */ - pool_debug("send_cached_messages: %c len: %d", tmpkind, tmplen); - send_message(frontend, tmpkind, tmplen, tmpbuf); + pool_debug("send_cached_messages: %c len: %d", tmpkind, len); + send_message(frontend, tmpkind, len, p); msg++; } [parent: 90550358779f]