From f98f33ef826251ef26b7402cc953cada7e502d9d Mon Sep 17 00:00:00 2001 From: Jeremy Lakeman Date: Mon, 25 May 2015 11:49:48 +0930 Subject: [PATCH] Release mdp socket in config sync --- conf_cli.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/conf_cli.c b/conf_cli.c index aea0d7ca..3b90b5f8 100644 --- a/conf_cli.c +++ b/conf_cli.c @@ -87,19 +87,26 @@ static int mdp_client_sync_config(time_ms_t timeout) set_nonblock(mdpsock); int r = mdp_send(mdpsock, &mdp_header, NULL, 0); if (r == -1) - return -1; + goto end; time_ms_t deadline = gettime_ms() + timeout; // TODO add --timeout option struct mdp_header rev_header; do { ssize_t len = mdp_poll_recv(mdpsock, deadline, &rev_header, NULL, 0); - if (len == -1) - return -1; + if (len == -1){ + r = -1; + goto end; + } if (len == -2) { WHYF("timeout while synchronising daemon configuration"); - return -1; + r = -1; + goto end; } } while (!(rev_header.flags & MDP_FLAG_CLOSE)); - return 0; + r = 0; + +end: + mdp_close(mdpsock); + return r; } DEFINE_CMD(app_config_set, CLIFLAG_PERMISSIVE_CONFIG,