summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-15 12:20:42 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-01-15 12:20:42 (GMT)
commit746f6355a4595cc4bbcffc89a3e42a082d757759 (patch) (side-by-side diff)
tree8530127396a94f3d70bdef83a0aaffddb1b80469
parent5fc59f5271d5ca06374782848bcd53adecfffcf1 (diff)
downloadvmod-variable-746f6355a4595cc4bbcffc89a3e42a082d757759.tar.gz
vmod-variable-746f6355a4595cc4bbcffc89a3e42a082d757759.tar.bz2
Revert "Store per-session symtabs in private storage."
This reverts commit 5fc59f5271d5ca06374782848bcd53adecfffcf1, which in fact pertains to 4.1 branch.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS11
-rw-r--r--configure.ac4
-rw-r--r--src/variable.c89
-rw-r--r--src/variable.vcc32
4 files changed, 68 insertions, 68 deletions
diff --git a/NEWS b/NEWS
index c0d662a..1c3e867 100644
--- a/NEWS
+++ b/NEWS
@@ -1,15 +1,10 @@
-vmod-variable -- history of user-visible changes. 2016-01-15
-Copyright (C) 2015-2016 Sergey Poznyakoff
+vmod-variable -- history of user-visible changes. 2015-02-16
+Copyright (C) 2015 Sergey Poznyakoff
See the end of file for copying conditions.
Please send vmod-variable bug reports to <gray@gnu.org>
-Version 1.0.90, (Git)
-
-Fix coredumps.
-
-
Version 1.0, 2015-02-16
Initial release
@@ -17,7 +12,7 @@ Initial release
=========================================================================
Copyright information:
-Copyright (C) 2015-2016 Sergey Poznyakoff
+Copyright (C) 2015 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
diff --git a/configure.ac b/configure.ac
index f2adcb9..9a69658 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# This file is part of vmod-variable -*- autoconf -*-
-# Copyright (C) 2015-2016 Sergey Poznyakoff
+# Copyright (C) 2015 Sergey Poznyakoff
#
# Vmod-variable is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with vmod-variable. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
-AC_INIT([vmod-variable], [1.0.90], [gray@gnu.org])
+AC_INIT([vmod-variable], [1.0], [gray@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/variable.vcc)
diff --git a/src/variable.c b/src/variable.c
index acdc6f6..bd79c3b 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -310,6 +310,10 @@ symtab_free(struct symtab *st)
}
+static struct symtab **symtabv;
+static size_t symtabc;
+static pthread_mutex_t symtab_mtx = PTHREAD_MUTEX_INITIALIZER;
+
static struct symtab *global_symtab;
static pthread_mutex_t global_mtx = PTHREAD_MUTEX_INITIALIZER;
@@ -377,20 +381,26 @@ vmod_global_unset(VARIABLE_CTX ctx, VCL_STRING name)
AZ(pthread_mutex_unlock(&global_mtx));
}
-static void
-priv_symtab_free(void *p)
-{
- symtab_free(p);
-}
-
static struct symtab *
-get_symtab(struct vmod_priv *priv)
-{
- if (!priv->priv) {
- priv->priv = symtab_create();
- priv->free = priv_symtab_free;
+get_symtab(VARIABLE_CTX ctx)
+{
+ struct symtab *st;
+ int fd = ctx->req->sp->fd;
+ AZ(pthread_mutex_lock(&symtab_mtx));
+ if (symtabc <= fd) {
+ size_t n = fd + 1;
+ symtabv = realloc(symtabv, n * sizeof(symtabv[0]));
+ while (symtabc < n)
+ symtabv[symtabc++] = NULL;
}
- return priv->priv;
+ if (!symtabv[fd])
+ symtabv[fd] = symtab_create();
+ st = symtabv[fd];
+ if (st->vxid != ctx->req->sp->vxid)
+ symtab_clear(st);
+ st->vxid = ctx->req->sp->vxid;
+ AZ(pthread_mutex_unlock(&symtab_mtx));
+ return st;
}
#define getvar(vt, name) symtab_lookup_or_install(vt, name, NULL)
@@ -412,25 +422,24 @@ defvar(struct symtab *vt, const char *name, enum variable_type t,
}
VCL_VOID
-vmod_clear(VARIABLE_CTX ctx, struct vmod_priv *priv)
+vmod_clear(VARIABLE_CTX ctx)
{
- symtab_clear(get_symtab(priv));
+ symtab_clear(get_symtab(ctx));
}
VCL_STRING
-vmod_get_string(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
+vmod_get_string(VARIABLE_CTX ctx, VCL_STRING name)
{
- struct variable *var = getvar(get_symtab(priv), name);
+ struct variable *var = getvar(get_symtab(ctx), name);
if (var && var->type == variable_string)
return var->v.s;
return NULL;
}
VCL_VOID
-vmod_set_string(VARIABLE_CTX ctx, struct vmod_priv *priv,
- VCL_STRING name, VCL_STRING value)
+vmod_set_string(VARIABLE_CTX ctx, VCL_STRING name, VCL_STRING value)
{
- struct symtab *vt = get_symtab(priv);
+ struct symtab *vt = get_symtab(ctx);
struct variable *var = defvar(vt, name, variable_unset, NULL);
var->type = variable_string;
var->v.s = strdup(value ? value : "");
@@ -438,25 +447,23 @@ vmod_set_string(VARIABLE_CTX ctx, struct vmod_priv *priv,
}
VCL_STRING
-vmod_get(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
+vmod_get(VARIABLE_CTX ctx, VCL_STRING name)
{
- return vmod_get_string(ctx, priv, name);
+ return vmod_get_string(ctx, name);
}
VCL_VOID
-vmod_set(VARIABLE_CTX ctx, struct vmod_priv *priv,
- VCL_STRING name, VCL_STRING value)
+vmod_set(VARIABLE_CTX ctx, VCL_STRING name, VCL_STRING value)
{
- vmod_set_string(ctx, priv, name, value);
+ vmod_set_string(ctx, name, value);
}
#define __cat__(a,b) a ## b
#define DEFGET(r_type, vcl_type, memb) \
vcl_type \
-__cat__(vmod_get_,r_type)(VARIABLE_CTX ctx, struct vmod_priv *priv, \
- VCL_STRING name) \
+__cat__(vmod_get_,r_type)(VARIABLE_CTX ctx, VCL_STRING name) \
{ \
- struct variable *var = getvar(get_symtab(priv), name); \
+ struct variable *var = getvar(get_symtab(ctx), name); \
if (var && var->type == __cat__(variable_,r_type)) \
return var->v.memb; \
return 0; \
@@ -464,11 +471,10 @@ __cat__(vmod_get_,r_type)(VARIABLE_CTX ctx, struct vmod_priv *priv, \
#define DEFSET(r_type, vcl_type, memb) \
VCL_VOID \
-__cat__(vmod_set_,r_type)(VARIABLE_CTX ctx, struct vmod_priv *priv, \
- VCL_STRING name, \
+__cat__(vmod_set_,r_type)(VARIABLE_CTX ctx, VCL_STRING name, \
vcl_type value) \
{ \
- struct symtab *vt = get_symtab(priv); \
+ struct symtab *vt = get_symtab(ctx); \
struct variable *var = defvar(vt, name, variable_unset, NULL); \
var->type = __cat__(variable_,r_type); \
var->v.memb = value; \
@@ -483,22 +489,22 @@ DEF(real, VCL_REAL, r)
DEF(duration, VCL_DURATION, d)
VCL_BOOL
-vmod_defined(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
+vmod_defined(VARIABLE_CTX ctx, VCL_STRING name)
{
- return !!getvar(get_symtab(priv), name);
+ return !!getvar(get_symtab(ctx), name);
}
VCL_STRING
-vmod_type_of(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
+vmod_type_of(VARIABLE_CTX ctx, VCL_STRING name)
{
- struct variable *var = getvar(get_symtab(priv), name);
+ struct variable *var = getvar(get_symtab(ctx), name);
return typestr[var ? var->type : variable_unset];
}
VCL_VOID
-vmod_unset(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
+vmod_unset(VARIABLE_CTX ctx, VCL_STRING name)
{
- symtab_remove(get_symtab(priv), name);
+ symtab_remove(get_symtab(ctx), name);
}
static void
@@ -710,10 +716,10 @@ setval(union value *val, const char *s, enum variable_type type, char **err)
}
VCL_VOID
-vmod_regset(VARIABLE_CTX ctx, struct vmod_priv *priv,
- VCL_STRING vars, VCL_STRING rxs, VCL_STRING input)
+vmod_regset(VARIABLE_CTX ctx, VCL_STRING vars, VCL_STRING rxs,
+ VCL_STRING input)
{
- struct symtab *vt = get_symtab(priv);
+ struct symtab *vt = get_symtab(ctx);
struct vardef *head = NULL, *tail = NULL, *def;
size_t count = 0;
size_t n;
@@ -887,10 +893,9 @@ define_param(struct symtab *vt, struct vardef *def,
}
VCL_VOID
-vmod_queryset(VARIABLE_CTX ctx, struct vmod_priv *priv,
- VCL_STRING vars, VCL_STRING query)
+vmod_queryset(VARIABLE_CTX ctx, VCL_STRING vars, VCL_STRING query)
{
- struct symtab *vt = get_symtab(priv);
+ struct symtab *vt = get_symtab(ctx);
struct vardef *head = NULL, *tail = NULL, *def;
size_t count = 0;
size_t n;
diff --git a/src/variable.vcc b/src/variable.vcc
index ad80fe0..3745a8d 100644
--- a/src/variable.vcc
+++ b/src/variable.vcc
@@ -22,26 +22,26 @@ Due to limitations of the vmodtool.py utility, this document contains
only prototypes of the functions provided by the **vmod-variable** module.
For a detailed documentation, please see vmod-variable(3) manual page.
-$Function VOID set(PRIV_VCL, STRING, STRING)
-$Function STRING get(PRIV_VCL, STRING)
+$Function VOID set(STRING, STRING)
+$Function STRING get(STRING)
$Function VOID global_set(STRING, STRING)
$Function STRING global_get(STRING)
-$Function VOID set_int(PRIV_VCL, STRING, INT)
-$Function INT get_int(PRIV_VCL, STRING)
-$Function VOID set_string(PRIV_VCL, STRING, STRING)
-$Function STRING get_string(PRIV_VCL, STRING)
-$Function VOID set_real(PRIV_VCL, STRING, REAL)
-$Function REAL get_real(PRIV_VCL, STRING)
-$Function VOID set_duration(PRIV_VCL, STRING, DURATION)
-$Function DURATION get_duration(PRIV_VCL, STRING)
-$Function VOID clear(PRIV_VCL)
+$Function VOID set_int(STRING, INT)
+$Function INT get_int(STRING)
+$Function VOID set_string(STRING, STRING)
+$Function STRING get_string(STRING)
+$Function VOID set_real(STRING, REAL)
+$Function REAL get_real(STRING)
+$Function VOID set_duration(STRING, DURATION)
+$Function DURATION get_duration(STRING)
+$Function VOID clear()
$Function VOID global_clear()
$Function BOOL global_defined(STRING)
$Function VOID global_unset(STRING)
-$Function BOOL defined(PRIV_VCL, STRING)
-$Function STRING type_of(PRIV_VCL, STRING)
-$Function VOID unset(PRIV_VCL, STRING)
-$Function VOID regset(PRIV_VCL, STRING, STRING, STRING)
-$Function VOID queryset(PRIV_VCL, STRING, STRING)
+$Function BOOL defined(STRING)
+$Function STRING type_of(STRING)
+$Function VOID unset(STRING)
+$Function VOID regset(STRING, STRING, STRING)
+$Function VOID queryset(STRING, STRING)

Return to:

Send suggestions and report system problems to the System administrator.