MEDIUM: get rid of SMP_F_READ_ONLY and SMP_F_MUST_FREE
These ones were either unused or improperly used. Some integers were marked
read-only, which does not make much sense. Buffers are not read-only, they're
"constant" in that they must be kept intact after any possible change.
diff --git a/include/proto/acl.h b/include/proto/acl.h
index e21075f..998ac43 100644
--- a/include/proto/acl.h
+++ b/include/proto/acl.h
@@ -205,10 +205,8 @@
/* Check that the IPv4 address in <test> matches the IP/mask in pattern */
int acl_match_ip(struct sample *smp, struct acl_pattern *pattern);
-/* Executes a regex. It needs to change the data. If it is marked READ_ONLY
- * then it will be allocated and duplicated in place so that others may use
- * it later on. Note that this is embarrassing because we always try to avoid
- * allocating memory at run time.
+/* Executes a regex. It temporarily changes the data to add a trailing zero,
+ * and restores the previous character when leaving.
*/
int acl_match_reg(struct sample *smp, struct acl_pattern *pattern);
diff --git a/include/types/pattern.h b/include/types/pattern.h
index 8fcc5d8..c710b20 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -54,10 +54,6 @@
SMP_F_VOL_TXN = 1 << 5, /* result sensitive to new transaction (eg: HTTP version) */
SMP_F_VOL_SESS = 1 << 6, /* result sensitive to new session (eg: src IP) */
SMP_F_VOLATILE = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */
-
- SMP_F_READ_ONLY = 1 << 7, /* returned data must not be altered */
- SMP_F_MUST_FREE = 1 << 10, /* migration: this sample must be freed ASAP */
-
};
/* pattern fetch direction */
diff --git a/src/acl.c b/src/acl.c
index 9c4ce0c..5d86a3e 100644
--- a/src/acl.c
+++ b/src/acl.c
@@ -623,32 +623,14 @@
return node;
}
-/* Executes a regex. It needs to change the data. If it is marked READ_ONLY
- * then it will be allocated and duplicated in place so that others may use
- * it later on. Note that this is embarrassing because we always try to avoid
- * allocating memory at run time.
+/* Executes a regex. It temporarily changes the data to add a trailing zero,
+ * and restores the previous character when leaving.
*/
int acl_match_reg(struct sample *smp, struct acl_pattern *pattern)
{
char old_char;
int ret;
- if (unlikely(smp->flags & SMP_F_READ_ONLY)) {
- char *new_str;
-
- new_str = calloc(1, smp->data.str.len + 1);
- if (!new_str)
- return ACL_PAT_FAIL;
-
- memcpy(new_str, smp->data.str.str, smp->data.str.len);
- new_str[smp->data.str.len] = 0;
- if (smp->flags & SMP_F_MUST_FREE)
- free(smp->data.str.str);
- smp->data.str.str = new_str;
- smp->flags |= SMP_F_MUST_FREE;
- smp->flags &= ~SMP_F_READ_ONLY;
- }
-
old_char = smp->data.str.str[smp->data.str.len];
smp->data.str.str[smp->data.str.len] = 0;
@@ -1903,12 +1885,6 @@
*
*/
- /* now we may have some cleanup to do */
- if (smp.flags & SMP_F_MUST_FREE) {
- free(smp.data.str.str);
- smp.data.str.len = 0;
- }
-
/* we're ORing these terms, so a single PASS is enough */
if (acl_res == ACL_PAT_PASS)
break;
diff --git a/src/backend.c b/src/backend.c
index 4d0d86f..fc8f22f 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1456,7 +1456,6 @@
acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->flags = SMP_F_VOL_TXN;
smp->type = SMP_T_UINT;
smp->data.uint = l4->be->uuid;
@@ -1471,7 +1470,6 @@
if (!target_srv(&l4->target))
return 0;
- smp->flags = SMP_F_READ_ONLY;
smp->type = SMP_T_UINT;
smp->data.uint = target_srv(&l4->target)->puid;
diff --git a/src/frontend.c b/src/frontend.c
index 2e0237a..c44cd92 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -502,7 +502,6 @@
acl_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->flags = SMP_F_VOL_SESS;
smp->type = SMP_T_UINT;
smp->data.uint = l4->fe->uuid;
diff --git a/src/proto_http.c b/src/proto_http.c
index b6036d5..f3db682 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -7665,7 +7665,7 @@
smp->data.str.len = txn->req.sl.rq.m_l;
smp->data.str.str = txn->req.buf->p + txn->req.sol;
}
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
@@ -7730,7 +7730,7 @@
smp->data.str.str = ptr;
smp->data.str.len = len;
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
@@ -7755,7 +7755,7 @@
smp->data.str.str = ptr;
smp->data.str.len = len;
- smp->flags = SMP_F_READ_ONLY | SMP_F_VOL_1ST;
+ smp->flags = SMP_F_VOL_1ST;
return 1;
}
@@ -7837,7 +7837,7 @@
if (px->options & PR_O_HTTP_PROXY)
l4->flags |= SN_ADDR_SET;
- smp->flags = SMP_F_READ_ONLY;
+ smp->flags = 0;
return 1;
}
@@ -7965,8 +7965,6 @@
ptr++;
smp->data.str.len = ptr - smp->data.str.str;
-
- /* we do not need to set READ_ONLY because the data is in a buffer */
smp->flags = SMP_F_VOL_1ST;
return 1;
}
diff --git a/src/protocols.c b/src/protocols.c
index 12d719a..52ddbcc 100644
--- a/src/protocols.c
+++ b/src/protocols.c
@@ -338,7 +338,6 @@
acl_fetch_so_id(struct proxy *px, struct session *l4, void *l7, int dir,
struct acl_expr *expr, struct sample *smp)
{
- smp->flags = SMP_F_READ_ONLY;
smp->type = SMP_T_UINT;
smp->data.uint = l4->listener->luid;
return 1;