diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-05-29 13:22:59 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2014-05-29 17:04:56 +0300 |
commit | 2035536f831b0ce54c28c2a0b405febb113e0fab (patch) | |
tree | 2408086b3eae646006a39e0b78892e2838cb2f35 | |
parent | 35e2816614ab2a1aa585b1ae2547683a69ed9d22 (diff) | |
download | vmod-binlog-2035536f831b0ce54c28c2a0b405febb113e0fab.tar.gz vmod-binlog-2035536f831b0ce54c28c2a0b405febb113e0fab.tar.bz2 |
Further thread-safety fixes.
* NEWS: Version 1.0.90
* configure.ac: Likewise.
* src/binlog.c (binlog_env) <inst_head>: New member.
(binlog_env_init): Initialize inst_head and use it
instead of conf->inst_head.
(env_free): Free inst_head.
* src/pack.c (packdup): New function.
* src/pack.h (packdup): New proto.
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/binlog.c | 10 | ||||
-rw-r--r-- | src/binlogsel.c | 2 | ||||
-rw-r--r-- | src/pack.c | 25 | ||||
-rw-r--r-- | src/pack.h | 1 |
6 files changed, 39 insertions, 7 deletions
@@ -1,12 +1,14 @@ -Vmod-binlog NEWS -- history of user-visible changes. 2013-10-19 +Vmod-binlog NEWS -- history of user-visible changes. 2014-05-29 Copyright (C) 2013 Sergey Poznyakoff See the end of file for copying conditions. Please send Vmod-binlog bug reports to <gray@gnu.org> +Version 1,0.90 (Git) + Version 1.0, 2013-10-19 Initial release. Local variables: diff --git a/configure.ac b/configure.ac index 692b052..3d80940 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ # This file is part of vmod-binlog -# Copyright (C) 2013 Sergey Poznyakoff +# Copyright (C) 2013, 2014 Sergey Poznyakoff # # Vmod-binlog is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # @@ -11,13 +11,13 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. AC_PREREQ(2.69) -AC_INIT([vmod-binlog], 1.0, [gray@gnu.org]) +AC_INIT([vmod-binlog], 1.0.90, [gray@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/binlog.c) AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM diff --git a/src/binlog.c b/src/binlog.c index 4c3f40e..45299f2 100644 --- a/src/binlog.c +++ b/src/binlog.c @@ -1,8 +1,8 @@ /* This file is part of vmod-binlog - Copyright (C) 2013 Sergey Poznyakoff + Copyright (C) 2013, 2014 Sergey Poznyakoff Vmod-binlog is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -69,12 +69,13 @@ struct binlog_config { }; struct binlog_env { enum binlog_state state; /* binlog machine state */ struct binlog_config *conf; time_t timestamp; /* timestamp for the entry being built */ + struct packinst *inst_head; /* compiled format */ struct packinst *inst_cur; /* current instruction */ struct packenv *env; /* pack environment */ }; void binlog_error(const char *fmt, ...) @@ -118,18 +119,20 @@ binlog_env_get(void) } void binlog_env_init(struct binlog_env *ep, struct binlog_config *conf, time_t ts) { if (!ep->env) { - ep->env = packenv_create(packsize(conf->inst_head)); + ep->inst_head = packdup(conf->inst_head); + AN(ep->inst_head); + ep->env = packenv_create(packsize(ep->inst_head)); AN(ep->env); } packenv_init(ep->env); ep->state = state_start; - ep->inst_cur = packinit(conf->inst_head); + ep->inst_cur = packinit(ep->inst_head); ep->timestamp = ts; } void packerror(const char *fmt, ...) { @@ -244,12 +247,13 @@ getindexpat(const char *name) } static void env_free(void *f) { struct binlog_env *ep = f; + packfree(ep->inst_head); packenv_free(ep->env); free(ep); } static void make_key() diff --git a/src/binlogsel.c b/src/binlogsel.c index fad0881..da04636 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -1,8 +1,8 @@ /* This file is part of vmod-binlog - Copyright (C) 2013 Sergey Poznyakoff + Copyright (C) 2013, 2014 Sergey Poznyakoff Vmod-binlog is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. @@ -711,12 +711,37 @@ packcomp(const char *s, char **endp) } if (endp) *endp = (char*) s; return head; } +struct packinst * +packdup(struct packinst *src) +{ + struct packinst *head = NULL, *tail = NULL, *p; + + for (; src; src = src->next) { + p = malloc(sizeof(*p)); + if (!p) { + packfree(head); + errno = ENOMEM; + return NULL; + } + p->next = NULL; + p->spec = src->spec; + p->rep = src->rep; + p->cur = src->cur; + if (tail) + tail->next = p; + else + head = p; + tail = p; + } + return head; +} + void packfree(struct packinst *pi) { while (pi) { struct packinst *next = pi->next; free(pi); @@ -26,12 +26,13 @@ struct packenv { FILE *fp; }; struct packinst; struct packinst *packcomp(const char *s, char **endp); +struct packinst *packdup(struct packinst *s); void packfree(struct packinst *pi); struct packinst *packinit(struct packinst *pi); void packin(struct packinst *pi, struct packenv *env); void packout(struct packinst *pi, struct packenv *env); struct packinst *packinnext(struct packinst *pi, struct packenv *env); |