diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-02-05 15:29:41 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2018-02-05 23:11:56 +0200 |
commit | 3eff9532e5116eab0b465c356fc798ec62e16df7 (patch) | |
tree | 4023205648cd8d400cce6a23ee9702a0ebf518e9 /src | |
parent | 16c8dfa0c3ffabd61bb07d8b47e63983b8eb94da (diff) | |
download | varnish-mib-3eff9532e5116eab0b465c356fc798ec62e16df7.tar.gz varnish-mib-3eff9532e5116eab0b465c356fc798ec62e16df7.tar.bz2 |
Initial rewrite for varnish 5.2
* src/betab.c (backend_dfn): Change type of the vpt
array. All uses updated.
(backend_clear): No need to release vpt entries now.
* src/varnish_mib.mib2c (VarnishMib::MIBTable): Change data table
to keep entries of const volatile uint64_t *.
(varnish_var_lookup, varnish_get_oid, dict_install): Reflect that change.
(vd): Rename to vsm.
(dict_load): Change arguments to VSC_Iter
(post_config): VSC_New takes no arguments.
Diffstat (limited to 'src')
-rw-r--r-- | src/betab.c | 9 | ||||
-rw-r--r-- | src/varnish_mib.mib2c | 66 |
2 files changed, 33 insertions, 42 deletions
diff --git a/src/betab.c b/src/betab.c index 2979f8b..83d77e3 100644 --- a/src/betab.c +++ b/src/betab.c @@ -81,3 +81,3 @@ struct backend_dfn { - struct VSC_point *vpt[VBE_MAX]; + const volatile uint64_t *vpt[VBE_MAX]; @@ -94,5 +94,2 @@ backend_clear(void) struct backend_dfn *dfn = VTAILQ_FIRST(&backends); - int i; - for (i = 0; i < VBE_MAX; i++) - VSC_Destroy_Point(&dfn->vpt[i]); VTAILQ_REMOVE(&backends, dfn, list); @@ -129,3 +126,3 @@ backend_register(char const *name, size_t len, char const *param, if (strcmp(betab_trans[i].param, param) == 0) { - dfn->vpt[i] = VSC_Clone_Point(vpt); + dfn->vpt[i] = vpt->ptr; break; @@ -164,3 +161,3 @@ backendTable_load(netsnmp_cache *cache, void *vmagic) U64 *u = (U64*)((char*)ent + betab_trans[i].off); - uint64_t n = *(const volatile uint64_t*)dfn->vpt[i]->ptr; + uint64_t n = *dfn->vpt[i]; u->high = n >> 32; diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c index 2b12090..b061022 100644 --- a/src/varnish_mib.mib2c +++ b/src/varnish_mib.mib2c @@ -122,3 +122,3 @@ $vars{'varnish_translate_table'} = { $vars{'varnish_hash_table'} = new VarnishMib::MIBTable( - 'struct VSC_point *', + 'const volatile uint64_t *', $vars{'varnish_translate_table'}, @@ -204,3 +204,3 @@ int varnish_ban(netsnmp_agent_request_info *reqinfo, -static struct vsm *vd; +static struct vsm *vsm; static struct vsc *vsc; @@ -212,4 +212,4 @@ post_config(int majorID, int minorID, void *serverarg, void *clientarg) { - vd = VSM_New(); - if (!vd) { + vsm = VSM_New(); + if (!vsm) { snmp_log(LOG_ERR, "VSM_New: %s\n", strerror(errno)); @@ -218,3 +218,3 @@ post_config(int majorID, int minorID, void *serverarg, void *clientarg) - vsc = VSC_New(vd); + vsc = VSC_New(); if (!vsc) { @@ -224,7 +224,7 @@ post_config(int majorID, int minorID, void *serverarg, void *clientarg) - if (VSM_Attach(vd, 2)) - snmp_log(LOG_ERR, "%s\n", VSM_Error(vd)); + if (VSM_Attach(vsm, 2)) + snmp_log(LOG_ERR, "%s\n", VSM_Error(vsm)); dict_load(vsc); - backend_collect_addr(vd); + backend_collect_addr(vsm); return 0; @@ -250,10 +250,10 @@ varnish_get_vsm_data(void) { - if (vd) { - if (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED)) { - DEBUGMSGTL(("$modulename", "reopening vd\n")); + if (vsm) { + if (VSM_Status(vsm) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED)) { + DEBUGMSGTL(("$modulename", "reopening vsm\n")); dict_load(vsc); - backend_collect_addr(vd); + backend_collect_addr(vsm); } } - return vd; + return vsm; } @@ -262,3 +262,3 @@ ${varnish_hash_table} -static struct VSC_point ** +static const volatile uint64_t ** varnish_var_lookup(char const *str) @@ -281,3 +281,3 @@ varnish_var_lookup(char const *str) -static inline struct VSC_point * +static inline const volatile uint64_t * varnish_get_oid(int i) @@ -292,18 +292,13 @@ dict_clear(void) for (i = 0; i < MAX_VMIB_OID; i++) - if (vmib_data_table[i]) - VSC_Destroy_Point(&vmib_data_table[i]); + vmib_data_table[i] = NULL; } -static struct VSC_point const * +static void dict_install(struct VSC_point const *pt) { - struct VSC_point **ent; + const volatile uint64_t **ent; ent = varnish_var_lookup(pt->name); - if (!ent) - return NULL; - if (*ent) - VSC_Destroy_Point(ent); - *ent = VSC_Clone_Point(pt); - return *ent; + if (ent) + *ent = pt->ptr; } @@ -321,3 +316,3 @@ load_cb(void *priv, const struct VSC_point *vpt) } - vpt = dict_install(vpt); + dict_install(vpt); return 0; @@ -328,6 +323,5 @@ dict_load(struct vsc *vsc) { - struct vsm_fantom fantom = VSM_FANTOM_NULL; dict_clear(); backend_clear(); - VSC_Iter(vsc, &fantom, load_cb, NULL); + VSC_Iter(vsc, vsm, load_cb, NULL); } @@ -363,3 +357,3 @@ handle_$i(netsnmp_mib_handler *handler, { - struct VSC_point *ent = varnish_get_oid($i); + const volatile uint64_t *ent = varnish_get_oid($i); uint64_t val; @@ -368,3 +362,3 @@ handle_$i(netsnmp_mib_handler *handler, return SNMP_ERR_NOSUCHNAME; - val = *(uint64_t*)ent->ptr; + val = *ent; @if $i.type eq 'ASN_COUNTER64'@ @@ -448,3 +442,3 @@ handle_$i(netsnmp_mib_handler *handler, @if $varnish_set_reserve2 ne ''@ - if ($varnish_set_reserve2 (reqinfo, requests, vd)) { + if ($varnish_set_reserve2 (reqinfo, requests, vsm)) { netsnmp_set_request_error(reqinfo, requests, @@ -460,3 +454,3 @@ handle_$i(netsnmp_mib_handler *handler, # below won't be called. - $varnish_set_free(reqinfo, requests, vd); + $varnish_set_free(reqinfo, requests, vsm); @end@ @@ -466,3 +460,3 @@ handle_$i(netsnmp_mib_handler *handler, @if $varnish_set_action ne ''@ - ret = $varnish_set_action(reqinfo, requests, vd); + ret = $varnish_set_action(reqinfo, requests, vsm); if (ret != SNMP_ERR_NOERROR) @@ -475,3 +469,3 @@ handle_$i(netsnmp_mib_handler *handler, # delete temporary storage - if ($varnish_set_commit(reqinfo, requests, vd)) + if ($varnish_set_commit(reqinfo, requests, vsm)) netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED); @@ -483,3 +477,3 @@ handle_$i(netsnmp_mib_handler *handler, # UNDO and return to previous value for the object - if ($varnish_set_undo(reqinfo, requests, vd)) + if ($varnish_set_undo(reqinfo, requests, vsm)) netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED); @@ -682,3 +676,3 @@ init_$modulename(void) { - if (vd) { + if (vsm) { snmp_log(LOG_ERR, "%s: can't be loaded twice\n", "$modulename"); |