[master] ebc18974f Various auxillary 64-bit VXID adjustments
Poul-Henning Kamp
phk at FreeBSD.org
Thu Jan 12 14:17:12 UTC 2023
commit ebc18974f980ed2335e551f6b0d6f670941686cd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Jan 12 14:16:23 2023 +0000
Various auxillary 64-bit VXID adjustments
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 87d85d935..117e710c6 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -139,10 +139,10 @@ ved_include(struct req *preq, const char *src, const char *host,
wrk->stats->esi_req++;
req->esi_level = preq->esi_level + 1;
- VSLb(req->vsl, SLT_Begin, "req %ju esi %u", VXID(preq->vsl->wid),
- req->esi_level);
- VSLb(preq->vsl, SLT_Link, "req %ju esi %u", VXID(req->vsl->wid),
- req->esi_level);
+ VSLb(req->vsl, SLT_Begin, "req %ju esi %u",
+ (uintmax_t)VXID(preq->vsl->wid), req->esi_level);
+ VSLb(preq->vsl, SLT_Link, "req %ju esi %u",
+ (uintmax_t)VXID(req->vsl->wid), req->esi_level);
VSLb_ts_req(req, "Start", W_TIM_real(wrk));
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index ff6ef5c39..107506938 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -179,7 +179,7 @@ THR_Init(void)
* zero vxid, in order to reserve that for "unassociated" VSL records.
*/
-static uint32_t vxid_base;
+static uint64_t vxid_base;
static uint32_t vxid_chunk = 32768;
static struct lock vxid_lock;
@@ -221,14 +221,14 @@ cli_debug_xid(struct cli *cli, const char * const *av, void *priv)
{
(void)priv;
if (av[2] != NULL) {
- vxid_base = strtoul(av[2], NULL, 0);
+ vxid_base = strtoull(av[2], NULL, 0);
vxid_chunk = 0;
if (av[3] != NULL)
vxid_chunk = strtoul(av[3], NULL, 0);
if (vxid_chunk == 0)
vxid_chunk = 1;
}
- VCLI_Out(cli, "XID is %u chunk %u", vxid_base, vxid_chunk);
+ VCLI_Out(cli, "XID is %ju chunk %u", (uintmax_t)vxid_base, vxid_chunk);
}
/*
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 2e335b97c..20077e182 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -66,7 +66,7 @@ extern const struct req_step R_STP_TRANSPORT[1];
extern const struct req_step R_STP_RECV[1];
struct vxid_pool {
- uint32_t next;
+ uint64_t next;
uint32_t count;
};
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 3b9350f6d..d7b8216c5 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -748,7 +748,7 @@ VRT_INT_string(VRT_CTX, VCL_INT num)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
if (!VRT_INT_is_valid(num))
- VRT_fail(ctx, "INT overflow converting to string (%jX)",
+ VRT_fail(ctx, "INT overflow converting to string (0x%jx)",
(intmax_t)num);
return (WS_Printf(ctx->ws, "%jd", (intmax_t)num));
}
diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c
index 7b1e4234e..37b27834b 100644
--- a/bin/varnishncsa/varnishncsa.c
+++ b/bin/varnishncsa/varnishncsa.c
@@ -110,7 +110,7 @@ struct format {
char *string;
const char *const *strptr;
char *time_fmt;
- int32_t *int32;
+ int64_t *int64;
};
struct watch {
@@ -159,7 +159,7 @@ static struct ctx {
const char *hitmiss;
const char *handling;
const char *side;
- int32_t vxid;
+ int64_t vxid;
} CTX;
static void
@@ -235,11 +235,11 @@ format_strptr(const struct format *format)
}
static int v_matchproto_(format_f)
-format_int32(const struct format *format)
+format_int64(const struct format *format)
{
CHECK_OBJ_NOTNULL(format, FORMAT_MAGIC);
- VSB_printf(CTX.vsb, "%" PRIi32, *format->int32);
+ VSB_printf(CTX.vsb, "%jd", (intmax_t)*format->int64);
return (1);
}
@@ -448,15 +448,15 @@ addf_fragment(struct fragment *frag, const char *str)
}
static void
-addf_int32(int32_t *i)
+addf_int64(int64_t *i)
{
struct format *f;
AN(i);
ALLOC_OBJ(f, FORMAT_MAGIC);
AN(f);
- f->func = format_int32;
- f->int32 = i;
+ f->func = format_int64;
+ f->int64 = i;
VTAILQ_INSERT_TAIL(&CTX.format, f, list);
}
@@ -626,7 +626,7 @@ parse_x_format(char *buf)
return;
}
if (!strcmp(buf, "Varnish:vxid")) {
- addf_int32(&CTX.vxid);
+ addf_int64(&CTX.vxid);
return;
}
if (!strncmp(buf, "VCL_Log:", 8)) {
diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c
index 07024e23d..88cb5049f 100644
--- a/bin/varnishtest/vtc_logexp.c
+++ b/bin/varnishtest/vtc_logexp.c
@@ -180,7 +180,7 @@ struct logexp_test {
VTAILQ_ENTRY(logexp_test) faillist;
struct vsb *str;
- int vxid;
+ int64_t vxid;
int tag;
vre_t *vre;
int skip_max;
@@ -201,7 +201,7 @@ struct logexp {
struct logexp_test *test;
int skip_cnt;
- int vxid_last;
+ int64_t vxid_last;
int tag_last;
struct tests_head fail;
@@ -382,7 +382,7 @@ enum le_match_e {
static enum le_match_e
logexp_match(const struct logexp *le, struct logexp_test *test,
- const char *data, int vxid, int tag, int type, int len)
+ const char *data, int64_t vxid, int tag, int type, int len)
{
const char *legend;
int ok = 1, skip = 0, alt, fail, vxid_ok = 0;
@@ -446,8 +446,8 @@ logexp_match(const struct logexp *le, struct logexp_test *test,
legend = "err";
if (legend != NULL)
- vtc_log(le->vl, 4, "%-5s| %10u %-15s %c %.*s",
- legend, vxid, VSL_tags[tag], type, len,
+ vtc_log(le->vl, 4, "%-5s| %10ju %-15s %c %.*s",
+ legend, (intmax_t)vxid, VSL_tags[tag], type, len,
data);
if (ok) {
@@ -469,7 +469,7 @@ logexp_match(const struct logexp *le, struct logexp_test *test,
static enum le_match_e
logexp_failchk(const struct logexp *le,
- const char *data, int vxid, int tag, int type, int len)
+ const char *data, int64_t vxid, int tag, int type, int len)
{
struct logexp_test *test;
static enum le_match_e r;
@@ -500,7 +500,8 @@ logexp_dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[],
struct VSL_transaction *t;
int i;
enum le_match_e r;
- int vxid, tag, type, len;
+ int64_t vxid;
+ int tag, type, len;
const char *data;
CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC);
@@ -650,7 +651,8 @@ cmd_logexp_common(struct logexp *le, struct vtclog *vl,
{
vre_t *vre;
struct vsb vsb[1];
- int err, pos, tag, vxid;
+ int64_t vxid;
+ int err, pos, tag;
struct logexp_test *test;
char *end, errbuf[VRE_ERROR_LEN];
@@ -659,7 +661,7 @@ cmd_logexp_common(struct logexp *le, struct vtclog *vl,
else if (!strcmp(av[2], "="))
vxid = LE_LAST;
else {
- vxid = (int)strtol(av[2], &end, 10);
+ vxid = (int)strtoll(av[2], &end, 10);
if (*end != '\0' || vxid < 0)
vtc_fatal(vl, "Not a positive integer: '%s'", av[2]);
}
diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c
index 62e3deec0..f68ed5d2f 100644
--- a/bin/varnishtest/vtc_varnish.c
+++ b/bin/varnishtest/vtc_varnish.c
@@ -203,7 +203,7 @@ varnishlog_thread(void *priv)
struct vsm *vsm;
struct VSL_cursor *c;
enum VSL_tag_e tag;
- uint32_t vxid;
+ uint64_t vxid;
unsigned len;
const char *tagname, *data;
int type, i, opt;
@@ -259,11 +259,13 @@ varnishlog_thread(void *priv)
VSB_quote(vsb, data, len, VSB_QUOTE_HEX);
AZ(VSB_finish(vsb));
/* +2 to skip "0x" */
- vtc_log(v->vl, 4, "vsl| %10u %-15s %c [%s]",
- vxid, tagname, type, VSB_data(vsb) + 2);
+ vtc_log(v->vl, 4, "vsl| %10ju %-15s %c [%s]",
+ (uintmax_t)vxid, tagname, type,
+ VSB_data(vsb) + 2);
} else {
- vtc_log(v->vl, 4, "vsl| %10u %-15s %c %.*s",
- vxid, tagname, type, (int)len, data);
+ vtc_log(v->vl, 4, "vsl| %10ju %-15s %c %.*s",
+ (uintmax_t)vxid, tagname, type, (int)len,
+ data);
}
}
if (i == 0) {
diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index 4df8e14dc..a1f1528e6 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -112,8 +112,8 @@ enum VSL_reason_e {
struct VSL_transaction {
int level;
- uint32_t vxid;
- uint32_t vxid_parent;
+ int64_t vxid;
+ int64_t vxid_parent;
enum VSL_transaction_e type;
enum VSL_reason_e reason;
struct VSL_cursor *c;
diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py
index 10bef4257..6ec9a5028 100755
--- a/lib/libvarnishapi/generate.py
+++ b/lib/libvarnishapi/generate.py
@@ -190,6 +190,7 @@ fo.write("""
#include "config.h"
#include <ctype.h>
+#include <stdint.h>
#include <stdio.h>
#include "vdef.h"
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 0a7b2cbf1..8b0f095fa 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -261,7 +261,7 @@ vsl_print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo,
int terse)
{
enum VSL_tag_e tag;
- uint32_t vxid;
+ uint64_t vxid;
unsigned len;
const char *data;
int type;
@@ -279,7 +279,7 @@ vsl_print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo,
data = VSL_CDATA(c->rec.ptr);
if (!terse)
- VSL_PRINT(fo, "%10u ", vxid);
+ VSL_PRINT(fo, "%10ju ", (uintmax_t)vxid);
VSL_PRINT(fo, "%-14s ", VSL_tags[tag]);
if (!terse)
VSL_PRINT(fo, "%c ", type);
@@ -373,11 +373,11 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[],
else
VSL_PRINT(fo, "%-3.*s ",
(int)(t->level), "***");
- VSL_PRINT(fo, "%*.s%-14s %*.s%-10u\n",
+ VSL_PRINT(fo, "%*.s%-14s %*.s%-10ju\n",
verbose ? 10 + 1 : 0, " ",
VSL_transactions[t->type],
verbose ? 1 + 1 : 0, " ",
- t->vxid);
+ (uintmax_t)t->vxid);
delim = 1;
}
diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c
index 361407f1b..34b8af199 100644
--- a/lib/libvarnishapi/vsl_dispatch.c
+++ b/lib/libvarnishapi/vsl_dispatch.c
@@ -137,7 +137,7 @@ struct vslc_vtx {
};
struct vtx_key {
- unsigned vxid;
+ uint64_t vxid;
VRBT_ENTRY(vtx_key) entry;
};
VRBT_HEAD(vtx_tree, vtx_key);
@@ -603,7 +603,7 @@ vtx_retire(struct VSLQ *vslq, struct vtx **pvtx)
/* Lookup a vtx by vxid from the managed list */
static struct vtx *
-vtx_lookup(const struct VSLQ *vslq, unsigned vxid)
+vtx_lookup(const struct VSLQ *vslq, uint64_t vxid)
{
struct vtx_key lkey, *key;
struct vtx *vtx;
@@ -619,7 +619,7 @@ vtx_lookup(const struct VSLQ *vslq, unsigned vxid)
/* Insert a new vtx into the managed list */
static struct vtx *
-vtx_add(struct VSLQ *vslq, unsigned vxid)
+vtx_add(struct VSLQ *vslq, uint64_t vxid)
{
struct vtx *vtx;
@@ -690,10 +690,10 @@ vtx_set_parent(struct vtx *parent, struct vtx *child)
successfully parsed. */
static int
vtx_parse_link(const char *str, enum VSL_transaction_e *ptype,
- unsigned *pvxid, enum VSL_reason_e *preason, unsigned *psub)
+ uint64_t *pvxid, enum VSL_reason_e *preason, uint64_t *psub)
{
char type[16], reason[16];
- unsigned vxid, sub;
+ uintmax_t vxid, sub;
int i;
enum VSL_transaction_e et;
enum VSL_reason_e er;
@@ -703,7 +703,7 @@ vtx_parse_link(const char *str, enum VSL_transaction_e *ptype,
AN(pvxid);
AN(preason);
- i = sscanf(str, "%15s %u %15s %u", type, &vxid, reason, &sub);
+ i = sscanf(str, "%15s %ju %15s %ju", type, &vxid, reason, &sub);
if (i < 1)
return (0);
@@ -746,7 +746,7 @@ vtx_scan_begin(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
int i;
enum VSL_transaction_e type;
enum VSL_reason_e reason;
- unsigned p_vxid;
+ uint64_t p_vxid;
struct vtx *p_vtx;
assert(VSL_TAG(ptr) == SLT_Begin);
@@ -813,7 +813,7 @@ vtx_scan_link(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr)
int i;
enum VSL_transaction_e c_type;
enum VSL_reason_e c_reason;
- unsigned c_vxid;
+ uint64_t c_vxid;
struct vtx *c_vtx;
assert(VSL_TAG(ptr) == SLT_Link);
@@ -1295,7 +1295,7 @@ vslq_candidate(struct VSLQ *vslq, const uint32_t *ptr)
enum VSL_reason_e reason;
struct VSL_data *vsl;
enum VSL_tag_e tag;
- unsigned p_vxid, sub;
+ uint64_t p_vxid, sub;
int i;
CHECK_OBJ_NOTNULL(vslq, VSLQ_MAGIC);
@@ -1341,7 +1341,8 @@ vslq_next(struct VSLQ *vslq)
enum vsl_status r;
enum VSL_tag_e tag;
ssize_t len;
- unsigned vxid, keep;
+ uint64_t vxid;
+ unsigned keep;
struct vtx *vtx;
c = vslq->c;
diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h
index 337c4b519..ce5cd224a 100644
--- a/lib/libvarnishapi/vxp.h
+++ b/lib/libvarnishapi/vxp.h
@@ -85,7 +85,7 @@ struct vex_lhs {
int level;
int level_pm;
unsigned taglist;
- unsigned vxid;
+ int64_t vxid;
};
enum vex_rhs_e {
@@ -102,7 +102,7 @@ struct vex_rhs {
unsigned magic;
#define VEX_RHS_MAGIC 0x3F109965
enum vex_rhs_e type;
- long long val_int;
+ int64_t val_int;
double val_float;
char *val_string;
size_t val_stringlen;
diff --git a/lib/libvarnishapi/vxp_test.c b/lib/libvarnishapi/vxp_test.c
index d44a9600a..c1bc08833 100644
--- a/lib/libvarnishapi/vxp_test.c
+++ b/lib/libvarnishapi/vxp_test.c
@@ -31,6 +31,7 @@
#ifndef __FLEXELINT__
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
More information about the varnish-commit
mailing list