--- channels/chan_iax2.c.orig 2013-09-11 11:58:39.591475250 +0200 +++ channels/chan_iax2.c 2013-09-11 12:00:25.593765722 +0200 @@ -8833,6 +8833,21 @@ } } + /* treat an unspecified refresh interval as the minimum */ + if (!refresh) + refresh = min_reg_expire; + if (refresh > max_reg_expire) { + ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n", + p->name, max_reg_expire, refresh); + p->expiry = max_reg_expire; + } else if (refresh < min_reg_expire) { + ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n", + p->name, min_reg_expire, refresh); + p->expiry = min_reg_expire; + } else { + p->expiry = refresh; + } + if (ast_sockaddr_cmp(&p->addr, &sockaddr)) { if (iax2_regfunk) { iax2_regfunk(p->name, 1); @@ -8885,20 +8900,7 @@ peer_unref(p); } } - /* treat an unspecified refresh interval as the minimum */ - if (!refresh) - refresh = min_reg_expire; - if (refresh > max_reg_expire) { - ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n", - p->name, max_reg_expire, refresh); - p->expiry = max_reg_expire; - } else if (refresh < min_reg_expire) { - ast_log(LOG_NOTICE, "Restricting registration for peer '%s' to %d seconds (requested %d)\n", - p->name, min_reg_expire, refresh); - p->expiry = min_reg_expire; - } else { - p->expiry = refresh; - } + if (p->expiry && sin->sin_addr.s_addr) { p->expire = iax2_sched_add(sched, (p->expiry + 10) * 1000, expire_registry, peer_ref(p)); if (p->expire == -1)