|
|
@ -237,24 +237,11 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if ((__GNUC__ == 4) && (__GNUC_MINOR__ <= 7)) || defined(__NetBSD__) |
|
|
|
|
|
|
|
// due the bug in gcc 4.7. std::shared_future.get() is not const
|
|
|
|
|
|
|
|
CreateAESKey (m_Establisher->phase2.pubKey); |
|
|
|
|
|
|
|
HandlePhase2 (); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
auto s = shared_from_this (); |
|
|
|
auto s = shared_from_this (); |
|
|
|
// create AES key in separate thread
|
|
|
|
m_Server.Work(s, [s]() -> std::function<void(void)> { |
|
|
|
auto keyCreated = std::async (std::launch::async, [s] () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
s->CreateAESKey (s->m_Establisher->phase2.pubKey); |
|
|
|
s->CreateAESKey (s->m_Establisher->phase2.pubKey); |
|
|
|
}).share (); // TODO: use move capture in C++ 14 instead shared_future
|
|
|
|
return std::bind(&NTCPSession::HandlePhase2, s); |
|
|
|
// let other operations execute while a key gets created
|
|
|
|
|
|
|
|
m_Server.GetService ().post ([s, keyCreated]() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
keyCreated.get (); // we might wait if no more pending operations
|
|
|
|
|
|
|
|
s->HandlePhase2 (); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|