BUG/MEDIUM: conn-stream: Only keep app layer flags of the endpoint on reset

The commit a6c4a4834 ("BUG/MEDIUM: conn-stream: Don't erase endpoint flags
on reset") was too laxy on reset. Only app layer flags must be preserved. On
reset, the endpoint is detached. Thus all flags set by the endpoint itself
or concerning its type must be removed.

Without this fix, we can experienced crashes when a stream is released while
a server connection attempt failed. Indeed, in this case, endpoint of the
backend conn-stream is reset. But the endpoint type is still set. Thus when
the stream is released, the endpoint is detached again.

This patch is 2.6-specific. No backport needed. This commit depends on the
previous one ("MINOR: conn-stream: Add mask from flags set by endpoint or
app layer").
This commit is contained in:
Christopher Faulet 2022-05-04 09:52:48 +02:00
parent fa24379aeb
commit c41f93c5cd

View File

@ -394,6 +394,7 @@ static void cs_detach_endp(struct conn_stream **csp)
/* the cs is the only one one the endpoint */
cs->endp->target = NULL;
cs->endp->ctx = NULL;
cs->endp->flags &= CS_EP_APP_MASK;
cs->endp->flags |= CS_EP_DETACHED;
}
@ -471,7 +472,7 @@ int cs_reset_endp(struct conn_stream *cs)
cs->endp->flags |= CS_EP_ERROR;
return -1;
}
new_endp->flags = cs->endp->flags;
new_endp->flags = (cs->endp->flags & CS_EP_APP_MASK);
/* The app is still attached, the cs will not be released */
cs_detach_endp(&cs);