Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (Revision 291226) +++ channels/chan_sip.c (Arbeitskopie) @@ -18329,8 +18329,6 @@ if (r->call) r->call = dialog_unref(r->call, "unsetting registry->call pointer-- case 200"); p->registry = registry_unref(p->registry, "unref registry entry p->registry"); - /* Let this one hang around until we have all the responses */ - sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); /* p->needdestroy = 1; */ /* set us up for re-registering @@ -18374,7 +18372,17 @@ expires_ms -= EXPIRY_GUARD_SECS * 1000; if (sipdebug) ast_log(LOG_NOTICE, "Outbound Registration: Expiry for %s is %d sec (Scheduling reregistration in %d s)\n", r->hostname, expires, expires_ms/1000); + /* Let this one hang around until we have all the responses + * If we receive an expiry header from the registrat which is shorter than T1 * 64 + * this pvt should be destroyed soon enough to ensure reregistration works fine */ + int save_expire_timeout = DEFAULT_TRANS_TIMEOUT; + if ((expires_ms < (global_t1 * 64)) && (p->timer_t1 == 0)) { + save_expire_timeout = expires_ms - EXPIRY_GUARD_MIN; + } else if ((expires_ms < (p->timer_t1 * 64)) && (p->timer_t1 != 0)) { + save_expire_timeout = expires_ms - EXPIRY_GUARD_MIN; + } + sip_scheddestroy(p, save_expire_timeout); r->refresh= (int) expires_ms / 1000; /* Schedule re-registration before we expire */