Protect access to ZRTP state by a mutex

This commit is contained in:
Aaro Altonen 2020-07-23 13:05:55 +03:00
parent 333517c113
commit ffc24e6b49
2 changed files with 7 additions and 0 deletions

View File

@ -10,6 +10,7 @@
#include <arpa/inet.h>
#endif
#include <mutex>
#include <vector>
#include "crypto.hh"
@ -287,6 +288,8 @@ namespace uvg_rtp {
zrtp_crypto_ctx_t cctx_;
zrtp_session_t session_;
std::mutex zrtp_mtx_;
};
};
#endif

View File

@ -599,6 +599,8 @@ rtp_error_t uvg_rtp::zrtp::init(uint32_t ssrc, socket_t& socket, sockaddr_in& ad
rtp_error_t uvg_rtp::zrtp::init_dhm(uint32_t ssrc, socket_t& socket, sockaddr_in& addr)
{
std::lock_guard<std::mutex> lock(zrtp_mtx_);
rtp_error_t ret = RTP_OK;
/* TODO: set all fields initially to zero */
@ -695,6 +697,8 @@ rtp_error_t uvg_rtp::zrtp::init_dhm(uint32_t ssrc, socket_t& socket, sockaddr_in
rtp_error_t uvg_rtp::zrtp::init_msm(uint32_t ssrc, socket_t& socket, sockaddr_in& addr)
{
std::lock_guard<std::mutex> lock(zrtp_mtx_);
rtp_error_t ret;
socket_ = socket;