diff options
-rw-r--r-- | channels/chan_iax2.c | 6 | ||||
-rw-r--r-- | channels/chan_sip.c | 18 | ||||
-rw-r--r-- | res/res_rtp_asterisk.c | 4 |
3 files changed, 17 insertions, 11 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 5af0bfe1d..42a538fd4 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -7114,7 +7114,7 @@ static char *handle_cli_iax2_unregister(struct ast_cli_entry *e, int cmd, struct p = find_peer(a->argv[2], 1); if (p) { - if (p->expire > 0) { + if (p->expire > -1) { struct iax2_peer *peer; peer = ao2_find(peers, a->argv[2], OBJ_KEY); @@ -7146,8 +7146,8 @@ static char *complete_iax2_unregister(const char *line, const char *word, int po if (pos == 2) { struct ao2_iterator i = ao2_iterator_init(peers, 0); while ((p = ao2_iterator_next(&i))) { - if (!strncasecmp(p->name, word, wordlen) && - ++which > state && p->expire > 0) { + if (!strncasecmp(p->name, word, wordlen) && + ++which > state && p->expire > -1) { res = ast_strdup(p->name); peer_unref(p); break; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index cda437024..c4d26d56b 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -20829,7 +20829,7 @@ static char *sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_arg return CLI_SHOWUSAGE; if ((peer = sip_find_peer(a->argv[2], NULL, load_realtime, FINDPEERS, TRUE, 0))) { - if (peer->expire > 0) { + if (peer->expire > -1) { AST_SCHED_DEL_UNREF(sched, peer->expire, sip_unref_peer(peer, "remove register expire ref")); expire_register(sip_ref_peer(peer, "ref for expire_register")); @@ -21408,7 +21408,7 @@ static char *complete_sip_registered_peer(const char *word, int state, int flags while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) { if (!strncasecmp(word, peer->name, wordlen) && (!flags2 || ast_test_flag(&peer->flags[1], flags2)) && - ++which > state && peer->expire > 0) + ++which > state && peer->expire > -1) result = ast_strdup(peer->name); if (result) { sip_unref_peer(peer, "toss iterator peer ptr before break"); @@ -30264,13 +30264,11 @@ static struct ast_variable *add_var(const char *buf, struct ast_variable *list) /*! \brief Set peer defaults before configuring specific configurations */ static void set_peer_defaults(struct sip_peer *peer) { - if (peer->expire == 0) { + if (peer->expire < 0) { /* Don't reset expire or port time during reload if we have an active registration */ - peer->expire = -1; - peer->pokeexpire = -1; - peer->keepalivesend = -1; + peer_sched_cleanup(peer); set_socket_transport(&peer->socket, AST_TRANSPORT_UDP); } peer->type = SIP_TYPE_PEER; @@ -30355,6 +30353,10 @@ static struct sip_peer *temp_peer(const char *name) } ast_atomic_fetchadd_int(&apeerobjs, 1); + peer->expire = -1; + peer->pokeexpire = -1; + peer->keepalivesend = -1; + set_peer_defaults(peer); ast_copy_string(peer->name, name, sizeof(peer->name)); @@ -30475,6 +30477,10 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, str ast_debug(3, "-REALTIME- peer built. Name: %s. Peer objects: %d\n", name, rpeerobjs); } else ast_atomic_fetchadd_int(&speerobjs, 1); + + peer->expire = -1; + peer->pokeexpire = -1; + peer->keepalivesend = -1; } /* Note that our peer HAS had its reference count increased */ diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index e2062416e..f6bf34211 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -4780,7 +4780,7 @@ static void ast_rtp_prop_set(struct ast_rtp_instance *instance, enum ast_rtp_pro return; } else { if (rtp->rtcp) { - if (rtp->rtcp->schedid > 0) { + if (rtp->rtcp->schedid > -1) { if (!ast_sched_del(rtp->sched, rtp->rtcp->schedid)) { /* Successfully cancelled scheduler entry. */ ao2_ref(instance, -1); @@ -4997,7 +4997,7 @@ static void ast_rtp_stop(struct ast_rtp_instance *instance) } #endif - if (rtp->rtcp && rtp->rtcp->schedid > 0) { + if (rtp->rtcp && rtp->rtcp->schedid > -1) { if (!ast_sched_del(rtp->sched, rtp->rtcp->schedid)) { /* successfully cancelled scheduler entry. */ ao2_ref(instance, -1); |