diff --git a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c index 6250536a9..2ed0bb027 100644 --- a/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c +++ b/bundles/pubsub/pubsub_admin_tcp/src/pubsub_tcp_topic_sender.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "pubsub_psa_tcp_constants.h" diff --git a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c index d14a070f5..4197562ce 100644 --- a/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c +++ b/bundles/pubsub/pubsub_admin_udp_mc/src/pubsub_udpmc_topic_sender.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include "pubsub_udpmc_topic_sender.h" diff --git a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_sender.c b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_sender.c index e721ac7b1..59e58d75a 100644 --- a/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_sender.c +++ b/bundles/pubsub/pubsub_admin_websocket/src/pubsub_websocket_topic_sender.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "pubsub_websocket_topic_sender.h" #include "pubsub_psa_websocket_constants.h" diff --git a/documents/building/dev_celix_with_clion.md b/documents/building/dev_celix_with_clion.md index 45457be4e..3b0273805 100644 --- a/documents/building/dev_celix_with_clion.md +++ b/documents/building/dev_celix_with_clion.md @@ -60,6 +60,17 @@ ctest --verbose source deactivate_conanrun.sh ``` +### Work with Conan 2 + +The above is for Conan 1.x. +Conan 2 has greatly simplified its integration with CLion. +Issuing the following command will produce a CMakeUserPresets.json at the project root, which CLion will load automatically to set up CMake profiles. +Then Celix can be built within the IDE. + +```shell +conan install . -pr:b default -pr:h default -s:h build_type=Debug -o celix/*:build_all=True -o celix/*:celix_cxx17=True -o celix/*:enable_testing=True -b missing -o celix/*:enable_address_sanitizer=True -of cmake-build-debug +``` + ## Configuring CLion To ensure that all Conan build dependencies can be found the Run/Debug configurations of CLion needs te be updated. diff --git a/libs/framework/src/celix_scheduled_event.c b/libs/framework/src/celix_scheduled_event.c index b63dadf78..e941f194c 100644 --- a/libs/framework/src/celix_scheduled_event.c +++ b/libs/framework/src/celix_scheduled_event.c @@ -22,6 +22,7 @@ #include #include "celix_constants.h" +#include "celix_ref.h" #include "celix_utils.h" /** @@ -44,6 +45,7 @@ static const char* const CELIX_SCHEDULED_EVENT_DEFAULT_NAME = "unnamed"; * @see celix_bundleContext_wakeupScheduledEvent */ struct celix_scheduled_event { + struct celix_ref useCount; /**< The use count of the scheduled event. */ long scheduledEventId; /**< The ID of the scheduled event. */ celix_framework_logger_t* logger; /**< The framework logger used to log information */ long bndId; /**< The bundle id for the bundle that owns the scheduled event. */ @@ -62,7 +64,6 @@ struct celix_scheduled_event { celix_thread_mutex_t mutex; /**< The mutex to protect the data below. */ celix_thread_cond_t cond; /**< The condition variable to signal the scheduled event for a changed callCount and isRemoved. */ - size_t useCount; /**< The use count of the scheduled event. */ size_t callCount; /**< The call count of the scheduled event. */ bool isMarkedForRemoval; /**< Whether the scheduled event is marked for removal. */ bool isRemoved; /**< Whether the scheduled event is removed. */ @@ -110,7 +111,7 @@ celix_scheduled_event_t* celix_scheduledEvent_create(celix_framework_t* fw, event->removedCallbackData = removedCallbackData; event->removedCallback = removedCallback; event->isMarkedForRemoval = false; - event->useCount = 1; + celix_ref_init(&event->useCount); event->callCount = 0; event->isRemoved = false; event->nextDeadline = celixThreadCondition_getDelayedTime(event->initialDelayInSeconds); @@ -136,9 +137,7 @@ celix_scheduled_event_t* celix_scheduledEvent_retain(celix_scheduled_event_t* ev return NULL; } - celixThreadMutex_lock(&event->mutex); - event->useCount += 1; - celixThreadMutex_unlock(&event->mutex); + celix_ref_get(&event->useCount); return event; } @@ -146,15 +145,7 @@ void celix_scheduledEvent_release(celix_scheduled_event_t* event) { if (event == NULL) { return; } - - celixThreadMutex_lock(&event->mutex); - event->useCount -= 1; - bool unused = event->useCount == 0; - celixThreadMutex_unlock(&event->mutex); - - if (unused) { - celix_scheduledEvent_destroy(event); - } + celix_ref_put(&event->useCount, (bool (*)(struct celix_ref *))celix_scheduledEvent_destroy); } const char* celix_scheduledEvent_getName(const celix_scheduled_event_t* event) { return event->eventName; } diff --git a/libs/utils/gtest/src/FileUtilsTestSuite.cc b/libs/utils/gtest/src/FileUtilsTestSuite.cc index 0b4755a95..6ff80d79c 100644 --- a/libs/utils/gtest/src/FileUtilsTestSuite.cc +++ b/libs/utils/gtest/src/FileUtilsTestSuite.cc @@ -189,9 +189,16 @@ TEST_F(FileUtilsTestSuite, ExtractZipFileTest) { EXPECT_EQ(celix_properties_getAsLong(props, "level", 0), 2); celix_properties_destroy(props); + //Given a test zip file, extract to file is a error + const char* error = nullptr; + status = celix_utils_extractZipFile(TEST_ZIP_LOCATION, file1, &error); + EXPECT_NE(status, CELIX_SUCCESS); + EXPECT_NE(error, nullptr); + + //Given a incorrect path extractZipFile returns a error const char* invalidPath = "does-not-exists.zip"; - const char* error = nullptr; + error = nullptr; EXPECT_FALSE(celix_utils_fileExists(invalidPath)); status = celix_utils_extractZipFile(invalidPath, extractLocation, &error); EXPECT_NE(status, CELIX_SUCCESS); diff --git a/libs/utils/src/celix_file_utils.c b/libs/utils/src/celix_file_utils.c index dcfd6b70c..692be8d61 100644 --- a/libs/utils/src/celix_file_utils.c +++ b/libs/utils/src/celix_file_utils.c @@ -214,6 +214,11 @@ static celix_status_t celix_utils_extractZipInternal(zip_t *zip, const char* ext char buf[5120]; size_t bufSize = 5112; + status = celix_utils_createDirectory(extractToDir, false, errorOut); + if (status != CELIX_SUCCESS) { + return status; + } + for (zip_int64_t i = 0; status == CELIX_SUCCESS && i < nrOfEntries; ++i) { zip_stat_t st; if(zip_stat_index(zip, i, 0, &st) == -1) { diff --git a/misc/experimental/bundles/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc b/misc/experimental/bundles/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc index 7deca357b..452ea7853 100644 --- a/misc/experimental/bundles/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc +++ b/misc/experimental/bundles/pubsub_admin_nanomsg/src/pubsub_nanomsg_topic_sender.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include