diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-06-02 15:02:56 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-06-02 15:02:56 +0200 |
commit | 7610a41afe910df6426aa09eae5aad7431d69e36 (patch) | |
tree | 1b86d67a4230819a5f4ee8ef1e92e2ee70d57f09 /src/dabOutput/dabOutputTcp.cpp | |
parent | 8bd4a04c4098e1dfe75f8056d4ff5a125d445275 (diff) | |
download | dabmux-7610a41afe910df6426aa09eae5aad7431d69e36.tar.gz dabmux-7610a41afe910df6426aa09eae5aad7431d69e36.tar.bz2 dabmux-7610a41afe910df6426aa09eae5aad7431d69e36.zip |
TCP output: do not block in the destructor if one connection stalls
Diffstat (limited to 'src/dabOutput/dabOutputTcp.cpp')
-rw-r--r-- | src/dabOutput/dabOutputTcp.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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; |