Skip to content

Commit

Permalink
improved stability
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanShangin-biterp committed Dec 28, 2024
1 parent 712b884 commit c2a1e65
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/SynchServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ void SynchClientServer::stopServer_()

allThreadsNeedToTerminate.store(true, std::memory_order_seq_cst);

std::this_thread::sleep_for(std::chrono::milliseconds(1000));

// establish temporary connections on all server ports to exit loops in the accept_connections_thread thread,
// since the acceptor.accept () method is blocking
for (auto const& portSettingPair : portsSettings) {
Expand Down Expand Up @@ -376,12 +378,16 @@ void SynchClientServer::terminateServer()
addLogInFile("DEBUG: start terminateServer()");

std::unique_lock<std::mutex> lk(stopServer_mutex);

stopServer_();

std::this_thread::sleep_for(std::chrono::milliseconds(3000));

service_io.post([this]() {
work_io.reset(); // let io_service run out of work
});
service_io.stop();
stopServer_();


if (getLoggingRequired())
addLogInFile("DEBUG: done terminateServer()");
Expand Down Expand Up @@ -483,6 +489,9 @@ void SynchClientServer::accept_connections_thread(const portSettings_ptr & portS
std::unique_lock<std::mutex> lk_connections(connections_mutex);
clientsConnections.push_back(newConnection_);
}

if (loggingRequired)
addLog("finish accept_connections_thread");
}

void SynchClientServer::handle_connections_thread() {
Expand All @@ -500,6 +509,9 @@ void SynchClientServer::handle_connections_thread() {
sendMessagesToConnection(clientConnection_ptr);
}
}

if (loggingRequired)
addLog("finish handle_connections_thread");
}

void SynchClientServer::clean_thread()
Expand Down
4 changes: 2 additions & 2 deletions windows/WindowsAddin/WindowsAddin.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<AdditionalIncludeDirectories>C:\Users\REShangin\Documents\dev\boost_1_72_0</AdditionalIncludeDirectories>
<FavorSizeOrSpeed>Neither</FavorSizeOrSpeed>
<Optimization>Disabled</Optimization>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down

0 comments on commit c2a1e65

Please sign in to comment.