STRM_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */
};
+
+/* Types of entities that may interrupt a processing, teomporarily or not
+ * depending on the context;
+ */
+enum {
+ STRM_ENTITY_NONE = 0x0000,
+ STRM_ENTITY_RULE = 0x0001,
+ STRM_ENTITY_FILTER = 0x0002,
+};
+
/* This function is used to report flags in debugging tools. Please reflect
* below any single-bit flag addition above in the same order via the
* __APPEND_FLAG macro. The new end of the buffer is returned.
struct {
void *ptr; /* Pointer on the entity (def: NULL) */
- int type; /* entity type (0: undef, 1: rule, 2: filter) */
+ int type; /* entity type (STRM_ENTITY_*) */
} last_entity; /* last evaluated entity that interrupted processing */
struct {
void *ptr; /* Pointer on the entity (def: NULL) */
- int type; /* entity type (0: undef, 1: rule, 2: filter) */
+ int type; /* entity type (STRM_ENTITY_*) */
} waiting_entity; /* The entity waiting to continue its processing and interrupted by an error/timeout */
unsigned int stream_epoch; /* copy of stream_epoch when the stream was created */
strm_flt(strm)->current[CHN_IDX(chn)] = NULL; \
if (!(chn_prod(chn)->flags & SC_FL_ERROR) && \
!(chn->flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) { \
- (strm)->waiting_entity.type = 0; \
+ (strm)->waiting_entity.type = STRM_ENTITY_NONE; \
(strm)->waiting_entity.ptr = NULL; \
} \
goto resume_execution; \
#define BREAK_EXECUTION(strm, chn, label) \
do { \
if (ret == 0) { \
- s->waiting_entity.type = 2; \
+ s->waiting_entity.type = STRM_ENTITY_FILTER; \
s->waiting_entity.ptr = filter; \
} \
else if (ret < 0) { \
- (strm)->last_entity.type = 2; \
+ (strm)->last_entity.type = STRM_ENTITY_FILTER; \
(strm)->last_entity.ptr = filter; \
} \
strm_flt(strm)->current[CHN_IDX(chn)] = filter; \
if (FLT_OPS(filter)->stream_set_backend) {
filter->calls++;
if (FLT_OPS(filter)->stream_set_backend(s, filter, be) < 0) {
- s->last_entity.type = 2;
+ s->last_entity.type = STRM_ENTITY_FILTER;
s->last_entity.ptr = filter;
return -1;
}
filter->calls++;
ret = FLT_OPS(filter)->http_payload(s, filter, msg, out + offset, data - offset);
if (ret < 0) {
- s->last_entity.type = 2;
+ s->last_entity.type = STRM_ENTITY_FILTER;
s->last_entity.ptr = filter;
goto end;
}
filter->calls++;
ret = FLT_OPS(filter)->channel_post_analyze(s, filter, chn, an_bit);
if (ret < 0) {
- s->last_entity.type = 2;
+ s->last_entity.type = STRM_ENTITY_FILTER;
s->last_entity.ptr = filter;
break;
}
filter->calls++;
ret = FLT_OPS(filter)->tcp_payload(s, filter, chn, out + offset, data - offset);
if (ret < 0) {
- s->last_entity.type = 2;
+ s->last_entity.type = STRM_ENTITY_FILTER;
s->last_entity.ptr = filter;
goto end;
}
act_opts |= ACT_OPT_FINAL;
if (!(s->scf->flags & SC_FL_ERROR) & !(s->req.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
- s->waiting_entity.type = 0;
+ s->waiting_entity.type = STRM_ENTITY_NONE;
s->waiting_entity.ptr = NULL;
}
break;
case ACT_RET_STOP:
rule_ret = HTTP_RULE_RES_STOP;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_YIELD:
send_log(s->be, LOG_WARNING,
"Internal error: action yields while it is no long allowed "
"for the http-request actions.");
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
rule_ret = HTTP_RULE_RES_ERROR;
goto end;
}
- s->waiting_entity.type = 1;
+ s->waiting_entity.type = STRM_ENTITY_RULE;
s->waiting_entity.ptr = rule;
rule_ret = HTTP_RULE_RES_YIELD;
goto end;
case ACT_RET_ERR:
rule_ret = HTTP_RULE_RES_ERROR;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_DONE:
rule_ret = HTTP_RULE_RES_DONE;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_DENY:
if (txn->status == -1)
txn->status = 403;
rule_ret = HTTP_RULE_RES_DENY;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_ABRT:
rule_ret = HTTP_RULE_RES_ABRT;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_INV:
rule_ret = HTTP_RULE_RES_BADREQ;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
switch (rule->action) {
case ACT_ACTION_ALLOW:
rule_ret = HTTP_RULE_RES_STOP;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
txn->status = rule->arg.http_reply->status;
txn->http_reply = rule->arg.http_reply;
rule_ret = HTTP_RULE_RES_DENY;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
txn->status = rule->arg.http_reply->status;
txn->http_reply = rule->arg.http_reply;
rule_ret = HTTP_RULE_RES_DENY;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
break;
rule_ret = ret ? HTTP_RULE_RES_ABRT : HTTP_RULE_RES_ERROR;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
act_opts |= ACT_OPT_FINAL;
if (!(s->scb->flags & SC_FL_ERROR) & !(s->res.flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
- s->waiting_entity.type = 0;
+ s->waiting_entity.type = STRM_ENTITY_NONE;
s->waiting_entity.ptr = NULL;
}
break;
case ACT_RET_STOP:
rule_ret = HTTP_RULE_RES_STOP;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_YIELD:
send_log(s->be, LOG_WARNING,
"Internal error: action yields while it is no long allowed "
"for the http-response/http-after-response actions.");
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
rule_ret = HTTP_RULE_RES_ERROR;
goto end;
}
- s->waiting_entity.type = 1;
+ s->waiting_entity.type = STRM_ENTITY_RULE;
s->waiting_entity.ptr = rule;
rule_ret = HTTP_RULE_RES_YIELD;
goto end;
case ACT_RET_ERR:
rule_ret = HTTP_RULE_RES_ERROR;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_DONE:
rule_ret = HTTP_RULE_RES_DONE;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_DENY:
if (txn->status == -1)
txn->status = 502;
rule_ret = HTTP_RULE_RES_DENY;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_ABRT:
rule_ret = HTTP_RULE_RES_ABRT;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_INV:
rule_ret = HTTP_RULE_RES_BADREQ;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
switch (rule->action) {
case ACT_ACTION_ALLOW:
rule_ret = HTTP_RULE_RES_STOP; /* "allow" rules are OK */
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
txn->status = rule->arg.http_reply->status;
txn->http_reply = rule->arg.http_reply;
rule_ret = HTTP_RULE_RES_DENY;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
break;
rule_ret = ret ? HTTP_RULE_RES_ABRT : HTTP_RULE_RES_ERROR;
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
s->current_rule_list = NULL;
s->current_rule = NULL;
s->rules_exp = TICK_ETERNITY;
- s->last_entity.type = 0;
+ s->last_entity.type = STRM_ENTITY_NONE;
s->last_entity.ptr = NULL;
- s->waiting_entity.type = 0;
+ s->waiting_entity.type = STRM_ENTITY_NONE;
s->waiting_entity.ptr = NULL;
s->stkctr = NULL;
smp->flags = SMP_F_VOL_TXN;
smp->data.type = SMP_T_STR;
- if (!smp->strm || smp->strm->last_entity.type != 1)
+ if (!smp->strm || smp->strm->last_entity.type != STRM_ENTITY_RULE)
return 0;
rule = smp->strm->last_entity.ptr;
smp->flags = SMP_F_VOL_TXN;
smp->data.type = SMP_T_SINT;
- if (!smp->strm || smp->strm->last_entity.type != 1)
+ if (!smp->strm || smp->strm->last_entity.type != STRM_ENTITY_RULE)
return 0;
rule = smp->strm->last_entity.ptr;
if (!smp->strm)
return 0;
- if (smp->strm->last_entity.type == 1) {
+ if (smp->strm->last_entity.type == STRM_ENTITY_RULE) {
struct act_rule *rule = smp->strm->last_entity.ptr;
struct buffer *trash = get_trash_chunk();
trash->data = snprintf(trash->area, trash->size, "%s:%d", rule->conf.file, rule->conf.line);
smp->data.u.str = *trash;
}
- else if (smp->strm->last_entity.type == 2) {
+ else if (smp->strm->last_entity.type == STRM_ENTITY_FILTER) {
struct filter *filter = smp->strm->last_entity.ptr;
if (FLT_ID(filter)) {
if (!smp->strm)
return 0;
- if (smp->strm->waiting_entity.type == 1) {
+ if (smp->strm->waiting_entity.type == STRM_ENTITY_RULE) {
struct act_rule *rule = smp->strm->waiting_entity.ptr;
struct buffer *trash = get_trash_chunk();
trash->data = snprintf(trash->area, trash->size, "%s:%d", rule->conf.file, rule->conf.line);
smp->data.u.str = *trash;
}
- else if (smp->strm->waiting_entity.type == 2) {
+ else if (smp->strm->waiting_entity.type == STRM_ENTITY_FILTER) {
struct filter *filter = smp->strm->waiting_entity.ptr;
if (FLT_ID(filter)) {
rule = s->current_rule;
s->current_rule = NULL;
if (!(req->flags & SC_FL_ERROR) && !(req->flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
- s->waiting_entity.type = 0;
+ s->waiting_entity.type = STRM_ENTITY_NONE;
s->waiting_entity.ptr = NULL;
}
if ((def_rules && s->current_rule_list == def_rules) || s->current_rule_list == rules)
break;
case ACT_RET_STOP:
case ACT_RET_DONE:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_YIELD:
send_log(s->be, LOG_WARNING,
"Internal error: yield not allowed if the inspect-delay expired "
"for the tcp-request content actions.");
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto internal;
}
- s->waiting_entity.type = 1;
+ s->waiting_entity.type = STRM_ENTITY_RULE;
s->waiting_entity.ptr = rule;
goto missing_data;
case ACT_RET_DENY:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto deny;
case ACT_RET_ABRT:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto abort;
case ACT_RET_ERR:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto internal;
case ACT_RET_INV:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto invalid;
}
/* If not action function defined, check for known actions */
if (rule->action == ACT_ACTION_ALLOW) {
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
else if (rule->action == ACT_ACTION_DENY) {
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto deny;
}
rule = s->current_rule;
s->current_rule = NULL;
if (!(rep->flags & SC_FL_ERROR) && !(rep->flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT))) {
- s->waiting_entity.type = 0;
+ s->waiting_entity.type = STRM_ENTITY_NONE;
s->waiting_entity.ptr = NULL;
}
if ((def_rules && s->current_rule_list == def_rules) || s->current_rule_list == rules)
break;
case ACT_RET_STOP:
case ACT_RET_DONE:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
case ACT_RET_YIELD:
send_log(s->be, LOG_WARNING,
"Internal error: yield not allowed if the inspect-delay expired "
"for the tcp-response content actions.");
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto internal;
}
- s->waiting_entity.type = 1;
+ s->waiting_entity.type = STRM_ENTITY_RULE;
s->waiting_entity.ptr = rule;
channel_dont_close(rep);
goto missing_data;
case ACT_RET_DENY:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto deny;
case ACT_RET_ABRT:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto abort;
case ACT_RET_ERR:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto internal;
case ACT_RET_INV:
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto invalid;
}
/* If not action function defined, check for known actions */
if (rule->action == ACT_ACTION_ALLOW) {
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}
else if (rule->action == ACT_ACTION_DENY) {
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto deny;
}
sc_must_kill_conn(s->scb);
sc_abort(s->scb);
sc_shutdown(s->scb);
- s->last_entity.type = 1;
+ s->last_entity.type = STRM_ENTITY_RULE;
s->last_entity.ptr = rule;
goto end;
}