Tracking memory leaks is improving
This commit is contained in:
parent
163110c814
commit
9685885afe
4 changed files with 9 additions and 2 deletions
|
@ -306,6 +306,10 @@ int algo_rr_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void algo_rr_free(void* v) {
|
||||||
|
struct rr_ctx* rr = v;
|
||||||
|
free(rr);
|
||||||
|
}
|
||||||
|
|
||||||
void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap) {
|
void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap) {
|
||||||
struct rr_ctx* rr = malloc(sizeof(struct rr_ctx));
|
struct rr_ctx* rr = malloc(sizeof(struct rr_ctx));
|
||||||
|
@ -321,6 +325,7 @@ void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct alg
|
||||||
rr->recv_id = 0;
|
rr->recv_id = 0;
|
||||||
rr->recv_id_late = 0;
|
rr->recv_id_late = 0;
|
||||||
app_ctx->misc = rr;
|
app_ctx->misc = rr;
|
||||||
|
app_ctx->free_misc = algo_rr_free;
|
||||||
|
|
||||||
init_timer(ctx);
|
init_timer(ctx);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,10 @@ void free_naive(void* app_ctx) {
|
||||||
struct algo_ctx* ctx = (struct algo_ctx*) app_ctx;
|
struct algo_ctx* ctx = (struct algo_ctx*) app_ctx;
|
||||||
ctx->ref_count--;
|
ctx->ref_count--;
|
||||||
if (ctx->ref_count > 0) return;
|
if (ctx->ref_count > 0) return;
|
||||||
|
if (ctx->free_misc) ctx->free_misc(ctx->misc);
|
||||||
g_queue_free(ctx->free_buffer);
|
g_queue_free(ctx->free_buffer);
|
||||||
g_queue_free(ctx->read_waiting);
|
g_queue_free(ctx->read_waiting);
|
||||||
|
g_hash_table_destroy (ctx->application_waiting);
|
||||||
g_hash_table_destroy (ctx->used_buffer);
|
g_hash_table_destroy (ctx->used_buffer);
|
||||||
g_hash_table_destroy (ctx->write_waiting);
|
g_hash_table_destroy (ctx->write_waiting);
|
||||||
free(ctx);
|
free(ctx);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
void free_udp_t(void* v) {
|
void free_udp_t(void* v) {
|
||||||
struct udp_target* udp_t = v;
|
struct udp_target* udp_t = v;
|
||||||
udp_t->ref_count--;
|
udp_t->ref_count--;
|
||||||
if (udp_t <= 0) {
|
if (udp_t->ref_count <= 0) {
|
||||||
free(udp_t);
|
free(udp_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) {
|
||||||
.name = "tcp-listen",
|
.name = "tcp-listen",
|
||||||
.flags = EPOLLIN,
|
.flags = EPOLLIN,
|
||||||
.app_ctx = ctx,
|
.app_ctx = ctx,
|
||||||
.free_app_ctx = free_nothing,
|
.free_app_ctx = free_naive,
|
||||||
.cb = main_on_tcp_co,
|
.cb = main_on_tcp_co,
|
||||||
.err_cb = NULL
|
.err_cb = NULL
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue