Commit 59b605ec authored by Michael Smith's avatar Michael Smith

Memory leaks. Lots of little ones.

svn path=/trunk/httpp/; revision=3275
parent 0dbd488c
......@@ -48,8 +48,9 @@ void config_initialize(void)
void config_shutdown(void)
{
if (_config_filename) free(_config_filename);
ice_config_dir_t *dirnode, *nextdirnode;
if (_config_filename) free(_config_filename);
if (_configuration.location) free(_configuration.location);
if (_configuration.admin) free(_configuration.admin);
if (_configuration.source_password) free(_configuration.source_password);
......@@ -58,8 +59,16 @@ void config_shutdown(void)
if (_configuration.log_dir) free(_configuration.log_dir);
if (_configuration.access_log) free(_configuration.access_log);
if (_configuration.error_log) free(_configuration.error_log);
memset(&_configuration, 0, sizeof(ice_config_t));
if (_configuration.bind_address) free(_configuration.bind_address);
dirnode = _configuration.dir_list;
while(dirnode) {
nextdirnode = dirnode->next;
free(dirnode->host);
free(dirnode);
dirnode = nextdirnode;
}
memset(&_configuration, 0, sizeof(ice_config_t));
}
int config_parse_file(const char *filename)
......
......@@ -386,12 +386,16 @@ static void *_handle_connection(void *arg)
format_type_t format = format_get_type(contenttype);
if (format < 0) {
WARN1("Content-type \"%s\" not supported, dropping source", contenttype);
connection_close(con);
httpp_destroy(parser);
continue;
} else {
source = source_create(con, parser, httpp_getvar(parser, HTTPP_VAR_URI), format);
}
} else {
WARN0("No content-type header, cannot handle source");
connection_close(con);
httpp_destroy(parser);
continue;
}
......@@ -400,7 +404,6 @@ static void *_handle_connection(void *arg)
sock_set_blocking(con->sock, SOCK_NONBLOCK);
thread_create("Source Thread", source_main, (void *)source, THREAD_DETACHED);
continue;
} else if (parser->req_type == httpp_req_stats) {
printf("DEBUG: stats connection...\n");
......
......@@ -117,6 +117,10 @@ int format_vorbis_get_buffer(format_plugin_t *self, char *data, unsigned long le
state->headbuf[i] = NULL;
}
}
/* Clear old stuff. Rarely but occasionally needed. */
ogg_stream_clear(&state->os);
vorbis_comment_clear(&state->vc);
vorbis_info_clear(&state->vi);
state->serialno = ogg_page_serialno(&state->og);
ogg_stream_init(&state->os, state->serialno);
......
......@@ -268,7 +268,7 @@ char *httpp_getvar(http_parser_t *parser, char *name)
return NULL;
}
void httpp_destroy(http_parser_t *parser)
void httpp_clear(http_parser_t *parser)
{
parser->req_type = httpp_req_none;
if (parser->uri)
......@@ -278,6 +278,12 @@ void httpp_destroy(http_parser_t *parser)
parser->vars = NULL;
}
void httpp_destroy(http_parser_t *parser)
{
httpp_clear(parser);
free(parser);
}
char *_lowercase(char *str)
{
long i;
......
......@@ -40,6 +40,7 @@ int httpp_parse(http_parser_t *parser, char *http_data, unsigned long len);
void httpp_setvar(http_parser_t *parser, char *name, char *value);
char *httpp_getvar(http_parser_t *parser, char *name);
void httpp_destroy(http_parser_t *parser);
void httpp_clear(http_parser_t *parser);
#endif
......
......@@ -814,6 +814,7 @@ static int _free_source_stats(void *key)
stats_source_t *node = (stats_source_t *)key;
avl_tree_free(node->stats_tree, _free_stats);
free(node->source);
free(node);
return 1;
}
......
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