From abac35c6eba4273fc54e85e82af669ac2e793671 Mon Sep 17 00:00:00 2001 From: David Nadle Date: Fri, 4 Oct 2013 03:07:47 -0400 Subject: [PATCH 1/2] Handle autosave SIGCHLD with no stored pid --- v/save.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/v/save.c b/v/save.c index a2245ea50..f32385a1a 100644 --- a/v/save.c +++ b/v/save.c @@ -29,14 +29,13 @@ _save_time_cb(uv_timer_t* tim_u, c3_i sas_i) } if ( u2A->ent_w > sav_u->ent_w ) { - c3_w pid_w; - // uL(fprintf(uH, "autosaving... ent_w %d\n", u2A->ent_w)); u2_cm_purge(); // u2_ve_grab(0); #ifdef FORKPT + c3_w pid_w; if ( 0 == (pid_w = fork()) ) { u2_loom_save(u2A->ent_w); exit(0); @@ -63,10 +62,18 @@ u2_save_ef_chld(void) c3_i loc_i; c3_w pid_w; - c3_assert(0 != sav_u->pid_w); + /* modified for cases with no pid_w + */ uL(fprintf(uH, "checkpoint: complete %d\n", sav_u->pid_w)); pid_w = wait(&loc_i); - c3_assert(pid_w == sav_u->pid_w); + if (0 != sav_u->pid_w) + { + c3_assert(pid_w == sav_u->pid_w); + } + else + { + c3_assert(pid_w > 0); + } sav_u->pid_w = 0; } From 323d0107244c30a0ac77b0160bf1b58dac47344d Mon Sep 17 00:00:00 2001 From: Curtis Yarvin Date: Fri, 4 Oct 2013 22:33:26 +0000 Subject: [PATCH 2/2] Fix a memory leak per packet. --- v/ames.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/v/ames.c b/v/ames.c index 6c37f0f61..6c144b0ab 100644 --- a/v/ames.c +++ b/v/ames.c @@ -28,7 +28,19 @@ static uv_buf_t _ames_alloc(uv_handle_t* had_u, size_t len_i) { - return uv_buf_init(malloc(len_i), len_i); + void* ptr_v = malloc(len_i); + +// uL(fprintf(uH, "grab %p\n", ptr_v)); + return uv_buf_init(ptr_v, len_i); +} + +/* _ames_free(): contrasting free. +*/ +static void +_ames_free(void* ptr_v) +{ +// uL(fprintf(uH, "free %p\n", ptr_v)); + free(ptr_v); } /* _ames_czar(): quasi-static route to emperor. @@ -235,10 +247,10 @@ _ames_recv_cb(uv_udp_t* wax_u, struct sockaddr* adr_u, unsigned flg_i) { - // fprintf(stderr, "ames: rx\r\n"); + // uL(fprintf(uH, "ames: rx %p\r\n", buf_u.base)); if ( 0 == nrd_i ) { - free(buf_u.base); + _ames_free(buf_u.base); } else { u2_lo_open(); @@ -254,6 +266,7 @@ _ames_recv_cb(uv_udp_t* wax_u, u2nt(c3__gold, c3__ames, u2_nul), u2nt(c3__hear, u2nt(c3__if, por_s, u2_ci_words(1, &pip_w)), msg)); } + _ames_free(buf_u.base); u2_lo_shut(u2_yes); } }