diff --git a/src/tcp_rules.c b/src/tcp_rules.c index 131895340..e64979495 100644 --- a/src/tcp_rules.c +++ b/src/tcp_rules.c @@ -118,8 +118,12 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit) if ((req->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(req, global.tune.maxrewrite) || sc_waiting_room(chn_prod(req)) || - !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) + !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { partial = SMP_OPT_FINAL; + /* Action may yield while the inspect_delay is not expired and there is no read error */ + if ((req->flags & CF_READ_ERROR) || !s->be->tcp_req.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) + act_opts |= ACT_OPT_FINAL; + } else partial = 0; @@ -153,12 +157,8 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit) if (ret) { act_opts |= ACT_OPT_FIRST; resume_execution: - /* Always call the action function if defined */ if (rule->action_ptr) { - if (partial & SMP_OPT_FINAL) - act_opts |= ACT_OPT_FINAL; - switch (rule->action_ptr(rule, s->be, s->sess, s, act_opts)) { case ACT_RET_CONT: break; @@ -169,7 +169,7 @@ int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit) goto end; case ACT_RET_YIELD: s->current_rule = rule; - if (partial & SMP_OPT_FINAL) { + if (act_opts & ACT_OPT_FINAL) { send_log(s->be, LOG_WARNING, "Internal error: yield not allowed if the inspect-delay expired " "for the tcp-request content actions."); @@ -301,8 +301,12 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit) */ if ((rep->flags & (CF_EOI|CF_SHUTR|CF_READ_ERROR)) || channel_full(rep, global.tune.maxrewrite) || sc_waiting_room(chn_prod(rep)) || - !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) + !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) { partial = SMP_OPT_FINAL; + /* Action may yield while the inspect_delay is not expired and there is no read error */ + if ((rep->flags & CF_READ_ERROR) || !s->be->tcp_rep.inspect_delay || tick_is_expired(s->rules_exp, now_ms)) + act_opts |= ACT_OPT_FINAL; + } else partial = 0; @@ -338,9 +342,6 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit) resume_execution: /* Always call the action function if defined */ if (rule->action_ptr) { - if (partial & SMP_OPT_FINAL) - act_opts |= ACT_OPT_FINAL; - switch (rule->action_ptr(rule, s->be, s->sess, s, act_opts)) { case ACT_RET_CONT: break; @@ -351,7 +352,7 @@ int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit) goto end; case ACT_RET_YIELD: s->current_rule = rule; - if (partial & SMP_OPT_FINAL) { + if (act_opts & ACT_OPT_FINAL) { send_log(s->be, LOG_WARNING, "Internal error: yield not allowed if the inspect-delay expired " "for the tcp-response content actions.");