aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-05-11 21:29:25 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-05-11 21:29:25 +0200
commit21533437b60eea8575272ac3c4a371b7f351548e (patch)
tree625fe8624781d691b25858ffd3f0c060ca5b9aef
parent2538f484c824896feed63e3315b3cd5b22f0de12 (diff)
downloaddabmux-21533437b60eea8575272ac3c4a371b7f351548e.tar.gz
dabmux-21533437b60eea8575272ac3c4a371b7f351548e.tar.bz2
dabmux-21533437b60eea8575272ac3c4a371b7f351548e.zip
Apply common 3e7e9b6 for TCPSendClient
-rw-r--r--lib/Socket.cpp7
-rw-r--r--lib/Socket.h4
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/Socket.cpp b/lib/Socket.cpp
index 159de7e..bc1b179 100644
--- a/lib/Socket.cpp
+++ b/lib/Socket.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2020
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -932,6 +932,11 @@ void TCPSendClient::sendall(const std::vector<uint8_t>& buffer)
}
m_queue.push(buffer);
+
+ if (m_queue.size() > MAX_QUEUE_SIZE) {
+ vector<uint8_t> discard;
+ m_queue.try_pop(discard);
+ }
}
void TCPSendClient::process()
diff --git a/lib/Socket.h b/lib/Socket.h
index 84def40..8c6f8a9 100644
--- a/lib/Socket.h
+++ b/lib/Socket.h
@@ -2,7 +2,7 @@
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the
Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2019
+ Copyright (C) 2020
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -311,7 +311,7 @@ class TCPSendClient {
bool m_is_connected = false;
TCPSocket m_sock;
- static constexpr size_t MAX_QUEUE_SIZE = 1024;
+ static constexpr size_t MAX_QUEUE_SIZE = 512;
ThreadsafeQueue<std::vector<uint8_t> > m_queue;
std::atomic<bool> m_running;
std::string m_exception_data;