From 7610a41afe910df6426aa09eae5aad7431d69e36 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 2 Jun 2017 15:02:56 +0200 Subject: TCP output: do not block in the destructor if one connection stalls --- src/dabOutput/dabOutputTcp.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/dabOutput') diff --git a/src/dabOutput/dabOutputTcp.cpp b/src/dabOutput/dabOutputTcp.cpp index 2aab48a..f5aebe0 100644 --- a/src/dabOutput/dabOutputTcp.cpp +++ b/src/dabOutput/dabOutputTcp.cpp @@ -89,7 +89,17 @@ class TCPConnection queue.wait_and_pop(data); try { - m_sock.send(&data[0], data.size()); + ssize_t sent = 0; + do { + const int timeout_ms = 10; // Less than one ETI frame + sent = m_sock.send(&data[0], data.size(), timeout_ms); + + if (is_overloaded()) { + m_running = false; + break; + } + } + while (sent == 0); } catch (std::runtime_error& e) { m_running = false; -- cgit v1.2.3