Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/python-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
uses: uraimo/run-on-arch-action@v3
with:
arch: riscv64
distro: ubuntu_latest
distro: ubuntu22.04
githubToken: ${{ github.token }}

install: |
Expand All @@ -121,7 +121,7 @@ jobs:
set -eux
echo "Building for RISC-V on Ubuntu 22.04"

python3 -m pip install -r build-requirements.txt --break-system-packages
python3 -m pip install -r build-requirements.txt #--break-system-packages

mkdir -p /tmp/capio_cl_jsons
mkdir -p /tmp/capio_cl_tomls
Expand All @@ -133,7 +133,9 @@ jobs:
-Ccmake.build-type=Release \
-Ccmake.define.CAPIO_CL_BUILD_TESTS=OFF

pip install dist/*.whl --break-system-packages
python3 -m pip install -r test-requirements.txt --break-system-packages
pip install dist/*.whl #--break-system-packages
python3 -m pip install -r test-requirements.txt #--break-system-packages

pytest -v tests/python/test_* | tee pytest-riscv.log
export PYTHONUNBUFFERED=1
pytest -vvv -s --timeout=120 --timeout-method=thread \
tests/python/test_bindings.py tests/python/test_parser_serializer.py
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ FetchContent_Declare(
FetchContent_Declare(
jsoncons
GIT_REPOSITORY https://github.com/danielaparker/jsoncons.git
GIT_TAG v1.4.3
GIT_TAG v1.8.1
)

set(JSONCONS_BUILD_TESTS OFF CACHE BOOL "" FORCE)
Expand Down
11 changes: 7 additions & 4 deletions capiocl/monitor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef CAPIO_CL_MONITOR_H
#define CAPIO_CL_MONITOR_H

#include <atomic>
#include <filesystem>
#include <mutex>
#include <set>
Expand Down Expand Up @@ -147,7 +148,7 @@ class MulticastMonitor final : public MonitorInterface {
std::string MULTICAST_HOME_NODE_ADDR;

/// @brief variable to terminate execution
bool terminate = false;
std::atomic<bool> terminate = false;

/// @brief Multicast poll timeout interval
static constexpr int MULTICAST_THREAD_POLL_INTERVAL = 250;
Expand Down Expand Up @@ -189,10 +190,11 @@ class MulticastMonitor final : public MonitorInterface {
* @param lock Mutex protecting shared access to committed_files.
* @param ip_addr Multicast commit listen address.
* @param ip_port Multicast commit listen port.
* @param terminate Boolean flag to terminate thread
* @param terminate Atomic Boolean flag to terminate thread
*/
static void commit_listener(std::vector<std::string> &committed_files, std::mutex &lock,
const std::string &ip_addr, int ip_port, const bool *terminate);
const std::string &ip_addr, int ip_port,
const std::atomic<bool> *terminate);

/**
* @brief Background thread function to listen for commit messages.
Expand All @@ -205,10 +207,11 @@ class MulticastMonitor final : public MonitorInterface {
* @param lock Mutex protecting shared access to committed_files.
* @param ip_addr Multicast home node listen address.
* @param ip_port Multicast home node listen port.
* @param terminate Atomic Boolean flag to terminate thread
*/
static void home_node_listener(std::unordered_map<std::string, std::string> &home_nodes,
std::mutex &lock, const std::string &ip_addr, int ip_port,
const bool *terminate);
const std::atomic<bool> *terminate);

public:
/**
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void capiocl::parser::Parser::validate_json(const jsoncons::json &doc, const cha
jsoncons::jsonschema::json_schema<jsoncons::json> schema = loadSchema(str_schema);
try {
// throws jsoncons::jsonschema::validation_error on failure
[[maybe_unused]] auto status = schema.validate(doc);
schema.validate(doc);
} catch (const jsoncons::jsonschema::validation_error &e) {
printer::print(printer::CLI_LEVEL_ERROR, e.what());
throw ParserException("JSON validation failed!");
Expand Down
18 changes: 10 additions & 8 deletions src/monitors/Multicast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ static int incoming_socket_multicast(const std::string &address_ip, const int po
void capiocl::monitor::MulticastMonitor::commit_listener(std::vector<std::string> &committed_files,
std::mutex &lock,
const std::string &ip_addr,
const int ip_port, const bool *terminate) {
const int ip_port,
const std::atomic<bool> *terminate) {
pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr);
sockaddr_in addr_in = {};
socklen_t addr_len = {};
Expand Down Expand Up @@ -134,7 +135,7 @@ void capiocl::monitor::MulticastMonitor::commit_listener(std::vector<std::string

void capiocl::monitor::MulticastMonitor::home_node_listener(
std::unordered_map<std::string, std::string> &home_nodes, std::mutex &lock,
const std::string &ip_addr, int ip_port, const bool *terminate) {
const std::string &ip_addr, int ip_port, const std::atomic<bool> *terminate) {
pthread_setcancelstate(PTHREAD_CANCEL_ASYNCHRONOUS, nullptr);

char this_hostname[HOST_NAME_MAX] = {};
Expand Down Expand Up @@ -168,7 +169,7 @@ void capiocl::monitor::MulticastMonitor::home_node_listener(
}

// LCOV_EXCL_START
if (recvfrom(socket, incoming_message, MESSAGE_SIZE, 0, addr, &addr_len) < 0) {
if (recvfrom(socket, incoming_message, MESSAGE_SIZE, MSG_DONTWAIT, addr, &addr_len) < 0) {
continue;
}
// LCOV_EXCL_STOP
Expand Down Expand Up @@ -244,11 +245,12 @@ capiocl::monitor::MulticastMonitor::~MulticastMonitor() {

terminate = true;

pthread_cancel(commit_thread.native_handle());
commit_thread.join();

pthread_cancel(home_node_thread.native_handle());
home_node_thread.join();
if (commit_thread.joinable()) {
commit_thread.join();
}
if (home_node_thread.joinable()) {
home_node_thread.join();
}
}

bool capiocl::monitor::MulticastMonitor::isCommitted(const std::filesystem::path &path) const {
Expand Down
3 changes: 2 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pytest==8.4.2
pytest==8.4.2
pytest-timeout==2.4.0
Loading