On Tue, Oct 24, 2017 at 07:12:15PM +0200, Olivier Houchard wrote: > On Tue, Oct 24, 2017 at 05:37:42PM +0200, Baptiste wrote: > > Hi, > > > > While testing Christopher's DNS "thread-safe" code, I found a bug in > > srv_update_status following a recent update (related to threads too). > > > > The patch is in attachment. > > > Ah you beat me at it ! I ran in the exact same issue. However my patch > also releases tmptrash, so I join it anyway, for great justice. > > Regards, >
Of course I forgot to attach the patch, here it comes. Olivier
>From c6911d42df6f1938beb30f37919327ca4fc31b02 Mon Sep 17 00:00:00 2001 From: Olivier Houchard <[email protected]> Date: Tue, 24 Oct 2017 17:42:47 +0200 Subject: [PATCH 1/2] BUG/MINOR: server: Allocate tmptrash before using it. Don't forget to allocate tmptrash before using it, and free it once we're done. --- src/server.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/server.c b/src/server.c index f57434a29..844d6963b 100644 --- a/src/server.c +++ b/src/server.c @@ -4655,16 +4655,21 @@ void srv_update_status(struct server *s) } if (s->cur_state == SRV_ST_STOPPED) { /* server was already down */ - chunk_printf(tmptrash, - "%sServer %s/%s was DOWN and now enters maintenance%s%s%s", - s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id, - *(s->adm_st_chg_cause) ? " (" : "", s->adm_st_chg_cause, *(s->adm_st_chg_cause) ? ")" : ""); + tmptrash = alloc_trash_chunk(); + if (tmptrash) { + chunk_printf(tmptrash, + "%sServer %s/%s was DOWN and now enters maintenance%s%s%s", + s->flags & SRV_F_BACKUP ? "Backup " : "", s->proxy->id, s->id, + *(s->adm_st_chg_cause) ? " (" : "", s->adm_st_chg_cause, *(s->adm_st_chg_cause) ? ")" : ""); - srv_append_status(tmptrash, s, NULL, -1, (s->next_admin & SRV_ADMF_FMAINT)); + srv_append_status(tmptrash, s, NULL, -1, (s->next_admin & SRV_ADMF_FMAINT)); - if (!(global.mode & MODE_STARTING)) { - Warning("%s.\n", tmptrash->str); - send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str); + if (!(global.mode & MODE_STARTING)) { + Warning("%s.\n", tmptrash->str); + send_log(s->proxy, LOG_NOTICE, "%s.\n", tmptrash->str); + } + free_trash_chunk(tmptrash); + tmptrash = NULL; } } else { /* server was still running */ -- 2.13.5

