diff --git a/src/sipreg/reg.c b/src/sipreg/reg.c index 9a0854f57..d68f61f2a 100644 --- a/src/sipreg/reg.c +++ b/src/sipreg/reg.c @@ -193,7 +193,6 @@ 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)) { @@ -215,54 +214,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 && reg->ls.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)