mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-11-03 04:17:17 -05:00
free up any per-client format specific resources, fixes a small memory
leak with mp3 streams svn path=/trunk/icecast/; revision=5873
This commit is contained in:
parent
a255c92b5f
commit
6ba8c0b2cd
@ -63,6 +63,10 @@ void client_destroy(client_t *client)
|
||||
while ((refbuf = refbuf_queue_remove(&client->queue)))
|
||||
refbuf_release(refbuf);
|
||||
|
||||
/* we need to free client specific format data (if any) */
|
||||
if (client->free_client_data)
|
||||
client->free_client_data (client);
|
||||
|
||||
free(client->username);
|
||||
|
||||
free(client);
|
||||
|
@ -42,6 +42,9 @@ typedef struct _client_tag
|
||||
|
||||
/* Format-handler-specific data for this client */
|
||||
void *format_data;
|
||||
|
||||
/* function to call to release format specific resources */
|
||||
void (*free_client_data)(struct _client_tag *client);
|
||||
} client_t;
|
||||
|
||||
client_t *client_create(connection_t *con, http_parser_t *parser);
|
||||
|
@ -59,6 +59,7 @@ static int format_mp3_get_buffer(format_plugin_t *self, char *data,
|
||||
static refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self);
|
||||
static void *format_mp3_create_client_data(format_plugin_t *self,
|
||||
source_t *source, client_t *client);
|
||||
static void free_mp3_client_data (client_t *client);
|
||||
static int format_mp3_write_buf_to_client(format_plugin_t *self,
|
||||
client_t *client, unsigned char *buf, int len);
|
||||
static void format_mp3_send_headers(format_plugin_t *self,
|
||||
@ -394,6 +395,7 @@ static void *format_mp3_create_client_data(format_plugin_t *self,
|
||||
|
||||
data->interval = ICY_METADATA_INTERVAL;
|
||||
data->offset = 0;
|
||||
client->free_client_data = free_mp3_client_data;
|
||||
|
||||
metadata = httpp_getvar(client->parser, "icy-metadata");
|
||||
if(metadata)
|
||||
@ -402,6 +404,14 @@ static void *format_mp3_create_client_data(format_plugin_t *self,
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void free_mp3_client_data (client_t *client)
|
||||
{
|
||||
free (client->format_data);
|
||||
client->format_data = NULL;
|
||||
}
|
||||
|
||||
|
||||
static void format_mp3_send_headers(format_plugin_t *self,
|
||||
source_t *source, client_t *client)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user