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 /src/binlog.c | |
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.
Diffstat (limited to 'src/binlog.c')
-rw-r--r-- | src/binlog.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 | |||
121 | binlog_env_init(struct binlog_env *ep, struct binlog_config *conf, time_t ts) | 122 | binlog_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 | |||
247 | env_free(void *f) | 250 | env_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 | } |