Commit 6ba8c0b2 authored by Karl Heyes's avatar Karl Heyes

free up any per-client format specific resources, fixes a small memory

leak with mp3 streams

svn path=/trunk/icecast/; revision=5873
parent a255c92b
......@@ -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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment