pnoltes commented on code in PR #802:
URL: https://github.com/apache/celix/pull/802#discussion_r2443437668
##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c:
##########
@@ -163,11 +154,40 @@ void rsaShm_destroy(rsa_shm_t *admin) {
assert(celix_longHashMap_size(admin->exportedServices) == 0);
celix_longHashMap_destroy(admin->exportedServices);
celixThreadMutex_destroy(&admin->exportedServicesLock);
+ celix_stringHashMap_destroy(admin->rpcFactories);
+ celix_logHelper_destroy(admin->logHelper);
free(admin);
return;
}
+celix_status_t celix_rsaShm_addRpcFactorySvc(void* handle, void* svc, const
celix_properties_t* props) {
+ rsa_shm_t* admin = (rsa_shm_t*)handle;
+ assert(admin != NULL);
+ assert(svc != NULL);
+ assert(props != NULL);
+ const char* rpcType = celix_properties_get(props, CELIX_RSA_RPC_TYPE_KEY,
NULL);
+ assert(rpcType != NULL);// It must be not NULL, because it is checked in
the filter when adding the dependency.
Review Comment:
I think this should not be an assert, but instead a check with an error log
and early return.
Asserts should be used for internal coding invariants and because services
can be registered outside the scope of the celix project, we cannot ensure that
`rcpType != NULL` is a coding invariant. The assert will also be compiled away
for release, so if a user decide the register a rcp factory svc without a rcp
type, we do not handle that as an error.
##########
bundles/remote_services/remote_service_admin_shm_v2/rsa_shm/src/rsa_shm_impl.c:
##########
@@ -163,11 +154,40 @@ void rsaShm_destroy(rsa_shm_t *admin) {
assert(celix_longHashMap_size(admin->exportedServices) == 0);
celix_longHashMap_destroy(admin->exportedServices);
celixThreadMutex_destroy(&admin->exportedServicesLock);
+ celix_stringHashMap_destroy(admin->rpcFactories);
+ celix_logHelper_destroy(admin->logHelper);
free(admin);
return;
}
+celix_status_t celix_rsaShm_addRpcFactorySvc(void* handle, void* svc, const
celix_properties_t* props) {
+ rsa_shm_t* admin = (rsa_shm_t*)handle;
+ assert(admin != NULL);
+ assert(svc != NULL);
+ assert(props != NULL);
+ const char* rpcType = celix_properties_get(props, CELIX_RSA_RPC_TYPE_KEY,
NULL);
+ assert(rpcType != NULL);// It must be not NULL, because it is checked in
the filter when adding the dependency.
+ celix_status_t status = celix_stringHashMap_put(admin->rpcFactories,
rpcType, svc);
+ if (status != CELIX_SUCCESS) {
+ celix_logHelper_error(admin->logHelper, "Error adding rpc factory for
type %s. %d", rpcType, status);
+ return status;
+ }
+ return CELIX_SUCCESS;
+}
+
+celix_status_t celix_rsaShm_removeRpcFactorySvc(void* handle, void* svc, const
celix_properties_t* props) {
+ rsa_shm_t* admin = (rsa_shm_t*)handle;
+ assert(admin != NULL);
+ assert(svc != NULL);
+ assert(props != NULL);
+ const char* rpcType = celix_properties_get(props, CELIX_RSA_RPC_TYPE_KEY,
NULL);
+ assert(rpcType != NULL);// It must be not NULL, because it is checked in
the filter when adding the dependency.
Review Comment:
Same as line rsa_shm_impl.c:170
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]