From fe32c9e28475d43f8da24bf121d5b6011d80919e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20V=C3=A1rady?= Date: Fri, 9 Aug 2024 12:36:27 +0200 Subject: [PATCH] grpc: add global destructor to avoid leaks when the module is not used MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit valgrind reported memory leaks even when no gRPC plugins were used in the configuration. Signed-off-by: László Várady --- modules/grpc/protos/apphook.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/grpc/protos/apphook.cpp b/modules/grpc/protos/apphook.cpp index fdd0bdf2a8..2e7e670635 100644 --- a/modules/grpc/protos/apphook.cpp +++ b/modules/grpc/protos/apphook.cpp @@ -1,4 +1,5 @@ /* + * Copyright (c) 2024 Axoflow * Copyright (c) 2024 László Várady * * This program is free software; you can redistribute it and/or modify it @@ -58,3 +59,9 @@ grpc_register_global_initializers(void) initialized = TRUE; } } + +static void __attribute__((destructor)) +_protobuf_cleanup(void) +{ + google::protobuf::ShutdownProtobufLibrary(); +}