Skip to content

Commit

Permalink
Data race!!!!!!!!!!!!!!!!!!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Sep 21, 2024
1 parent 2daa761 commit 6601ca2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ntcore/src/main/native/cpp/net/TimeSyncClientServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,15 @@ wpi::TimeSyncServer::TimeSyncServer(int port,
: m_logger{::ServerLoggerFunc},
m_timeProvider{timeProvider},
m_udp{wpi::uv::Udp::Create(m_loopRunner.GetLoop(), AF_INET)} {
m_udp->Bind("0.0.0.0", port);
m_loopRunner.ExecSync(
[this, port](uv::Loop&) { m_udp->Bind("0.0.0.0", port); });
}

void wpi::TimeSyncServer::Start() {
m_udp->received.connect(&wpi::TimeSyncServer::UdpCallback, this);
m_udp->StartRecv();
m_loopRunner.ExecSync([this](uv::Loop&) {
m_udp->received.connect(&wpi::TimeSyncServer::UdpCallback, this);
m_udp->StartRecv();
});
}

void wpi::TimeSyncServer::Stop() {
Expand Down Expand Up @@ -269,13 +272,17 @@ wpi::TimeSyncClient::TimeSyncClient(std::string_view server, int remote_port,
m_loopDelay(ping_delay) {
struct sockaddr_in serverAddr;
uv::NameToAddr(m_serverIP, m_serverPort, &serverAddr);
m_udp->Connect(serverAddr);

m_loopRunner.ExecSync([this, serverAddr](uv::Loop&) { m_udp->Connect(serverAddr); });
}

void wpi::TimeSyncClient::Start() {
wpi::println("Connecting recieved");
m_udp->received.connect(&wpi::TimeSyncClient::UdpCallback, this);
m_udp->StartRecv();

m_loopRunner.ExecSync([this](uv::Loop&) {
m_udp->received.connect(&wpi::TimeSyncClient::UdpCallback, this);
m_udp->StartRecv();
});

wpi::println("Starting pinger");
using namespace std::chrono_literals;
Expand Down

0 comments on commit 6601ca2

Please sign in to comment.