From c2a090d627f8f2df0f93b88106b98bf30c4f471c Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Fri, 14 Jun 2024 09:24:17 +0200 Subject: [PATCH] sipreg/reg.c: stop retrying registers early after 401/407 --- src/sipreg/reg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/sipreg/reg.c b/src/sipreg/reg.c index 76e558c75..9a0854f57 100644 --- a/src/sipreg/reg.c +++ b/src/sipreg/reg.c @@ -193,6 +193,7 @@ static void response_handler(int err, const struct sip_msg *msg, void *arg) { const struct sip_hdr *minexp; struct sipreg *reg = arg; + uint16_t last_scode = reg->ls.last_scode; reg->wait = failwait(reg->failc + 1); if (err || !msg || sip_request_loops(®->ls, msg->scode)) { @@ -223,6 +224,11 @@ static void response_handler(int err, const struct sip_msg *msg, void *arg) case 401: case 407: + if (reg->ls.failc > 1 && last_scode == msg->scode) { + reg->failc++; + goto out; + } + sip_auth_reset(reg->auth); err = sip_auth_authenticate(reg->auth, msg); if (err) {