From 37570800889a13f9c1aa7a6d0a49f778c29a0247 Mon Sep 17 00:00:00 2001 From: Sebastian Reimers Date: Thu, 20 Jun 2024 08:15:22 +0200 Subject: [PATCH] sipreg: refactor respons_handle else optimization --- src/sipreg/reg.c | 68 ++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/sipreg/reg.c b/src/sipreg/reg.c index 9a0854f57..7dff7bd1f 100644 --- a/src/sipreg/reg.c +++ b/src/sipreg/reg.c @@ -215,54 +215,54 @@ static void response_handler(int err, const struct sip_msg *msg, void *arg) if (reg->regid > 0 && !reg->terminated && !reg->ka) start_outbound(reg, msg); + goto out; } - else { - if (reg->terminated && !reg->registered) - goto out; - switch (msg->scode) { - - case 401: - case 407: - if (reg->ls.failc > 1 && last_scode == msg->scode) { - reg->failc++; - goto out; - } + if (reg->terminated && !reg->registered) + goto out; - sip_auth_reset(reg->auth); - err = sip_auth_authenticate(reg->auth, msg); - if (err) { - err = (err == EAUTH) ? 0 : err; - break; - } + switch (msg->scode) { - err = request(reg, false); - if (err) - break; + case 401: + case 407: + if (reg->ls.failc > 1 && last_scode == msg->scode) { + reg->failc++; + goto out; + } - return; + sip_auth_reset(reg->auth); + err = sip_auth_authenticate(reg->auth, msg); + if (err) { + err = (err == EAUTH) ? 0 : err; + break; + } - case 403: - sip_auth_reset(reg->auth); + err = request(reg, false); + if (err) break; - case 423: - minexp = sip_msg_hdr(msg, SIP_HDR_MIN_EXPIRES); - if (!minexp || !pl_u32(&minexp->val) || !reg->expires) - break; + return; - reg->expires = pl_u32(&minexp->val); + case 403: + sip_auth_reset(reg->auth); + break; - err = request(reg, false); - if (err) - break; + case 423: + minexp = sip_msg_hdr(msg, SIP_HDR_MIN_EXPIRES); + if (!minexp || !pl_u32(&minexp->val) || !reg->expires) + break; - return; - } + reg->expires = pl_u32(&minexp->val); - ++reg->failc; + err = request(reg, false); + if (err) + break; + + return; } + ++reg->failc; + out: if (!reg->expires) { if (msg && msg->scode >= 400 && msg->scode < 500)