From 0ae1bf3ac4667cb03cd71d178f5e4938dd4a5198 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 26 Nov 2008 16:25:55 -0800 Subject: [PATCH] Free txbuf, rxbuf in vconn-ssl and vconn-stream destructors. This bug was causing secchan to leak a little bit of memory on almost every connection close. This is most visible when openflow-monitor is running, because openflow-monitor connects to secchan once per second. --- lib/vconn-ssl.c | 3 +++ lib/vconn-stream.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/lib/vconn-ssl.c b/lib/vconn-ssl.c index 65e420f21..383714af4 100644 --- a/lib/vconn-ssl.c +++ b/lib/vconn-ssl.c @@ -170,6 +170,7 @@ static int ssl_init(void); static int do_ssl_init(void); static bool ssl_wants_io(int ssl_error); static void ssl_close(struct vconn *); +static void ssl_clear_txbuf(struct ssl_vconn *); static int interpret_ssl_error(const char *function, int ret, int error, int *want); static void ssl_tx_poll_callback(int fd, short int revents, void *vconn_); @@ -482,6 +483,8 @@ ssl_close(struct vconn *vconn) { struct ssl_vconn *sslv = ssl_vconn_cast(vconn); poll_cancel(sslv->tx_waiter); + ssl_clear_txbuf(sslv); + ofpbuf_delete(sslv->rxbuf); SSL_free(sslv->ssl); close(sslv->fd); free(sslv); diff --git a/lib/vconn-stream.c b/lib/vconn-stream.c index d8c8b4712..966c24202 100644 --- a/lib/vconn-stream.c +++ b/lib/vconn-stream.c @@ -66,6 +66,8 @@ static struct vconn_class stream_vconn_class; static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(10, 25); +static void stream_clear_txbuf(struct stream_vconn *); + int new_stream_vconn(const char *name, int fd, int connect_status, uint32_t ip, struct vconn **vconnp) @@ -94,6 +96,8 @@ stream_close(struct vconn *vconn) { struct stream_vconn *s = stream_vconn_cast(vconn); poll_cancel(s->tx_waiter); + stream_clear_txbuf(s); + ofpbuf_delete(s->rxbuf); close(s->fd); free(s); } -- 2.45.2