Skip to content
Snippets Groups Projects
Unverified Commit b416ecf6 authored by Sébastien Blin's avatar Sébastien Blin
Browse files

connectivity: use default initializer to avoid locks

Change-Id: Id0a13edf4f27b5f2fa11a63e4286166058c59ade
parent b97ab280
No related branches found
No related tags found
No related merge requests found
...@@ -64,25 +64,25 @@ private: ...@@ -64,25 +64,25 @@ private:
NON_COPYABLE(ChanneledSIPTransport); NON_COPYABLE(ChanneledSIPTransport);
// The SIP transport uses a ChannelSocket to send and receive datas // The SIP transport uses a ChannelSocket to send and receive datas
std::shared_ptr<ChannelSocket> socket_; std::shared_ptr<ChannelSocket> socket_ {};
IpAddr local_; IpAddr local_ {};
IpAddr remote_; IpAddr remote_ {};
// PJSIP transport backend // PJSIP transport backend
TransportData trData_; // uplink to "this" (used by PJSIP called C-callbacks) TransportData trData_ {}; // uplink to "this" (used by PJSIP called C-callbacks)
std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> pool_; std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> pool_;
std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> rxPool_; std::unique_ptr<pj_pool_t, decltype(pj_pool_release)*> rxPool_;
std::mutex rxMtx_; std::mutex rxMtx_ {};
std::list<std::vector<uint8_t>> rxPending_; std::list<std::vector<uint8_t>> rxPending_ {};
pjsip_rx_data rdata_; pjsip_rx_data rdata_ {};
std::mutex txMutex_ {}; std::mutex txMutex_ {};
std::condition_variable txCv_ {}; std::condition_variable txCv_ {};
std::list<pjsip_tx_data*> txQueue_ {}; std::list<pjsip_tx_data*> txQueue_ {};
ScheduledExecutor scheduler_; ScheduledExecutor scheduler_ {};
pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback); pj_status_t send(pjsip_tx_data*, const pj_sockaddr_t*, int, void*, pjsip_transport_callback);
void handleEvents(); void handleEvents();
......
...@@ -45,8 +45,8 @@ struct ConnectionInfo ...@@ -45,8 +45,8 @@ struct ConnectionInfo
{ {
std::condition_variable responseCv_ {}; std::condition_variable responseCv_ {};
std::atomic_bool responseReceived_ {false}; std::atomic_bool responseReceived_ {false};
PeerConnectionRequest response_; PeerConnectionRequest response_ {};
std::mutex mutex_; std::mutex mutex_ {};
std::unique_ptr<IceTransport> ice_ {nullptr}; std::unique_ptr<IceTransport> ice_ {nullptr};
}; };
...@@ -158,27 +158,27 @@ public: ...@@ -158,27 +158,27 @@ public:
// Note: Someone can ask multiple sockets, so to avoid any race condition, // Note: Someone can ask multiple sockets, so to avoid any race condition,
// each device can have multiple multiplexed sockets. // each device can have multiple multiplexed sockets.
std::map<std::string /* device id */, std::map<dht::Value::Id /* uid */, ConnectionInfo>> std::map<std::string /* device id */, std::map<dht::Value::Id /* uid */, ConnectionInfo>>
connectionsInfos_; connectionsInfos_ {};
// Used to store currently non ready TLS Socket // Used to store currently non ready TLS Socket
std::mutex nonReadySocketsMutex_; std::mutex nonReadySocketsMutex_ {};
std::map<std::string /* device id */, std::map<std::string /* device id */,
std::map<dht::Value::Id /* uid */, std::unique_ptr<TlsSocketEndpoint>>> std::map<dht::Value::Id /* uid */, std::unique_ptr<TlsSocketEndpoint>>>
nonReadySockets_; nonReadySockets_ {};
std::mutex msocketsMutex_; std::mutex msocketsMutex_ {};
// Note: Multiplexed sockets is also stored in ChannelSockets, so has to be shared_ptr // Note: Multiplexed sockets is also stored in ChannelSockets, so has to be shared_ptr
std::map<std::string /* device id */, std::map<std::string /* device id */,
std::map<dht::Value::Id /* uid */, std::shared_ptr<MultiplexedSocket>>> std::map<dht::Value::Id /* uid */, std::shared_ptr<MultiplexedSocket>>>
multiplexedSockets_; multiplexedSockets_ {};
// key: Stored certificate PublicKey id (normaly it's the DeviceId) // key: Stored certificate PublicKey id (normaly it's the DeviceId)
// value: pair of shared_ptr<Certificate> and associated RingId // value: pair of shared_ptr<Certificate> and associated RingId
std::map<dht::InfoHash, std::pair<std::shared_ptr<dht::crypto::Certificate>, dht::InfoHash>> std::map<dht::InfoHash, std::pair<std::shared_ptr<dht::crypto::Certificate>, dht::InfoHash>>
certMap_; certMap_ {};
bool validatePeerCertificate(const dht::crypto::Certificate&, dht::InfoHash&); bool validatePeerCertificate(const dht::crypto::Certificate&, dht::InfoHash&);
ChannelRequestCallback channelReqCb_; ChannelRequestCallback channelReqCb_ {};
ConnectionReadyCallback connReadyCb_; ConnectionReadyCallback connReadyCb_ {};
onICERequestCallback iceReqCb_; onICERequestCallback iceReqCb_ {};
std::mutex connectCbsMtx_ {}; std::mutex connectCbsMtx_ {};
std::map<std::pair<std::string, dht::Value::Id>, ConnectCallback> pendingCbs_ {}; std::map<std::pair<std::string, dht::Value::Id>, ConnectCallback> pendingCbs_ {};
......
...@@ -110,27 +110,27 @@ public: ...@@ -110,27 +110,27 @@ public:
void setOnReady(OnConnectionReadyCb&& cb) { onChannelReady_ = std::move(cb); } void setOnReady(OnConnectionReadyCb&& cb) { onChannelReady_ = std::move(cb); }
void setOnRequest(OnConnectionRequestCb&& cb) { onRequest_ = std::move(cb); } void setOnRequest(OnConnectionRequestCb&& cb) { onRequest_ = std::move(cb); }
msgpack::unpacker pac_; msgpack::unpacker pac_ {};
MultiplexedSocket& parent_; MultiplexedSocket& parent_;
OnConnectionReadyCb onChannelReady_; OnConnectionReadyCb onChannelReady_ {};
OnConnectionRequestCb onRequest_; OnConnectionRequestCb onRequest_ {};
OnShutdownCb onShutdown_; OnShutdownCb onShutdown_ {};
std::string deviceId; std::string deviceId {};
// Main socket // Main socket
std::unique_ptr<TlsSocketEndpoint> endpoint; std::unique_ptr<TlsSocketEndpoint> endpoint {};
std::mutex socketsMutex; std::mutex socketsMutex {};
std::map<uint16_t, std::shared_ptr<ChannelSocket>> sockets; std::map<uint16_t, std::shared_ptr<ChannelSocket>> sockets {};
// Contains callback triggered when a channel is ready // Contains callback triggered when a channel is ready
std::mutex channelCbsMutex; std::mutex channelCbsMutex {};
std::map<uint16_t, onChannelReadyCb> channelCbs; std::map<uint16_t, onChannelReadyCb> channelCbs {};
// Main loop to parse incoming packets // Main loop to parse incoming packets
std::future<void> eventLoopFut_; std::future<void> eventLoopFut_ {};
std::atomic_bool stop; std::atomic_bool stop {};
// Multiplexed available datas // Multiplexed available datas
std::map<uint16_t, std::unique_ptr<ChannelInfo>> channelDatas_ {}; std::map<uint16_t, std::unique_ptr<ChannelInfo>> channelDatas_ {};
...@@ -138,7 +138,7 @@ public: ...@@ -138,7 +138,7 @@ public:
std::map<uint16_t, GenericSocket<uint8_t>::RecvCb> channelCbs_ {}; std::map<uint16_t, GenericSocket<uint8_t>::RecvCb> channelCbs_ {};
std::atomic_bool isShutdown_ {false}; std::atomic_bool isShutdown_ {false};
std::mutex writeMtx; std::mutex writeMtx {};
}; };
void void
...@@ -517,11 +517,11 @@ public: ...@@ -517,11 +517,11 @@ public:
~Impl() {} ~Impl() {}
OnShutdownCb shutdownCb_; OnShutdownCb shutdownCb_ {};
std::atomic_bool isShutdown_ {false}; std::atomic_bool isShutdown_ {false};
std::string name; std::string name {};
uint16_t channel; uint16_t channel {};
std::weak_ptr<MultiplexedSocket> endpoint; std::weak_ptr<MultiplexedSocket> endpoint {};
}; };
ChannelSocket::ChannelSocket(std::weak_ptr<MultiplexedSocket> endpoint, ChannelSocket::ChannelSocket(std::weak_ptr<MultiplexedSocket> endpoint,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment