Skip to content

Commit

Permalink
gh-685: Add bundle entry guard
Browse files Browse the repository at this point in the history
Also improves several small issues based on
review comments.
  • Loading branch information
pnoltes committed Jun 9, 2024
1 parent a014956 commit 8b0e0e0
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveCreateErrorTest) {
EXPECT_EQ(CELIX_SUCCESS, celix_utils_extractZipFile(SIMPLE_TEST_BUNDLE1_LOCATION, testExtractDir, nullptr));
EXPECT_EQ(CELIX_SUCCESS,
celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 2, testExtractDir, &archive));
bundleArchive_destroy(archive);
celix_bundleArchive_destroy(archive);
archive = nullptr;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
celix_utils_touch(SIMPLE_TEST_BUNDLE1_LOCATION);
Expand All @@ -223,7 +223,7 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveCreateErrorTest) {

EXPECT_EQ(CELIX_SUCCESS,
celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 1, SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
bundleArchive_destroy(archive);
celix_bundleArchive_destroy(archive);
archive = nullptr;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
celix_utils_touch(SIMPLE_TEST_BUNDLE1_LOCATION);
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/src/bundle_archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *arc
celix_utils_deleteDirectory(archive->archiveRoot, NULL);
}
init_failed:
bundleArchive_destroy(archive);
celix_bundleArchive_destroy(archive);
calloc_failed:
celix_framework_logTssErrors(fw->logger, CELIX_LOG_LEVEL_ERROR);
framework_logIfError(fw->logger, status, error, "Could not create archive.");
return status;
}

void bundleArchive_destroy(bundle_archive_pt archive) {
void celix_bundleArchive_destroy(bundle_archive_pt archive) {
if (archive != NULL) {
free(archive->location);
free(archive->savedBundleStatePropertiesPath);
Expand Down
2 changes: 1 addition & 1 deletion libs/framework/src/bundle_archive_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {
*/
celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *archiveRoot, long id, const char *location, bundle_archive_pt *bundle_archive);

void bundleArchive_destroy(bundle_archive_pt archive);
void celix_bundleArchive_destroy(bundle_archive_pt archive);

/**
* @brief Returns the bundle id of the bundle archive.
Expand Down
6 changes: 3 additions & 3 deletions libs/framework/src/celix_bundle_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void celix_bundleCache_destroyArchive(celix_bundle_cache_t* cache, bundle_archiv
}
(void)celix_bundleArchive_removeInvalidDirs(archive);
celixThreadMutex_unlock(&cache->mutex);
bundleArchive_destroy(archive);
celix_bundleArchive_destroy(archive);
}

/**
Expand Down Expand Up @@ -242,7 +242,7 @@ static celix_status_t celix_bundleCache_updateIdForLocationLookupMap(celix_bundl
fw_logCode(cache->fw->logger, CELIX_LOG_LEVEL_ERROR, status,
"Cannot load bundle state properties from %s", bundleStateProperties);
celix_framework_logTssErrors(cache->fw->logger, CELIX_LOG_LEVEL_ERROR);
return CELIX_FILE_IO_EXCEPTION;
return status;
}
const char* visitLoc = celix_properties_get(props, CELIX_BUNDLE_ARCHIVE_LOCATION_PROPERTY_NAME, NULL);
long bndId = celix_properties_getAsLong(props, CELIX_BUNDLE_ARCHIVE_BUNDLE_ID_PROPERTY_NAME, -1);
Expand Down Expand Up @@ -309,7 +309,7 @@ celix_bundleCache_createBundleArchivesForSpaceSeparatedList(celix_framework_t* f
fw_log(fw->logger, lvl, "Created bundle cache '%s' for bundle archive %s (bndId=%li).",
celix_bundleArchive_getCurrentRevisionRoot(archive),
celix_bundleArchive_getSymbolicName(archive), celix_bundleArchive_getId(archive));
bundleArchive_destroy(archive);
celix_bundleArchive_destroy(archive);
}
location = strtok_r(NULL, delims, &savePtr);
}
Expand Down
4 changes: 2 additions & 2 deletions libs/framework/src/celix_launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ int celix_launcher_launchAndWait(int argc, char* argv[], const char* embeddedCon

celix_framework_t* framework = NULL;
status = celix_launcher_createFramework(celix_steal_ptr(embeddedProps), runtimeProps, &framework);
if (status == CELIX_SUCCESS && framework) {
if (status == CELIX_SUCCESS) {
status = celix_launcher_setGlobalFramework(framework);
if (status != CELIX_SUCCESS) {
return CELIX_LAUNCHER_ERROR_EXIT_CODE;
Expand Down Expand Up @@ -235,7 +235,7 @@ static celix_status_t celix_launcher_createFramework(celix_properties_t* embedde
sigaction(SIGUSR2, &sigact, NULL);

#ifndef CELIX_NO_CURLINIT
// Before doing anything else, let's setup Curl
// Before doing anything else, lets setup Curl
curl_global_init(CURL_GLOBAL_ALL);
#endif

Expand Down
2 changes: 1 addition & 1 deletion libs/framework/src/celix_launcher_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void celix_launcher_stopInternal(const int* signal);
* @brief Create a combined configuration properties set by combining the embedded properties with the runtime
* properties.
* @param[in,out] embeddedProps The embedded properties to use and extend with the runtime properties.
* @param[in] configFile The optional runtime properties file to load and use.
* @param[in] runtimeProps The optional runtime properties file to load and use.
*/
celix_status_t celix_launcher_combineProperties(celix_properties_t* embeddedProps,
const celix_properties_t* runtimeProps);
Expand Down
Loading

0 comments on commit 8b0e0e0

Please sign in to comment.