q->q_state = QS_QUEUEUP;
q->q_state = QS_BADADDR;
It is clear, it will only requeue (QS_QUEUEUP) for a EX_TEMPFAIL
Yes, apparently clear *whenever* this switch is executed.
But *whenever* could include after RCPT TO 4xx and 5xx.
Which is precisely what many others here said, the post-
DATA 2/4/5 switch affects what is left after a RCPT 2xx.
All RCPT 4xx and RCPT 5xx were already handled *before*
DATA, possibly in the same piece of code you have quoted.
I'm far too lazy to find a source and check this, I only
point out that the mere existence of this switch doesn't
mean that it's only used after DATA 2/4/5.
Clearly there must be some code dealing with RCPT 2/4/5,
please check that, too.