File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,8 @@ std::unique_ptr<transport::Pair>& Context::getPair(int rank) {
177
177
return pair;
178
178
}
179
179
180
+ std::lock_guard<std::mutex> lock (m_);
181
+
180
182
if (!connecting_[rank]) {
181
183
connecting_[rank] = true ;
182
184
@@ -187,6 +189,7 @@ std::unique_ptr<transport::Pair>& Context::getPair(int rank) {
187
189
188
190
auto remoteDeviceAddr = Address (remoteRankInfo.addressBytes ).getSockaddr ();
189
191
auto remoteAddr = Address (remoteDeviceAddr, this ->rank );
192
+ // Actual connection happens asynchronously.
190
193
pair->connect (remoteAddr.bytes ());
191
194
}
192
195
return pair;
Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ class Context : public ::gloo::transport::Context,
52
52
protected:
53
53
std::shared_ptr<Device> device_;
54
54
std::shared_ptr<IStore> store_{nullptr };
55
+
56
+ // Protects the connection states to avoid race conditions.
57
+ std::mutex m_;
58
+ // Whether or not connection has been started for this peer.
55
59
std::vector<bool > connecting_;
56
60
57
61
using pendingRecvTuple = std::tuple<
You can’t perform that action at this time.
0 commit comments