diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-01-13 16:33:33 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2017-01-13 16:33:33 +0100 |
commit | 1bbbac7f62d71f0d0c4c71d429aeb2cfdf96e5ac (patch) | |
tree | f9234c8e6491151fddccc2c8d1ff0b0600c44c5f /src/EtiReader.cpp | |
parent | 7c8ae25ba83fc658dfbe4cd468bb1bdfd3513c74 (diff) | |
download | dabmod-1bbbac7f62d71f0d0c4c71d429aeb2cfdf96e5ac.tar.gz dabmod-1bbbac7f62d71f0d0c4c71d429aeb2cfdf96e5ac.tar.bz2 dabmod-1bbbac7f62d71f0d0c4c71d429aeb2cfdf96e5ac.zip |
EDI: add protection against runaway memory usage
Diffstat (limited to 'src/EtiReader.cpp')
-rw-r--r-- | src/EtiReader.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index f0a1793..de23142 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -545,7 +545,14 @@ void EdiUdpInput::Open(const std::string& uri) m_port = std::stoi(m[1].str()); etiLog.level(info) << "EDI port :" << m_port; - m_udp_rx.start(m_port); + + // The max_fragments_queued is only a protection against a runaway + // memory usage. + // Rough calculation: + // 300 seconds, 24ms per frame, up to 20 fragments per frame + const size_t max_fragments_queued = 20 * 300 * 1000 / 24; + + m_udp_rx.start(m_port, max_fragments_queued); m_enabled = true; } } |