Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release-2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pnoltes committed Sep 23, 2023
2 parents 25745ae + be8a413 commit 724f8d8
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <pubsub_constants.h>
#include <pubsub/publisher.h>
#include <utils.h>
#include <zconf.h>
#include <arpa/inet.h>
#include <celix_log_helper.h>
#include "pubsub_psa_tcp_constants.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <pubsub_constants.h>
#include <pubsub/publisher.h>
#include <utils.h>
#include <zconf.h>
#include <arpa/inet.h>
#include <pubsub_utils.h>
#include "pubsub_udpmc_topic_sender.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <pubsub_constants.h>
#include <pubsub/publisher.h>
#include <utils.h>
#include <zconf.h>
#include <celix_log_helper.h>
#include "pubsub_websocket_topic_sender.h"
#include "pubsub_psa_websocket_constants.h"
Expand Down
11 changes: 11 additions & 0 deletions documents/building/dev_celix_with_clion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
19 changes: 5 additions & 14 deletions libs/framework/src/celix_scheduled_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <assert.h>

#include "celix_constants.h"
#include "celix_ref.h"
#include "celix_utils.h"

/**
Expand All @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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);
Expand All @@ -136,25 +137,15 @@ 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;
}

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; }
Expand Down
9 changes: 8 additions & 1 deletion libs/utils/gtest/src/FileUtilsTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions libs/utils/src/celix_file_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <stdlib.h>
#include <utils.h>
#include <arpa/inet.h>
#include <zconf.h>
#include <LogHelper.h>
#include <nanomsg/nn.h>
#include <nanomsg/bus.h>
Expand Down

0 comments on commit 724f8d8

Please sign in to comment.