MINOR: checks/sample: Remove unnecessary tests on the sample session
A sample must always have a session defined. Otherwise, it is a bug. So it is
unnecessary to test if it is defined when called from a health checks context.
This patch fixes the issue #616.
diff --git a/src/backend.c b/src/backend.c
index 472d905..2a59247 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -2548,7 +2548,7 @@
if (smp->strm)
px = smp->strm->be;
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
px = __objt_check(smp->sess->origin)->proxy;
if (!px)
return 0;
@@ -2567,7 +2567,7 @@
if (smp->strm)
px = smp->strm->be;
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
px = __objt_check(smp->sess->origin)->proxy;
if (!px)
return 0;
@@ -2591,7 +2591,7 @@
if (smp->strm)
srv = objt_server(smp->strm->target);
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
srv = __objt_check(smp->sess->origin)->server;
if (!srv)
return 0;
@@ -2610,7 +2610,7 @@
if (smp->strm)
srv = objt_server(smp->strm->target);
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
srv = __objt_check(smp->sess->origin)->server;
if (!srv)
return 0;
diff --git a/src/http_fetch.c b/src/http_fetch.c
index ff292b6..5fc68a9 100644
--- a/src/http_fetch.c
+++ b/src/http_fetch.c
@@ -386,7 +386,7 @@
static int smp_fetch_stver(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct channel *chn = SMP_RES_CHN(smp);
- struct check *check = (smp->sess ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = objt_check(smp->sess->origin);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct htx_sl *sl;
char *ptr;
@@ -415,7 +415,7 @@
static int smp_fetch_stcode(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct channel *chn = SMP_RES_CHN(smp);
- struct check *check = (smp->sess ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = objt_check(smp->sess->origin);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct htx_sl *sl;
char *ptr;
@@ -463,7 +463,7 @@
{
/* possible keywords: req.hdrs, res.hdrs */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct buffer *temp;
int32_t pos;
@@ -510,7 +510,7 @@
{
/* possible keywords: req.hdrs_bin, res.hdrs_bin */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct buffer *temp;
char *p, *end;
@@ -579,7 +579,7 @@
{
/* possible keywords: req.body, res.body */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct buffer *temp;
int32_t pos;
@@ -614,7 +614,7 @@
{
/* possible keywords: req.body_len, res.body_len */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
int32_t pos;
unsigned long long len = 0;
@@ -647,7 +647,7 @@
{
/* possible keywords: req.body_size, res.body_size */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
int32_t pos;
unsigned long long len = 0;
@@ -744,7 +744,7 @@
{
/* possible keywords: req.fhdr, res.fhdr */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx *ctx = smp->ctx.a[0];
struct ist name;
@@ -798,7 +798,7 @@
{
/* possible keywords: req.fhdr_cnt, res.fhdr_cnt */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx ctx;
struct ist name;
@@ -829,7 +829,7 @@
{
/* possible keywords: req.hdr_names, res.hdr_names */
struct channel *chn = ((kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = ((kw[2] == 's' && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct buffer *temp;
char del = ',';
@@ -875,7 +875,7 @@
{
/* possible keywords: req.hdr / hdr, res.hdr / shdr */
struct channel *chn = ((kw[0] == 'h' || kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = (((kw[0] == 's' || kw[2] == 's') && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[0] == 's' || kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx *ctx = smp->ctx.a[0];
struct ist name;
@@ -939,7 +939,7 @@
{
/* possible keywords: req.hdr_cnt / hdr_cnt, res.hdr_cnt / shdr_cnt */
struct channel *chn = ((kw[0] == 'h' || kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = (((kw[0] == 's' || kw[2] == 's') && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[0] == 's' || kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx ctx;
struct ist name;
@@ -1563,7 +1563,7 @@
{
/* possible keywords: req.cookie / cookie / cook, res.cookie / scook / set-cookie */
struct channel *chn = ((kw[0] == 'c' || kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = (((kw[0] == 's' || kw[2] == 's') && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[0] == 's' || kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx *ctx = smp->ctx.a[2];
struct ist hdr;
@@ -1661,7 +1661,7 @@
{
/* possible keywords: req.cook_cnt / cook_cnt, res.cook_cnt / scook_cnt */
struct channel *chn = ((kw[0] == 'c' || kw[2] == 'q') ? SMP_REQ_CHN(smp) : SMP_RES_CHN(smp));
- struct check *check = (((kw[0] == 's' || kw[2] == 's') && smp->sess) ? objt_check(smp->sess->origin) : NULL);
+ struct check *check = ((kw[0] == 's' || kw[2] == 's') ? objt_check(smp->sess->origin) : NULL);
struct htx *htx = smp_prefetch_htx(smp, chn, check, 1);
struct http_hdr_ctx ctx;
struct ist hdr;
diff --git a/src/payload.c b/src/payload.c
index 00e9467..05201ff 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -58,7 +58,7 @@
else
smp->data.u.sint = ci_data(chn);
}
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
struct check *check = __objt_check(smp->sess->origin);
smp->data.u.sint = ((check->cs && IS_HTX_CS(check->cs)) ? (htxbuf(&check->bi))->data: b_data(&check->bi));
}
@@ -979,7 +979,7 @@
data = ci_data(chn);
max = global.tune.bufsize;
}
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
struct buffer *buf = &(__objt_check(smp->sess->origin)->bi);
head = b_head(buf);
data = b_data(buf);
@@ -1042,7 +1042,7 @@
data = ci_data(chn);
max = global.tune.bufsize;
}
- else if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
+ else if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) {
struct buffer *buf = &(__objt_check(smp->sess->origin)->bi);
head = b_head(buf);
data = b_data(buf);
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index dfaea05..8b02a1d 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -8470,7 +8470,7 @@
{
struct connection *conn;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8509,7 +8509,7 @@
struct connection *conn;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8534,7 +8534,7 @@
struct connection *conn;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8568,7 +8568,7 @@
struct ssl_sock_ctx *ctx;
int sint;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8598,7 +8598,7 @@
struct connection *conn;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8629,7 +8629,7 @@
smp->flags = SMP_F_CONST;
smp->data.type = SMP_T_STR;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8663,7 +8663,7 @@
smp->flags = SMP_F_CONST;
smp->data.type = SMP_T_STR;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8696,7 +8696,7 @@
struct connection *conn;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8734,7 +8734,7 @@
smp->flags = SMP_F_CONST;
smp->data.type = SMP_T_BIN;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8766,7 +8766,7 @@
struct buffer *data;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8803,7 +8803,7 @@
struct buffer *data;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :
@@ -8961,7 +8961,7 @@
struct buffer *finished_trash;
struct ssl_sock_ctx *ctx;
- if (smp->sess && obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
+ if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK)
conn = (kw[4] != 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL;
else
conn = (kw[4] != 'b') ? objt_conn(smp->sess->origin) :