]> granicus.if.org Git - pgbouncer/commitdiff
cleaner socket_row()
authorMarko Kreen <markokr@gmail.com>
Mon, 4 Aug 2008 08:44:48 +0000 (08:44 +0000)
committerMarko Kreen <markokr@gmail.com>
Mon, 4 Aug 2008 08:44:48 +0000 (08:44 +0000)
src/admin.c

index 5448cd63a20a48e6f8381cf221be2658af23c85c..4afab804f212b6400aa0becb9f07cbf06cac359d 100644 (file)
@@ -505,12 +505,16 @@ 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 = sk->sbuf.io ? iobuf_amount_parse(sk->sbuf.io) : 0;
-       int send_avail = sk->sbuf.io ? iobuf_amount_pending(sk->sbuf.io) : 0;
+       int pkt_avail = 0, send_avail = 0;
        char ptrbuf[128], linkbuf[128];
        char l_addr[32], r_addr[32];
        IOBuf *io = sk->sbuf.io;
 
+       if (io) {
+               pkt_avail = iobuf_amount_parse(sk->sbuf.io);
+               send_avail = iobuf_amount_pending(sk->sbuf.io);
+       }
+
        adr2txt(&sk->remote_addr, r_addr, sizeof(r_addr));
        adr2txt(&sk->local_addr, l_addr, sizeof(l_addr));