diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5e3898f014756a26d57a1532128077f6d19d83be..ed5d994955ba2b34724198c8435f4d7ae0c9c554 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -16727,10 +16727,9 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str } else if (!strcasecmp(v->name, "host")) { if (!strcasecmp(v->value, "dynamic")) { /* They'll register with us */ - ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC); - if (!found) { - /* Initialize stuff iff we're not found, otherwise - we keep going with what we had */ + if (!found || !ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)) { + /* Initialize stuff if this is a new peer, or if it used to + * not be dynamic before the reload. */ memset(&peer->addr.sin_addr, 0, 4); if (peer->addr.sin_port) { /* If we've already got a port, make it the default rather than absolute */ @@ -16738,6 +16737,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str peer->addr.sin_port = 0; } } + ast_set_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC); } else { /* Non-dynamic. Make sure we become that way if we're not */ if (peer->expire > -1)