From dcc6fcf2069bedb4181ec0d81796bd1f69b2a582 Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Tue, 21 Nov 2017 19:29:17 +0100 Subject: [PATCH] [mpd] Close connection for close command (#444) --- src/mpd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mpd.c b/src/mpd.c index 0cf8752e..292dd5e2 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -4542,6 +4542,17 @@ mpd_read_cb(struct bufferevent *bev, void *ctx) { evbuffer_add(output, "OK\n", 3); } + + if (close_cmd) + { + /* + * Freeing the bufferevent closes the connection, if it was + * opened with BEV_OPT_CLOSE_ON_FREE. + * Since bufferevent is reference-counted, it will happen as + * soon as possible, not necessarily immediately. + */ + bufferevent_free(bev); + } } /*