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 2021/05/07 14:47:59 UTC
[celix] 02/02: Fixes iter loops with erase
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/cxx_rsa_update
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 8fdcfc7381329dc9734d2d208268e32655cbf1c1
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Fri May 7 16:47:41 2021 +0200
Fixes iter loops with erase
---
bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc b/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
index 4ed0e2f..9a1e09e 100644
--- a/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
+++ b/bundles/cxx_remote_services/admin/src/RemoteServiceAdmin.cc
@@ -180,11 +180,13 @@ void celix::rsa::RemoteServiceAdmin::removeService(const std::shared_ptr<void>&
}
void celix::rsa::RemoteServiceAdmin::createImportServices() {
- for (auto it = _toBeImportedServices.begin(); it != _toBeImportedServices.end(); ++it) {
+ auto it = _toBeImportedServices.begin();
+ while (it != _toBeImportedServices.end()) {
auto interface = (*it)->getInterface();
auto existingFactory = _importServiceFactories.find(interface);
if (existingFactory == end(_importServiceFactories)) {
L_DEBUG("Adding endpoint to be imported but no factory available yet, delaying import");
+ it++;
continue;
}
auto endpointId = (*it)->getId();
@@ -195,18 +197,20 @@ void celix::rsa::RemoteServiceAdmin::createImportServices() {
}
void celix::rsa::RemoteServiceAdmin::createExportServices() {
-
- for (auto it = _toBeExportedServices.begin(); it != _toBeExportedServices.end(); ++it) {
+ auto it = _toBeExportedServices.begin();
+ while (it != _toBeExportedServices.end()) {
const auto& svcProperties = **it;
auto serviceName = svcProperties.get(celix::SERVICE_NAME, "");
auto svcId = svcProperties.getAsLong(celix::SERVICE_ID, -1);
if (serviceName.empty()) {
L_WARN("Adding service to be exported but missing objectclass for svc id %li", svcId);
+ it++;
continue;
}
auto factory = _exportServiceFactories.find(serviceName);
if (factory == end(_exportServiceFactories)) {
L_DEBUG("Adding service to be exported but no factory available yet, delaying creation");
+ it++;
continue;
}
_exportedServices.emplace(svcId, factory->second->exportService(svcProperties));