ovoshlook left a comment (kamailio/kamailio#4304)
The case is a little bit different (it is made in response to this issue https://github.com/kamailio/kamailio/issues/4266):
The case:
When Kamailio receives a REGISTER request, it makes a parallel forking to registrars ( mid-registrar case, let's say ) The Kamailio catches the Auth response (401/407) from Registrars at the branch-failure route. If it authenticates and sends a REGISTER with an authentication header to the Registrar.
However, there are some cases where the first Registrar authenticates and sends a 200 OK response earlier than other Registrars send 401/407 responses.
existing logic doesn't give those responses being handled anyhow and discards them, as the transaction status already changed to 200, and logic hits this point: https://github.com/kamailio/kamailio/blob/master/src/modules/tm/t_reply.c#L1...
goto: discard;
Added code allows handling such responses within failure routes; however, it won't propagate failure replies to UAC, because the new code is >=300 https://github.com/kamailio/kamailio/blob/master/src/modules/tm/t_reply.c#L1... and the status of the transaction is already 200 https://github.com/kamailio/kamailio/blob/master/src/modules/tm/t_reply.c#L1... 200 responses to late parallel registrations also won't be propagated to UAC because the transaction status 200 already exists.
The description of the added code might be indeed messy - I'll try to improve the clarity of the comment