From 65f49f9f07f9d65b58fba0a82aaf41ba470b149b Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nicolas.pope@utu.fi> Date: Mon, 9 May 2022 08:44:30 +0100 Subject: [PATCH] Add windows pipelines --- .gitlab-ci.yml | 80 +++++++++++++++++------------------ include/ftl/protocol/node.hpp | 2 - src/node.cpp | 4 -- src/peer.cpp | 19 +++++---- src/peer.hpp | 6 +-- 5 files changed, 52 insertions(+), 59 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 366fbf1..fad8a79 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -110,47 +110,47 @@ linux:valgrind: ### Windows -#windows:build: -# only: -# - main -# - merge_requests - -# stage: build -# tags: -# - windows - -# cache: # use artifacts instead if multiple runners available -# key: $CI_COMMIT_SHORT_SHA -# paths: -# - build/ - -# script: -# - Import-Module "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll" -# - Enter-VsDevShell -VsInstallPath "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/" -# - cd $CI_PROJECT_DIR -# - if (Test-Path build) { Remove-Item build/ -Recurse } -# - mkdir build -# - cd build -# - cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DWITH_GNUTLS=TRUE -DGNUTLS_INCLUDE_DIR="C:/Build/bin/gnutls/lib/includes/" -DGNUTLS_LIBRARY="C:/Build/bin/gnutls/lib/libgnutls.dll.a" .. -# - '& MSBuild.exe beyond-ftl.sln -property:Configuration=Release -nr:false -maxCpuCount' - -#windows:test: -# only: -# - master -# - merge_requests +windows:build: + only: + - main + - merge_requests + + stage: build + tags: + - windows + + cache: # use artifacts instead if multiple runners available + key: $CI_COMMIT_SHORT_SHA + paths: + - build/ + + script: + - Import-Module "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll" + - Enter-VsDevShell -VsInstallPath "C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/" + - cd $CI_PROJECT_DIR + - if (Test-Path build) { Remove-Item build/ -Recurse } + - mkdir build + - cd build + - cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DWITH_GNUTLS=TRUE -DGNUTLS_INCLUDE_DIR="C:/Build/bin/gnutls/lib/includes/" -DGNUTLS_LIBRARY="C:/Build/bin/gnutls/lib/libgnutls.dll.a" .. + - '& MSBuild.exe beyond-protocol.sln -property:Configuration=Release -nr:false -maxCpuCount' + +windows:test: + only: + - master + - merge_requests -# stage: test + stage: test -# tags: -# - windows -# needs: ["windows:build"] + tags: + - windows + needs: ["windows:build"] -# cache: # use artifacts instead if multiple runners available -# key: $CI_COMMIT_SHORT_SHA -# paths: -# - build/ + cache: # use artifacts instead if multiple runners available + key: $CI_COMMIT_SHORT_SHA + paths: + - build/ -# script: -# - $env:PATH+=";C:/Shared/Deploy" -# - cd build -# - ctest -V --output-on-failure --timeout 60 + script: + - $env:PATH+=";C:/Shared/Deploy" + - cd build + - ctest -V --output-on-failure --timeout 60 diff --git a/include/ftl/protocol/node.hpp b/include/ftl/protocol/node.hpp index ef67ea0..97887e9 100644 --- a/include/ftl/protocol/node.hpp +++ b/include/ftl/protocol/node.hpp @@ -101,8 +101,6 @@ class Node { * Get the peer id as a string. */ std::string to_string() const; - - bool isWaiting() const; void noReconnect(); diff --git a/src/node.cpp b/src/node.cpp index d647de0..cac2db8 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -51,10 +51,6 @@ const ftl::UUID &Node::id() const { std::string Node::to_string() const { return peer_->to_string(); } - -bool Node::isWaiting() const { - return peer_->isWaiting(); -} void Node::noReconnect() { peer_->noReconnect(); diff --git a/src/peer.cpp b/src/peer.cpp index f0708cc..fc5e6c6 100644 --- a/src/peer.cpp +++ b/src/peer.cpp @@ -126,7 +126,7 @@ void Peer::_bind_rpc() { } Peer::Peer(std::unique_ptr<internal::SocketConnection> s, Universe* u, Dispatcher* d) : - is_waiting_(true), outgoing_(false), local_id_(0), + outgoing_(false), local_id_(0), uri_("0"), status_(NodeStatus::kConnecting), can_reconnect_(false), net_(u), sock_(std::move(s)) { @@ -150,7 +150,7 @@ Peer::Peer(const ftl::URI& uri, Universe *u, Dispatcher *d) : /* Outgoing connection constructor */ // Must do to prevent receiving message before handlers are installed - UNIQUE_LOCK(recv_mtx_,lk); + //UNIQUE_LOCK(recv_mtx_,lk); disp_ = std::make_unique<Dispatcher>(d); @@ -167,7 +167,6 @@ void Peer::_connect() { _set_socket_options(); sock_->connect(uri_); // throws on error status_ = NodeStatus::kConnecting; - is_waiting_ = true; } /** Called from ftl::Universe::_periodic() */ @@ -198,7 +197,7 @@ void Peer::_updateURI() { void Peer::rawClose() { UNIQUE_LOCK(send_mtx_, lk_send); - UNIQUE_LOCK(recv_mtx_, lk_recv); + //UNIQUE_LOCK(recv_mtx_, lk_recv); sock_->close(); status_ = NodeStatus::kDisconnected; } @@ -208,7 +207,7 @@ void Peer::close(bool retry) { if (sock_->is_valid()) { send("__disconnect__"); } UNIQUE_LOCK(send_mtx_, lk_send); - UNIQUE_LOCK(recv_mtx_, lk_recv); + //UNIQUE_LOCK(recv_mtx_, lk_recv); _close(retry); } @@ -320,8 +319,10 @@ void Peer::data() { recv_buf_.buffer_consumed(rc); - if (is_waiting_) { - is_waiting_ = false; + // FIXME: This might get skipped incorrectly. + // However, it should be extremely unlikely given that recv is done already + //UNIQUE_LOCK(recv_mtx_, lk); + if (!already_processing_.test_and_set()) { //lk.unlock(); ++job_count_; @@ -364,7 +365,7 @@ bool Peer::_data() { try { bool has_next = _has_next() && recv_buf_.next(msg_handle); if (!has_next) { - is_waiting_ = true; + already_processing_.clear(); return false; } } catch (const std::exception& ex) { @@ -557,7 +558,7 @@ Peer::~Peer() { --net_->peer_instances_; { UNIQUE_LOCK(send_mtx_,lk1); - UNIQUE_LOCK(recv_mtx_,lk2); + //UNIQUE_LOCK(recv_mtx_,lk2); _close(false); } diff --git a/src/peer.hpp b/src/peer.hpp index 4cdd174..72fad36 100644 --- a/src/peer.hpp +++ b/src/peer.hpp @@ -185,8 +185,6 @@ class Peer { */ template <typename F> void bind(const std::string &name, F func); - - bool isWaiting() const { return is_waiting_; } void rawClose(); @@ -246,10 +244,10 @@ private: // Functions } } - std::atomic_bool is_waiting_; + std::atomic_flag already_processing_ = ATOMIC_FLAG_INIT; msgpack::unpacker recv_buf_; - RECURSIVE_MUTEX recv_mtx_; + //MUTEX recv_mtx_; // Send buffers msgpack::vrefbuffer send_buf_; -- GitLab