Skip to content

Commit

Permalink
server: fix memory leak during reconfiguration (#2843)
Browse files Browse the repository at this point in the history
Free previously initialized authentication modules in
'server_reconfigure()' and so avoid memory leak during
the volume file change.

Signed-off-by: Dmitry Antipov <dantipov@cloudlinux.com>
Updates: #1000
  • Loading branch information
dmantipov committed Oct 22, 2021
1 parent ab0046a commit 2e825b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 6 additions & 0 deletions xlators/protocol/server/src/authenticate.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,14 @@ static int
fini(dict_t *this, char *key, data_t *value, void *data)
{
auth_handle_t *handle = data_to_ptr(value);

if (handle) {
dlclose(handle->handle);

if (handle->vol_opt) {
list_del_init(&handle->vol_opt->list);
GF_FREE(handle->vol_opt);
}
}
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion xlators/protocol/server/src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,9 @@ server_reconfigure(xlator_t *this, dict_t *options)
this->ctx->statedump_path = gf_strdup(statedump_path);

do_auth:
if (!conf->auth_modules)
if (conf->auth_modules)
gf_auth_fini(conf->auth_modules);
else
conf->auth_modules = dict_new();

dict_foreach(options, get_auth_types, conf->auth_modules);
Expand Down

0 comments on commit 2e825b3

Please sign in to comment.