Skip to content

Commit

Permalink
Merge pull request #366 from dsanders11/patch-2
Browse files Browse the repository at this point in the history
Changes to stop keepalives on unregisters
  • Loading branch information
bogdan-iancu committed Nov 4, 2014
2 parents 85c8dab + f4ed457 commit 47c968f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions modules/nat_traversal/nat_traversal.c
Expand Up @@ -373,11 +373,9 @@ SIP_Dialog_end(SIP_Dialog *dialog)
static INLINE void
SIP_Registration_update(NAT_Contact *contact, time_t expire)
{
if (expire > contact->registration_expire) {
if (contact->registration_expire == 0)
update_stat(registered_endpoints, 1);
contact->registration_expire = expire;
}
if (contact->registration_expire == 0)
update_stat(registered_endpoints, 1);
contact->registration_expire = expire;
}

static INLINE void
Expand Down Expand Up @@ -891,11 +889,11 @@ get_register_expire(struct sip_msg *request, struct sip_msg *reply)
return 0;
}

if (!reply->contact)
return 0;

now = time(NULL);

if (!reply->contact)
return now;

// request may be R/O (if we are called from the TM callback),
// thus we copy the hdr_field structures before parsing them

Expand Down Expand Up @@ -943,7 +941,11 @@ get_register_expire(struct sip_msg *request, struct sip_msg *reply)

LM_DBG("maximum expire for all contacts: %u\n", (unsigned)expire);

return (expire ? expire + now : 0);
// If no contacts were found in the reply which match the contact
// address being registered, then it was an unregister. As such,
// we return 'now' as the expiration time, to stop keepalives

return (expire ? expire + now : now);
}


Expand Down

0 comments on commit 47c968f

Please sign in to comment.