You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2024/01/22 18:28:45 UTC
(celix) 04/05: Improve references handling in rsa_shm_impl.c
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/674-improve-properties
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 82246c13e2cc6c956aa4414df83b66faf9a3624d
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Mon Jan 22 19:27:55 2024 +0100
Improve references handling in rsa_shm_impl.c
---
.../remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c
index 1745e3f7..6cd251ec 100755
--- a/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c
+++ b/bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c
@@ -288,7 +288,7 @@ celix_status_t rsaShm_exportService(rsa_shm_t *admin, char *serviceId,
return CELIX_ILLEGAL_ARGUMENT;
}
- celix_array_list_t *references = NULL;
+ celix_autoptr(celix_array_list_t) references = NULL;
service_reference_pt reference = NULL;
char filter[32] = {0};// It is longer than the size of "service.id" + serviceId
snprintf(filter, sizeof(filter), "(%s=%s)", (char *) CELIX_FRAMEWORK_SERVICE_ID, serviceId);
@@ -298,10 +298,11 @@ celix_status_t rsaShm_exportService(rsa_shm_t *admin, char *serviceId,
return status;
}
//We get reference with serviceId, so the size of references must be less than or equal to 1.
- reference = celix_arrayList_get(references, 0);
- celix_arrayList_destroy(references);
+ if (celix_arrayList_size(references) == 1) {
+ reference = celix_arrayList_get(references, 0);
+ }
if (reference == NULL) {
- celix_logHelper_error(admin->logHelper, "Expect a reference for service id %s.", serviceId);
+ celix_logHelper_error(admin->logHelper, "Expect a exactly one reference for service id %s. Got %i", serviceId, celix_arrayList_size(references));
return CELIX_ILLEGAL_STATE;
}
celix_auto(celix_service_ref_guard_t) ref = celix_ServiceRefGuard_init(admin->context, reference);