Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix redis server example handler memory leak #2370

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions example/redis_c++/redis_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <butil/crc32c.h>
#include <butil/strings/string_split.h>
#include <gflags/gflags.h>
#include <memory>
#include <unordered_map>

#include <butil/time.h>
Expand Down Expand Up @@ -110,9 +111,11 @@ class SetCommandHandler : public brpc::RedisCommandHandler {

int main(int argc, char* argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
RedisServiceImpl* rsimpl = new RedisServiceImpl;
rsimpl->AddCommandHandler("get", new GetCommandHandler(rsimpl));
rsimpl->AddCommandHandler("set", new SetCommandHandler(rsimpl));
RedisServiceImpl *rsimpl = new RedisServiceImpl;
auto get_handler =std::unique_ptr<GetCommandHandler>(new GetCommandHandler(rsimpl));
auto set_handler =std::unique_ptr<SetCommandHandler>( new SetCommandHandler(rsimpl));
rsimpl->AddCommandHandler("get", get_handler.get());
rsimpl->AddCommandHandler("set", set_handler.get());

brpc::Server server;
brpc::ServerOptions server_options;
Expand Down
Loading