aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2014-05-29 13:22:59 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2014-05-29 17:04:56 +0300
commit2035536f831b0ce54c28c2a0b405febb113e0fab (patch)
tree2408086b3eae646006a39e0b78892e2838cb2f35
parent35e2816614ab2a1aa585b1ae2547683a69ed9d22 (diff)
downloadvmod-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--NEWS4
-rw-r--r--configure.ac4
-rw-r--r--src/binlog.c10
-rw-r--r--src/binlogsel.c2
-rw-r--r--src/pack.c25
-rw-r--r--src/pack.h1
6 files changed, 39 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 4546558..e8b0f8b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,11 @@
1Vmod-binlog NEWS -- history of user-visible changes. 2013-10-19 1Vmod-binlog NEWS -- history of user-visible changes. 2014-05-29
2Copyright (C) 2013 Sergey Poznyakoff 2Copyright (C) 2013 Sergey Poznyakoff
3See the end of file for copying conditions. 3See the end of file for copying conditions.
4 4
5Please send Vmod-binlog bug reports to <gray@gnu.org> 5Please send Vmod-binlog bug reports to <gray@gnu.org>
6 6
7Version 1,0.90 (Git)
8
7Version 1.0, 2013-10-19 9Version 1.0, 2013-10-19
8 10
9Initial release. 11Initial release.
diff --git a/configure.ac b/configure.ac
index 692b052..3d80940 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
1# This file is part of vmod-binlog 1# This file is part of vmod-binlog
2# Copyright (C) 2013 Sergey Poznyakoff 2# Copyright (C) 2013, 2014 Sergey Poznyakoff
3# 3#
4# Vmod-binlog is free software; you can redistribute it and/or modify 4# Vmod-binlog is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by 5# it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
14# You should have received a copy of the GNU General Public License 14# You should have received a copy of the GNU General Public License
15# along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>. 15# along with vmod-binlog. If not, see <http://www.gnu.org/licenses/>.
16AC_PREREQ(2.69) 16AC_PREREQ(2.69)
17AC_INIT([vmod-binlog], 1.0, [gray@gnu.org]) 17AC_INIT([vmod-binlog], 1.0.90, [gray@gnu.org])
18AC_CONFIG_AUX_DIR([build-aux]) 18AC_CONFIG_AUX_DIR([build-aux])
19AC_CONFIG_MACRO_DIR([m4]) 19AC_CONFIG_MACRO_DIR([m4])
20AC_CONFIG_SRCDIR(src/binlog.c) 20AC_CONFIG_SRCDIR(src/binlog.c)
diff --git a/src/binlog.c b/src/binlog.c
index 4c3f40e..45299f2 100644
--- a/src/binlog.c
+++ b/src/binlog.c
@@ -1,5 +1,5 @@
1/* This file is part of vmod-binlog 1/* This file is part of vmod-binlog
2 Copyright (C) 2013 Sergey Poznyakoff 2 Copyright (C) 2013, 2014 Sergey Poznyakoff
3 3
4 Vmod-binlog is free software; you can redistribute it and/or modify 4 Vmod-binlog is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
@@ -72,6 +72,7 @@ struct binlog_env {
72 enum binlog_state state; /* binlog machine state */ 72 enum binlog_state state; /* binlog machine state */
73 struct binlog_config *conf; 73 struct binlog_config *conf;
74 time_t timestamp; /* timestamp for the entry being built */ 74 time_t timestamp; /* timestamp for the entry being built */
75 struct packinst *inst_head; /* compiled format */
75 struct packinst *inst_cur; /* current instruction */ 76 struct packinst *inst_cur; /* current instruction */
76 struct packenv *env; /* pack environment */ 77 struct packenv *env; /* pack environment */
77}; 78};
@@ -121,12 +122,14 @@ void
121binlog_env_init(struct binlog_env *ep, struct binlog_config *conf, time_t ts) 122binlog_env_init(struct binlog_env *ep, struct binlog_config *conf, time_t ts)
122{ 123{
123 if (!ep->env) { 124 if (!ep->env) {
124 ep->env = packenv_create(packsize(conf->inst_head)); 125 ep->inst_head = packdup(conf->inst_head);
126 AN(ep->inst_head);
127 ep->env = packenv_create(packsize(ep->inst_head));
125 AN(ep->env); 128 AN(ep->env);
126 } 129 }
127 packenv_init(ep->env); 130 packenv_init(ep->env);
128 ep->state = state_start; 131 ep->state = state_start;
129 ep->inst_cur = packinit(conf->inst_head); 132 ep->inst_cur = packinit(ep->inst_head);
130 ep->timestamp = ts; 133 ep->timestamp = ts;
131} 134}
132 135
@@ -247,6 +250,7 @@ static void
247env_free(void *f) 250env_free(void *f)
248{ 251{
249 struct binlog_env *ep = f; 252 struct binlog_env *ep = f;
253 packfree(ep->inst_head);
250 packenv_free(ep->env); 254 packenv_free(ep->env);
251 free(ep); 255 free(ep);
252} 256}
diff --git a/src/binlogsel.c b/src/binlogsel.c
index fad0881..da04636 100644
--- a/src/binlogsel.c
+++ b/src/binlogsel.c
@@ -1,5 +1,5 @@
1/* This file is part of vmod-binlog 1/* This file is part of vmod-binlog
2 Copyright (C) 2013 Sergey Poznyakoff 2 Copyright (C) 2013, 2014 Sergey Poznyakoff
3 3
4 Vmod-binlog is free software; you can redistribute it and/or modify 4 Vmod-binlog is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
diff --git a/src/pack.c b/src/pack.c
index 9e9e0ed..6c21c89 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -714,6 +714,31 @@ packcomp(const char *s, char **endp)
714 return head; 714 return head;
715} 715}
716 716
717struct packinst *
718packdup(struct packinst *src)
719{
720 struct packinst *head = NULL, *tail = NULL, *p;
721
722 for (; src; src = src->next) {
723 p = malloc(sizeof(*p));
724 if (!p) {
725 packfree(head);
726 errno = ENOMEM;
727 return NULL;
728 }
729 p->next = NULL;
730 p->spec = src->spec;
731 p->rep = src->rep;
732 p->cur = src->cur;
733 if (tail)
734 tail->next = p;
735 else
736 head = p;
737 tail = p;
738 }
739 return head;
740}
741
717void 742void
718packfree(struct packinst *pi) 743packfree(struct packinst *pi)
719{ 744{
diff --git a/src/pack.h b/src/pack.h
index c134878..d32a8fa 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -29,6 +29,7 @@ struct packenv {
29struct packinst; 29struct packinst;
30 30
31struct packinst *packcomp(const char *s, char **endp); 31struct packinst *packcomp(const char *s, char **endp);
32struct packinst *packdup(struct packinst *s);
32void packfree(struct packinst *pi); 33void packfree(struct packinst *pi);
33struct packinst *packinit(struct packinst *pi); 34struct packinst *packinit(struct packinst *pi);
34void packin(struct packinst *pi, struct packenv *env); 35void packin(struct packinst *pi, struct packenv *env);

Return to:

Send suggestions and report system problems to the System administrator.