mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
Merge "Further fixes to improper usage of scheduler"
This commit is contained in:
@@ -7101,7 +7101,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);
|
||||
@@ -7133,8 +7133,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;
|
||||
|
@@ -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"));
|
||||
@@ -21412,7 +21412,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");
|
||||
@@ -30257,13 +30257,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;
|
||||
@@ -30348,6 +30346,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));
|
||||
@@ -30468,6 +30470,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 */
|
||||
|
@@ -4779,7 +4779,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);
|
||||
@@ -4996,7 +4996,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);
|
||||
|
Reference in New Issue
Block a user