connectivity: use default initializer to avoid locks

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