haproxy/include/types/vars.h
Christopher Faulet e95f2c3ef5 MEDIUM: thread/vars: Make vars thread-safe
A RW lock has been added to the vars structure to protect each list of
variables. And a global RW lock is used to protect registered names.

When a varibable is fetched, we duplicate sample data because the variable could
be modified by another thread.
2017-10-31 13:58:32 +01:00

38 lines
668 B
C

#ifndef _TYPES_VARS_H
#define _TYPES_VARS_H
#include <common/mini-clist.h>
#include <common/hathreads.h>
#include <types/sample.h>
enum vars_scope {
SCOPE_SESS = 0,
SCOPE_TXN,
SCOPE_REQ,
SCOPE_RES,
SCOPE_PROC,
};
struct vars {
struct list head;
enum vars_scope scope;
unsigned int size;
#ifdef USE_THREAD
HA_RWLOCK_T rwlock;
#endif
};
/* This struct describes a variable. */
struct var_desc {
const char *name; /* Contains the normalized variable name. */
enum vars_scope scope;
};
struct var {
struct list l; /* Used for chaining vars. */
const char *name; /* Contains the variable name. */
struct sample_data data; /* data storage. */
};
#endif