Skip to content

Commit 769e664

Browse files
committed
fix call to reg lookup
1 parent 9185837 commit 769e664

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/viam/sdk/module/service.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,14 @@ struct ModuleService::ServiceImpl : viam::module::v1::ModuleService::Service {
128128
stoppable->stop();
129129
}
130130

131-
manager->remove(cfg.resource_name());
132-
133131
const std::shared_ptr<const ModelRegistration> reg =
134-
Registry::get().lookup_model(cfg.name());
132+
Registry::get().lookup_model(cfg.api(), cfg.model());
135133

136134
// TODO RSDK-11067 new resource gets constructed while old one is still alive.
137135
if (reg) {
138136
try {
139-
const std::shared_ptr<Resource> resource = reg->construct_resource(deps, cfg);
140-
manager->replace_one(cfg.resource_name(), resource);
137+
std::shared_ptr<Resource> resource = reg->construct_resource(deps, cfg);
138+
manager->replace_one(cfg.resource_name(), std::move(resource));
141139
} catch (const std::exception& exc) {
142140
return grpc::Status(::grpc::INTERNAL, exc.what());
143141
}

src/viam/sdk/resource/resource_manager.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void ResourceManager::do_remove(const Name& name) {
108108
ErrorCondition::k_resource_not_found,
109109
"Attempted to remove resource " + name.to_string() + " but it didn't exist!");
110110
}
111+
111112
resources_.erase(short_name);
112113

113114
std::string const shortcut = get_shortcut_name(short_name);
@@ -135,8 +136,8 @@ void ResourceManager::remove(const Name& name) {
135136
do_remove(name);
136137
} catch (std::exception& exc) {
137138
VIAM_SDK_LOG(error) << "unable to remove resource: " << exc.what();
138-
};
139-
};
139+
}
140+
}
140141

141142
void ResourceManager::replace_one(const Name& name, std::shared_ptr<Resource> resource) {
142143
const std::lock_guard<std::mutex> lock(lock_);

0 commit comments

Comments
 (0)