Skip to content

Commit

Permalink
Merge pull request #1505 from furiel/json-leak
Browse files Browse the repository at this point in the history
bugfixes: missing counter in sql-dest, json-parser+scratchbuffer, stats cluster memleak
  • Loading branch information
kvch committed May 31, 2017
2 parents 5f2f4ed + 54541e1 commit 6beee4f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/stats/stats-cluster.c
Expand Up @@ -270,9 +270,17 @@ stats_counter_group_free(StatsCounterGroup *self)
self->free_fn(self);
}


static void
stats_cluster_free_counter_name(StatsCluster *self, gint type, StatsCounterItem *item, gpointer user_data)
{
g_free(item->name);
}

void
stats_cluster_free(StatsCluster *self)
{
stats_cluster_foreach_counter(self, stats_cluster_free_counter_name, NULL);
_stats_cluster_key_cloned_free(&self->key);
g_free(self->query_key);
stats_counter_group_free(&self->counter_group);
Expand Down
2 changes: 2 additions & 0 deletions modules/afsql/afsql.c
Expand Up @@ -1195,6 +1195,7 @@ afsql_dd_init(LogPipe *s)
afsql_dd_format_stats_instance(self) );
stats_register_counter(0, &sc_key, SC_TYPE_QUEUED, &self->queued_messages);
stats_register_counter(0, &sc_key, SC_TYPE_DROPPED, &self->dropped_messages);
stats_register_counter(0, &sc_key, SC_TYPE_MEMORY_USAGE, &self->memory_usage);
}
stats_unlock();

Expand Down Expand Up @@ -1326,6 +1327,7 @@ afsql_dd_init(LogPipe *s)
afsql_dd_format_stats_instance(self) );
stats_unregister_counter(&sc_key, SC_TYPE_QUEUED, &self->queued_messages);
stats_unregister_counter(&sc_key, SC_TYPE_DROPPED, &self->dropped_messages);
stats_unregister_counter(&sc_key, SC_TYPE_MEMORY_USAGE, &self->memory_usage);
}
stats_unlock();

Expand Down
4 changes: 3 additions & 1 deletion modules/json/json-parser.c
Expand Up @@ -84,7 +84,8 @@ json_parser_process_single(struct json_object *jso,
if (!jso)
return;

key = scratch_buffers2_alloc();
ScratchBuffersMarker marker;
key = scratch_buffers2_alloc_and_mark(&marker);
value = scratch_buffers2_alloc();

switch (json_object_get_type(jso))
Expand Down Expand Up @@ -162,6 +163,7 @@ json_parser_process_single(struct json_object *jso,
value->len);
}

scratch_buffers2_reclaim_marked(marker);
}

static void
Expand Down

0 comments on commit 6beee4f

Please sign in to comment.