[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Small memory leak in tcp shell server.

From: Tom M.
Subject: Re: [fluid-dev] Small memory leak in tcp shell server.
Date: Wed, 11 Oct 2017 10:56:38 +0200

handler = server->newclient(server->data, addr);

newclient is a caller provided callback function to return any instance of fluid_cmd_handler_t. This instance is only assigned to any created fluid_client, it's not owned by it. Thus the caller would be responsible for delete_fluid_cmd_handler().

However I refactored that part on master: https://github.com/FluidSynth/fluidsynth/commit/cb036d20233982567c3c6100999c3150f501b8f1

The fluid_cmd_handler_t is now uniquely created for every fluid_client, making it possible for fluid_client to own that instance. Thanks for that hint, just fixed in https://github.com/FluidSynth/fluidsynth/commit/820448bafe190b4f5dbbfe71a1102752defae62d


2017-10-10 23:55 GMT+02:00 Ceresa Jean-Jacques <address@hidden>:



There is a small memory leak in tcp command shell server in v 1.1.6 and may be still present in v1.1.7 ?.


The memory leak is a lack of deletion of the command handler (fluid_cmd_handler_t).

The command handler is created at client connection time, just before client creation task (in fluid_cmd.c-fluid_server_handle_connection()) here:

fluid_server_handle_connection(fluid_server_t* server, fluid_socket_t client_socket, char* addr)


fluid_cmd_handler_t* handler;

handler = server->newclient(server->data, addr);




However, this command handler  seems  never deleted (delete_fluid_cmd_handler()) (imho).


In this case this handler should be deleted on the following events:

- (1) When the remote client quit, or when the server force client closing (i.e at client task destruction time).
- (2) On error when calling 'client creation task' function.
So, the fusing fix could be to call delete_fluid_cmd_handler() only one time (i.e when the client task is deleted) ((in fluid_cmd.c-delete_fluid_client()), here:
void delete_fluid_client(fluid_client_t* client)





This is a fresh proposition and haven't not yet tested.





fluid-dev mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]