You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/07/02 05:01:02 UTC
[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #703: Use unique ptr
PragmaTwice commented on code in PR #703:
URL: https://github.com/apache/incubator-kvrocks/pull/703#discussion_r912320792
##########
src/server.cc:
##########
@@ -54,19 +54,18 @@ Server::Server(Engine::Storage *storage, Config *config) :
cluster_ = std::unique_ptr<Cluster>(new Cluster(this, config_->binds, config_->port));
for (int i = 0; i < config->workers; i++) {
- auto worker = new Worker(this, config);
+ auto worker = std::unique_ptr<Worker>(new Worker(this, config));
// multiple workers can't listen to the same unix socket, so
// listen unix socket only from a single worker - the first one
if (!config->unixsocket.empty() && i == 0) {
Status s = worker->ListenUnixSocket(config->unixsocket, config->unixsocketperm, config->backlog);
if (!s.IsOK()) {
LOG(ERROR) << "[server] Failed to listen on unix socket: "<< config->unixsocket
<< ", encounter error: " << s.Msg();
- delete worker;
exit(1);
}
}
- worker_threads_.emplace_back(new WorkerThread(worker));
+ worker_threads_.emplace_back(std::unique_ptr<WorkerThread> (new WorkerThread(std::move(worker))));
Review Comment:
```suggestion
worker_threads_.emplace_back(Util::MakeUnique<WorkerThread>(std::move(worker)));
```
##########
src/server.cc:
##########
@@ -54,19 +54,18 @@ Server::Server(Engine::Storage *storage, Config *config) :
cluster_ = std::unique_ptr<Cluster>(new Cluster(this, config_->binds, config_->port));
for (int i = 0; i < config->workers; i++) {
- auto worker = new Worker(this, config);
+ auto worker = std::unique_ptr<Worker>(new Worker(this, config));
Review Comment:
```suggestion
auto worker = Util::MakeUnique<Worker>(this, config);
```
--
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: issues-unsubscribe@kvrocks.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org