Skip to content

Commit

Permalink
sipreg: refactor response_handler else optimization (#1147)
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers authored Jun 22, 2024
1 parent 5628b79 commit cce88be
Showing 1 changed file with 34 additions and 34 deletions.
68 changes: 34 additions & 34 deletions src/sipreg/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cce88be

Please sign in to comment.