From 1542240ee87c056023a15a4b29ce4c2a5385c8ae Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 6 Nov 2015 16:28:56 +0100 Subject: [PATCH] Handle LuaContext::SyntaxErrorException() in the Console server. Gracefully handle disconnection on the client. Fixes #2866. --- pdns/dnsdist.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index a2f922cf1..8f4488738 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -679,6 +679,9 @@ try response += string(e.reason); } } + catch(const LuaContext::SyntaxErrorException& e) { + response = "Error: " + string(e.what()) + ": "; + } response = sodEncryptSym(response, g_key, ours); putMsgLen(fd, response.length()); writen2(fd, response.c_str(), (uint16_t)response.length()); @@ -777,9 +780,13 @@ void doClient(ComboAddress server, const std::string& command) uint16_t len; getMsgLen(fd, &len); + if(len == 0) { + cout << "Connection closed by the server." << endl; + break; + } + char resp[len]; - if(len) - readn2(fd, resp, len); + readn2(fd, resp, len); msg.assign(resp, len); msg=sodDecryptSym(msg, g_key, theirs); cout<