From 09f347eb673e95476c7c726beb218c51281115e0 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 1 Aug 2008 12:51:54 +0000 Subject: [PATCH] admin.c: dont crash if socket has no buffer --- NEWS | 4 ++++ src/admin.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 276f915..239ed60 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ * drop_on_error config param - if server throws error the connection will not be reused but dropped. Defaults to 1. + = Fixes = + + * SHOW SOCKETS/CLIENTS/SERVERS: Don't crash if socket has no buffer. + 2008-07-29 - PgBouncer 1.2 - "Ordinary Magic Flute" PgBouncer 1.2 now requires libevent version 1.3b or newer. diff --git a/src/admin.c b/src/admin.c index 5cb3f97..5448cd6 100644 --- a/src/admin.c +++ b/src/admin.c @@ -505,8 +505,8 @@ static void adr2txt(const PgAddr *adr, char *dst, unsigned dstlen) static void socket_row(PktBuf *buf, PgSocket *sk, const char *state, bool debug) { - int pkt_avail = iobuf_amount_parse(sk->sbuf.io); - int send_avail = iobuf_amount_pending(sk->sbuf.io); + int pkt_avail = sk->sbuf.io ? iobuf_amount_parse(sk->sbuf.io) : 0; + int send_avail = sk->sbuf.io ? iobuf_amount_pending(sk->sbuf.io) : 0; char ptrbuf[128], linkbuf[128]; char l_addr[32], r_addr[32]; IOBuf *io = sk->sbuf.io; -- 2.40.0