From 1bf05d819abeb51e74b11e634db9722b308a89d7 Mon Sep 17 00:00:00 2001 From: Maximilian Fridrich Date: Wed, 19 Jun 2024 08:39:46 +0200 Subject: [PATCH] sipreg/reg.c: stop retrying registers early after 401/407 (#1143) --- 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) {