diff options
Diffstat (limited to 'src/cli/tls_server.cpp')
-rw-r--r-- | src/cli/tls_server.cpp | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/cli/tls_server.cpp b/src/cli/tls_server.cpp index dd1c7f450..b1a5b0ec6 100644 --- a/src/cli/tls_server.cpp +++ b/src/cli/tls_server.cpp @@ -138,31 +138,42 @@ class TLS_Server final : public Command { while(!server.is_closed()) { - uint8_t buf[4*1024] = { 0 }; - ssize_t got = ::read(fd, buf, sizeof(buf)); - - if(got == -1) + try { - std::cout << "Error in socket read - " << strerror(errno) << std::endl; - break; - } + uint8_t buf[4*1024] = { 0 }; + ssize_t got = ::read(fd, buf, sizeof(buf)); - if(got == 0) - { - std::cout << "EOF on socket" << std::endl; - break; - } + if(got == -1) + { + std::cout << "Error in socket read - " << strerror(errno) << std::endl; + break; + } + + if(got == 0) + { + std::cout << "EOF on socket" << std::endl; + break; + } - server.received_data(buf, got); + server.received_data(buf, got); - while(server.is_active() && !pending_output.empty()) - { - std::string output = pending_output.front(); - pending_output.pop_front(); - server.send(output); + while(server.is_active() && !pending_output.empty()) + { + std::string output = pending_output.front(); + pending_output.pop_front(); + server.send(output); - if(output == "quit\n") - server.close(); + if(output == "quit\n") + server.close(); + } + } + catch(std::exception& e) + { + std::cout << "Connection1 problem: " << e.what() << std::endl; + if(is_tcp) + { + ::close(fd); + } } } } |