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,3 +1,3 @@
-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.
@@ -7,7 +7,2 @@ Please send vmod-variable bug reports to <gray@gnu.org>
-Version 1.0.90, (Git)
-
-Fix coredumps.
-
-
Version 1.0, 2015-02-16
@@ -19,3 +14,3 @@ Copyright information:
-Copyright (C) 2015-2016 Sergey Poznyakoff
+Copyright (C) 2015 Sergey Poznyakoff
diff --git a/configure.ac b/configure.ac
index f2adcb9..9a69658 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,3 +1,3 @@
# This file is part of vmod-variable -*- autoconf -*-
-# Copyright (C) 2015-2016 Sergey Poznyakoff
+# Copyright (C) 2015 Sergey Poznyakoff
#
@@ -16,3 +16,3 @@
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])
diff --git a/src/variable.c b/src/variable.c
index acdc6f6..bd79c3b 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -312,2 +312,6 @@ 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;
@@ -379,16 +383,22 @@ vmod_global_unset(VARIABLE_CTX ctx, VCL_STRING name)
-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;
}
@@ -414,5 +424,5 @@ 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));
}
@@ -420,5 +430,5 @@ vmod_clear(VARIABLE_CTX ctx, struct vmod_priv *priv)
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)
@@ -429,6 +439,5 @@ vmod_get_string(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
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);
@@ -440,5 +449,5 @@ 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);
}
@@ -446,6 +455,5 @@ vmod_get(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING 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);
}
@@ -455,6 +463,5 @@ vmod_set(VARIABLE_CTX ctx, struct vmod_priv *priv,
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)) \
@@ -466,7 +473,6 @@ __cat__(vmod_get_,r_type)(VARIABLE_CTX ctx, struct vmod_priv *priv, \
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); \
@@ -485,5 +491,5 @@ 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);
}
@@ -491,5 +497,5 @@ vmod_defined(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING 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];
@@ -498,5 +504,5 @@ vmod_type_of(VARIABLE_CTX ctx, struct vmod_priv *priv, VCL_STRING name)
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);
}
@@ -712,6 +718,6 @@ 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;
@@ -889,6 +895,5 @@ 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;
diff --git a/src/variable.vcc b/src/variable.vcc
index ad80fe0..3745a8d 100644
--- a/src/variable.vcc
+++ b/src/variable.vcc
@@ -24,15 +24,15 @@ 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()
@@ -42,6 +42,6 @@ $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.