Protect access to create_stream() with a mutex
Multiple threads may access create_stream() for the same session simultaneously which can cause problems if the access is not protected.
This commit is contained in:
parent
2d44980384
commit
d61a6cf4dc
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -47,5 +48,7 @@ namespace uvg_rtp {
|
|||
|
||||
/* All media streams of this session */
|
||||
std::unordered_map<uint32_t, uvg_rtp::media_stream *> streams_;
|
||||
|
||||
std::mutex session_mtx_;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -30,6 +30,8 @@ uvg_rtp::session::~session()
|
|||
|
||||
uvg_rtp::media_stream *uvg_rtp::session::create_stream(int r_port, int s_port, rtp_format_t fmt, int flags)
|
||||
{
|
||||
std::lock_guard<std::mutex> m(session_mtx_);
|
||||
|
||||
uvg_rtp::media_stream *stream = nullptr;
|
||||
|
||||
if (flags & RCE_SYSTEM_CALL_DISPATCHER) {
|
||||
|
|
Loading…
Reference in New Issue