You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pe...@apache.org on 2023/08/02 09:25:37 UTC
[celix] branch hotfix/framework-startup-optimization updated (5f95cb22 -> 8f089332)
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a change to branch hotfix/framework-startup-optimization
in repository https://gitbox.apache.org/repos/asf/celix.git
from 5f95cb22 Avoid unnecessary cache directory traversal when start with a clean cache.
add bb2c5585 Add initial "hello world" rust bundle example
add 42e3148b Merge branch 'master' into feature/599-rust-hello-world-bundle
add a131c9c3 Move rust dir to misc/experimental and Cargo.lock to gitignore
add 211e70fa 599: Refactor cargo -> cmake target handling
add a0c2ca32 599: Update the experimental Rust readme
add 5d8f5bba 599: Use dynamic lib for the rust bundle activator
add 88bec1d5 Merge pull request #600 from apache/feature/599-rust-hello-world-bundle
add 34f0e990 Remove export_import example from Celix examples
add 55f15fa7 [#531] Remove buggy Export-Library/Import-Library header parsing codes.
add 479df327 Remove resolver and related dead codes.
add d6637a98 Remove support for wire.
add 4ce9a103 Merge branch 'master' into feature/511-remove-resolver
add 072cba2a Merge pull request #601 from apache/feature/511-remove-resolver
new 3eefc0fe Merge branch 'master' into hotfix/framework-startup-optimization
new 8f089332 Code cleanup for bundle_archive.c
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
examples/celix-examples/CMakeLists.txt | 3 -
.../celix-examples/export_import/CMakeLists.txt | 59 ---
.../celix-examples/export_import/include/test.h | 34 --
.../celix-examples/export_import/include/test2.h | 34 --
.../celix-examples/export_import/src/activator.c | 69 ---
examples/celix-examples/export_import/src/test.c | 32 --
examples/celix-examples/export_import/src/test2.c | 32 --
libs/framework/CMakeLists.txt | 2 +-
.../BundleArchiveWithErrorInjectionTestSuite.cc | 6 +-
libs/framework/src/bundle.c | 3 -
libs/framework/src/bundle_archive.c | 66 ++-
libs/framework/src/bundle_archive_private.h | 2 +-
libs/framework/src/capability.c | 64 +--
libs/framework/src/celix_bundle_cache.c | 2 +-
libs/framework/src/celix_launcher.c | 2 +-
libs/framework/src/framework.c | 90 +---
libs/framework/src/framework_private.h | 2 -
libs/framework/src/manifest_parser.c | 380 +---------------
libs/framework/src/manifest_parser.h | 2 -
libs/framework/src/module.c | 125 +-----
libs/framework/src/requirement.c | 79 +---
libs/framework/src/resolver.c | 499 ---------------------
libs/framework/src/resolver.h | 45 --
libs/framework/src/wire.c | 53 +--
misc/experimental/CMakeLists.txt | 3 +-
.../.gitkeep => misc/experimental/rust/.gitignore | 6 +-
misc/experimental/rust/CMakeLists.txt | 45 ++
.../experimental/rust/Cargo.toml | 5 +-
misc/experimental/{ => rust}/README.md | 9 +-
.../rust/hello_world_activator/Cargo.toml | 9 +-
.../rust/hello_world_activator/src/lib.rs | 24 +-
31 files changed, 166 insertions(+), 1620 deletions(-)
delete mode 100644 examples/celix-examples/export_import/CMakeLists.txt
delete mode 100644 examples/celix-examples/export_import/include/test.h
delete mode 100644 examples/celix-examples/export_import/include/test2.h
delete mode 100644 examples/celix-examples/export_import/src/activator.c
delete mode 100644 examples/celix-examples/export_import/src/test.c
delete mode 100644 examples/celix-examples/export_import/src/test2.c
delete mode 100644 libs/framework/src/resolver.c
delete mode 100644 libs/framework/src/resolver.h
copy bundles/pubsub/examples/keys/subscriber/private/.gitkeep => misc/experimental/rust/.gitignore (97%)
create mode 100644 misc/experimental/rust/CMakeLists.txt
copy libs/dfi/error_injector/CMakeLists.txt => misc/experimental/rust/Cargo.toml (93%)
copy misc/experimental/{ => rust}/README.md (65%)
copy libs/framework/gtest/config.properties.in => misc/experimental/rust/hello_world_activator/Cargo.toml (86%)
copy bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/gtest/src/thpool_ei.h => misc/experimental/rust/hello_world_activator/src/lib.rs (69%)
[celix] 02/02: Code cleanup for bundle_archive.c
Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch hotfix/framework-startup-optimization
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 8f08933285bff807b927d2872da9913a701c4878
Author: PengZheng <ho...@gmail.com>
AuthorDate: Wed Aug 2 17:25:02 2023 +0800
Code cleanup for bundle_archive.c
---
.../BundleArchiveWithErrorInjectionTestSuite.cc | 6 +-
libs/framework/src/bundle_archive.c | 66 +++++++++++-----------
libs/framework/src/bundle_archive_private.h | 2 +-
libs/framework/src/celix_bundle_cache.c | 2 +-
4 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
index e4d5d422..03100ddf 100644
--- a/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
+++ b/libs/framework/gtest/src/BundleArchiveWithErrorInjectionTestSuite.cc
@@ -198,7 +198,7 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveCreateErrorTest) {
EXPECT_FALSE(celix_utils_directoryExists(TEST_ARCHIVE_ROOT));
teardownErrorInjectors();
- celix_ei_expect_lstat((void*) celix_bundleArchive_create, 2, -1);
+ celix_ei_expect_lstat((void*) celix_bundleArchive_create, 3, -1);
EXPECT_EQ(CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,EACCES),
celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 1, SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
EXPECT_EQ(nullptr, archive);
@@ -213,7 +213,7 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveCreateErrorTest) {
archive = nullptr;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
celix_utils_touch(SIMPLE_TEST_BUNDLE1_LOCATION);
- celix_ei_expect_unlink((void*)celix_bundleArchive_create, 2, -1);
+ celix_ei_expect_unlink((void*)celix_bundleArchive_create, 3, -1);
EXPECT_EQ(CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,EACCES),
celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 2, SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
EXPECT_EQ(nullptr, archive);
@@ -226,7 +226,7 @@ TEST_F(CelixBundleArchiveErrorInjectionTestSuite, ArchiveCreateErrorTest) {
archive = nullptr;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
celix_utils_touch(SIMPLE_TEST_BUNDLE1_LOCATION);
- celix_ei_expect_celix_utils_deleteDirectory((void*)celix_bundleArchive_create, 2, CELIX_FILE_IO_EXCEPTION);
+ celix_ei_expect_celix_utils_deleteDirectory((void*)celix_bundleArchive_create, 3, CELIX_FILE_IO_EXCEPTION);
EXPECT_EQ(CELIX_FILE_IO_EXCEPTION,
celix_bundleArchive_create(&fw, TEST_ARCHIVE_ROOT, 1, SIMPLE_TEST_BUNDLE1_LOCATION, &archive));
EXPECT_EQ(nullptr, archive);
diff --git a/libs/framework/src/bundle_archive.c b/libs/framework/src/bundle_archive.c
index 8d55e77e..37f5ed2c 100644
--- a/libs/framework/src/bundle_archive.c
+++ b/libs/framework/src/bundle_archive.c
@@ -97,6 +97,35 @@ static celix_status_t celix_bundleArchive_storeBundleStateProperties(bundle_arch
return CELIX_SUCCESS;
}
+static celix_status_t celix_bundleArchive_removeResourceCache(bundle_archive_t* archive) {
+ celix_status_t status = CELIX_SUCCESS;
+ const char* error = NULL;
+ struct stat st;
+ status = lstat(archive->resourceCacheRoot, &st);
+ if (status == -1 && errno == ENOENT) {
+ return CELIX_SUCCESS;
+ } else if(status == -1 && errno != ENOENT) {
+ status = CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,errno);
+ fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to stat bundle archive directory '%s'", archive->resourceCacheRoot);
+ return status;
+ }
+ // assert(status == 0);
+ // celix_utils_deleteDirectory does not work for dangling symlinks, so handle this case separately
+ if (S_ISLNK(st.st_mode)) {
+ status = unlink(archive->resourceCacheRoot);
+ if (status == -1) {
+ status = CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,errno);
+ error = "Failed to remove existing bundle symlink";
+ }
+ } else {
+ status = celix_utils_deleteDirectory(archive->resourceCacheRoot, &error);
+ }
+ if (status != CELIX_SUCCESS) {
+ fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to remove existing bundle archive revision directory '%s': %s", archive->resourceCacheRoot, error);
+ }
+ return status;
+}
+
static celix_status_t
celix_bundleArchive_extractBundle(bundle_archive_t* archive, const char* bundleUrl) {
celix_status_t status = CELIX_SUCCESS;
@@ -126,30 +155,10 @@ celix_bundleArchive_extractBundle(bundle_archive_t* archive, const char* bundleU
* If dlopen/dlsym is used with newer files, but with the same inode already used in dlopen/dlsym this leads to
* segfaults.
*/
- const char* error = NULL;
- struct stat st;
- status = lstat(archive->resourceCacheRoot, &st);
- if(status == -1 && errno != ENOENT) {
- status = CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,errno);
- fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to stat bundle archive directory '%s'", archive->resourceCacheRoot);
+ status = celix_bundleArchive_removeResourceCache(archive);
+ if (status != CELIX_SUCCESS) {
return status;
}
- if (status == 0) {
- // celix_utils_deleteDirectory does not work for dangling symlinks, so handle this case separately
- if (S_ISLNK(st.st_mode)) {
- status = unlink(archive->resourceCacheRoot);
- if (status == -1) {
- status = CELIX_ERROR_MAKE(CELIX_FACILITY_CERRNO,errno);
- error = "Failed to remove existing bundle symlink";
- }
- } else {
- status = celix_utils_deleteDirectory(archive->resourceCacheRoot, &error);
- }
- if (status != CELIX_SUCCESS) {
- fw_logCode(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, status, "Failed to remove existing bundle archive revision directory '%s': %s", archive->resourceCacheRoot, error);
- return status;
- }
- }
status = celix_framework_utils_extractBundle(archive->fw, bundleUrl, archive->resourceCacheRoot);
if (status != CELIX_SUCCESS) {
fw_log(archive->fw->logger, CELIX_LOG_LEVEL_ERROR, "Failed to initialize archive. Failed to extract bundle zip to revision directory.");
@@ -235,7 +244,6 @@ celix_status_t celix_bundleArchive_create(celix_framework_t* fw, const char *arc
archive->fw = fw;
archive->id = id;
- celixThreadMutex_create(&archive->lock, NULL);
if (isSystemBundle) {
archive->resourceCacheRoot = getcwd(NULL, 0);
@@ -312,7 +320,7 @@ calloc_failed:
return status;
}
-celix_status_t bundleArchive_destroy(bundle_archive_pt archive) {
+void bundleArchive_destroy(bundle_archive_pt archive) {
if (archive != NULL) {
free(archive->location);
free(archive->savedBundleStatePropertiesPath);
@@ -322,10 +330,8 @@ celix_status_t bundleArchive_destroy(bundle_archive_pt archive) {
free(archive->bundleSymbolicName);
free(archive->bundleVersion);
bundleRevision_destroy(archive->revision);
- celixThreadMutex_destroy(&archive->lock);
free(archive);
}
- return CELIX_SUCCESS;
}
celix_status_t bundleArchive_getId(bundle_archive_pt archive, long* id) {
@@ -342,19 +348,15 @@ const char* celix_bundleArchive_getSymbolicName(bundle_archive_pt archive) {
}
celix_status_t bundleArchive_getLocation(bundle_archive_pt archive, const char **location) {
- celixThreadMutex_lock(&archive->lock);
*location = archive->location;
- celixThreadMutex_unlock(&archive->lock);
return CELIX_SUCCESS;
}
char* celix_bundleArchive_getLocation(bundle_archive_pt archive) {
char* result = NULL;
- celixThreadMutex_lock(&archive->lock);
if (archive->location) {
result = celix_utils_strdup(archive->location);
}
- celixThreadMutex_unlock(&archive->lock);
return result;
}
@@ -371,9 +373,7 @@ celix_status_t bundleArchive_getCurrentRevisionNumber(bundle_archive_pt archive,
//LCOV_EXCL_STOP
celix_status_t bundleArchive_getCurrentRevision(bundle_archive_pt archive, bundle_revision_pt* revision) {
- celixThreadMutex_lock(&archive->lock);
*revision = archive->revision;
- celixThreadMutex_unlock(&archive->lock);
return CELIX_SUCCESS;
}
@@ -416,9 +416,7 @@ celix_status_t bundleArchive_getLastModified(bundle_archive_pt archive, time_t*
celix_status_t celix_bundleArchive_getLastModified(bundle_archive_pt archive, struct timespec* lastModified) {
celix_status_t status;
- celixThreadMutex_lock(&archive->lock);
status = celix_utils_getLastModified(archive->resourceCacheRoot, lastModified);
- celixThreadMutex_unlock(&archive->lock);
return status;
}
diff --git a/libs/framework/src/bundle_archive_private.h b/libs/framework/src/bundle_archive_private.h
index b6a837d9..d777ea50 100644
--- a/libs/framework/src/bundle_archive_private.h
+++ b/libs/framework/src/bundle_archive_private.h
@@ -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);
-celix_status_t bundleArchive_destroy(bundle_archive_pt archive);
+void bundleArchive_destroy(bundle_archive_pt archive);
/**
* @brief Returns the bundle id of the bundle archive.
diff --git a/libs/framework/src/celix_bundle_cache.c b/libs/framework/src/celix_bundle_cache.c
index 64fb332f..059c26a4 100644
--- a/libs/framework/src/celix_bundle_cache.c
+++ b/libs/framework/src/celix_bundle_cache.c
@@ -234,8 +234,8 @@ celix_status_t celix_bundleCache_destroyArchive(celix_bundle_cache_t* cache, bun
celix_status_t status = CELIX_SUCCESS;
const char* loc = NULL;
celixThreadMutex_lock(&cache->mutex);
- (void) bundleArchive_getLocation(archive, &loc);
if (permanent) {
+ (void) bundleArchive_getLocation(archive, &loc);
(void) celix_stringHashMap_remove(cache->locationToBundleIdLookupMap, loc);
status = bundleArchive_closeAndDelete(archive);
}
[celix] 01/02: Merge branch 'master' into hotfix/framework-startup-optimization
Posted by pe...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pengzheng pushed a commit to branch hotfix/framework-startup-optimization
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 3eefc0fedc678d2ee546ba2def87146b2da7c35e
Merge: 5f95cb22 072cba2a
Author: PengZheng <ho...@gmail.com>
AuthorDate: Wed Aug 2 12:15:19 2023 +0800
Merge branch 'master' into hotfix/framework-startup-optimization
examples/celix-examples/CMakeLists.txt | 3 -
.../celix-examples/export_import/CMakeLists.txt | 59 ---
.../celix-examples/export_import/include/test.h | 34 --
.../celix-examples/export_import/include/test2.h | 34 --
.../celix-examples/export_import/src/activator.c | 69 ---
examples/celix-examples/export_import/src/test.c | 32 --
libs/framework/CMakeLists.txt | 2 +-
libs/framework/src/bundle.c | 3 -
libs/framework/src/capability.c | 64 +--
libs/framework/src/celix_launcher.c | 2 +-
libs/framework/src/framework.c | 90 +---
libs/framework/src/framework_private.h | 2 -
libs/framework/src/manifest_parser.c | 380 +---------------
libs/framework/src/manifest_parser.h | 2 -
libs/framework/src/module.c | 125 +-----
libs/framework/src/requirement.c | 79 +---
libs/framework/src/resolver.c | 499 ---------------------
libs/framework/src/resolver.h | 45 --
libs/framework/src/wire.c | 53 +--
misc/experimental/CMakeLists.txt | 3 +-
.../{CMakeLists.txt => rust/.gitignore} | 5 +-
misc/experimental/rust/CMakeLists.txt | 45 ++
.../{CMakeLists.txt => rust/Cargo.toml} | 8 +-
misc/experimental/rust/README.md | 28 ++
.../hello_world_activator/Cargo.toml} | 11 +-
.../rust/hello_world_activator/src/lib.rs | 22 +-
26 files changed, 149 insertions(+), 1550 deletions(-)