diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 7d962e2a78b03eefcf4bdd426492877a80aebbc1..be5afa6ac099e82df3b8373663c03dcd2b9da431 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -2221,6 +2221,14 @@ static struct chan_iax2_pvt *new_iax(struct ast_sockaddr *addr, const char *host return NULL; } + tmp->pingid = -1; + tmp->lagid = -1; + tmp->autoid = -1; + tmp->authid = -1; + tmp->initid = -1; + tmp->keyrotateid = -1; + tmp->jbid = -1; + if (ast_string_field_init(tmp, 32)) { ao2_ref(tmp, -1); tmp = NULL; @@ -2228,18 +2236,11 @@ static struct chan_iax2_pvt *new_iax(struct ast_sockaddr *addr, const char *host } tmp->prefs = prefs_global; - tmp->pingid = -1; - tmp->lagid = -1; - tmp->autoid = -1; - tmp->authid = -1; - tmp->initid = -1; - tmp->keyrotateid = -1; ast_string_field_set(tmp,exten, "s"); ast_string_field_set(tmp,host, host); tmp->jb = jb_new(); - tmp->jbid = -1; jbconf.max_jitterbuf = maxjitterbuffer; jbconf.resync_threshold = resyncthreshold; jbconf.max_contig_interp = maxjitterinterps; diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 5f38e4dcc926fef5ce3e097094193ab130af7c77..9844fa96280b8d3e8eb50ba01d3e254deed5a5ee 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1706,6 +1706,7 @@ static int publish_expire(const void *data) ast_assert(esc != NULL); ao2_unlink(esc->compositor, esc_entry); + esc_entry->sched_id = -1; ao2_ref(esc_entry, -1); return 0; } @@ -1738,6 +1739,11 @@ static struct sip_esc_entry *create_esc_entry(struct event_state_compositor *esc /* Bump refcount for scheduler */ ao2_ref(esc_entry, +1); esc_entry->sched_id = ast_sched_add(sched, expires_ms, publish_expire, esc_entry); + if (esc_entry->sched_id == -1) { + ao2_ref(esc_entry, -1); + ao2_ref(esc_entry, -1); + return NULL; + } /* Note: This links the esc_entry into the ESC properly */ create_new_sip_etag(esc_entry, 0); @@ -9388,6 +9394,9 @@ static int sip_register(const char *value, int lineno) return -1; } + reg->expire = -1; + reg->timeout = -1; + if (ast_string_field_init(reg, 256)) { ao2_t_ref(reg, -1, "failed to string_field_init, drop reg"); return -1; @@ -9461,6 +9470,8 @@ static int sip_subscribe_mwi(const char *value, int lineno) return -1; } + mwi->resub = -1; + if (ast_string_field_init(mwi, 256)) { ao2_t_ref(mwi, -1, "failed to string_field_init, drop mwi"); return -1; @@ -9475,7 +9486,6 @@ static int sip_subscribe_mwi(const char *value, int lineno) } ast_string_field_set(mwi, hostname, hostname); ast_string_field_set(mwi, mailbox, mailbox); - mwi->resub = -1; mwi->portno = portnum; mwi->transport = transport; diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 499a7ef307a8fa5163287f69a10d9ad148d72415..72a53fa18cfd0a4f143ac30eb13ad30f11795374 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -1365,6 +1365,12 @@ static int gendigittimeout = 8000; /* How long to wait for an extra digit, if there is an ambiguous match */ static int matchdigittimeout = 3000; +/*! + * To apease the stupid compiler option on ast_sched_del() + * since we don't care about the return value. + */ +static int not_used; + #define SUBSTATE_UNSET 0 #define SUBSTATE_OFFHOOK 1 #define SUBSTATE_ONHOOK 2 @@ -2264,10 +2270,10 @@ static int skinny_register(struct skinny_req *req, struct skinnysession *s) int instance; int res = -1; - if (s->auth_timeout_sched && ast_sched_del(sched, s->auth_timeout_sched)) { - return 0; + if (-1 < s->auth_timeout_sched) { + not_used = ast_sched_del(sched, s->auth_timeout_sched); + s->auth_timeout_sched = -1; } - s->auth_timeout_sched = 0; AST_LIST_LOCK(&devices); AST_LIST_TRAVERSE(&devices, d, list){ @@ -5560,12 +5566,12 @@ static void setsubstate(struct skinny_subchannel *sub, int state) skinny_locksub(sub); - if (sub->dialer_sched) { + if (-1 < sub->dialer_sched) { skinny_sched_del(sub->dialer_sched, sub); sub->dialer_sched = -1; } - if (state != SUBSTATE_RINGIN && sub->aa_sched) { + if (state != SUBSTATE_RINGIN && -1 < sub->aa_sched) { skinny_sched_del(sub->aa_sched, sub); sub->aa_sched = -1; sub->aa_beep = 0; @@ -5583,6 +5589,7 @@ static void setsubstate(struct skinny_subchannel *sub, int state) sub->cfwd_sched = -1; } else if (state == SUBSTATE_ONHOOK) { skinny_sched_del(sub->cfwd_sched, sub); + sub->cfwd_sched = -1; } } @@ -6182,9 +6189,7 @@ static int handle_ip_port_message(struct skinny_req *req, struct skinnysession * static void handle_keepalive_message(struct skinny_req *req, struct skinnysession *s) { - if (ast_sched_del(sched, s->keepalive_timeout_sched)) { - return; - } + not_used = ast_sched_del(sched, s->keepalive_timeout_sched); #ifdef AST_DEVMODE { @@ -6250,7 +6255,7 @@ static int handle_keypad_button_message(struct skinny_req *req, struct skinnyses } if ((sub->owner && ast_channel_state(sub->owner) < AST_STATE_UP)) { - if (sub->dialer_sched && !skinny_sched_del(sub->dialer_sched, sub)) { + if (-1 < sub->dialer_sched && !skinny_sched_del(sub->dialer_sched, sub)) { SKINNY_DEBUG(DEBUG_SUB, 3, "Sub %u - Got a digit and not timed out, so try dialing\n", sub->callid); sub->dialer_sched = -1; len = strlen(sub->exten); @@ -7087,7 +7092,7 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse case SOFTKEY_BKSPC: SKINNY_DEBUG(DEBUG_PACKET, 3, "Received SOFTKEY_BKSPC from %s, inst %d, callref %d\n", d->name, instance, callreference); - if (sub->dialer_sched && !skinny_sched_del(sub->dialer_sched, sub)) { + if (-1 < sub->dialer_sched && !skinny_sched_del(sub->dialer_sched, sub)) { size_t len; sub->dialer_sched = -1; len = strlen(sub->exten); @@ -7427,7 +7432,7 @@ static int skinny_noauth_cb(const void *data) { struct skinnysession *s = (struct skinnysession *)data; ast_log(LOG_WARNING, "Skinny Client failed to authenticate in %d seconds (SCHED %d)\n", auth_timeout, s->auth_timeout_sched); - s->auth_timeout_sched = 0; + s->auth_timeout_sched = -1; end_session(s); return 0; } @@ -7436,7 +7441,7 @@ static int skinny_nokeepalive_cb(const void *data) { struct skinnysession *s = (struct skinnysession *)data; ast_log(LOG_WARNING, "Skinny Client failed to send keepalive in last %d seconds (SCHED %d)\n", keep_alive*3, s->keepalive_timeout_sched); - s->keepalive_timeout_sched = 0; + s->keepalive_timeout_sched = -1; end_session(s); return 0; } @@ -7454,11 +7459,13 @@ static void skinny_session_cleanup(void *data) ast_mutex_unlock(&s->lock); } - if (s->auth_timeout_sched && !ast_sched_del(sched, s->auth_timeout_sched)) { - s->auth_timeout_sched = 0; + if (-1 < s->auth_timeout_sched) { + not_used = ast_sched_del(sched, s->auth_timeout_sched); + s->auth_timeout_sched = -1; } - if (s->keepalive_timeout_sched && !ast_sched_del(sched, s->keepalive_timeout_sched)) { - s->keepalive_timeout_sched = 0; + if (-1 < s->keepalive_timeout_sched) { + not_used = ast_sched_del(sched, s->keepalive_timeout_sched); + s->keepalive_timeout_sched = -1; } if (d) { @@ -7661,6 +7668,8 @@ static void *accept_thread(void *ignore) ast_mutex_init(&s->lock); memcpy(&s->sin, &sin, sizeof(sin)); s->fd = as; + s->auth_timeout_sched = -1; + s->keepalive_timeout_sched = -1; if (ast_pthread_create(&s->t, NULL, skinny_session, s)) { destroy_session(s); diff --git a/channels/sip/config_parser.c b/channels/sip/config_parser.c index d48ff08dd022067a1b1318a92134c65ca6889594..50495427ed8c65769f0b85befbc94a728aaed850 100644 --- a/channels/sip/config_parser.c +++ b/channels/sip/config_parser.c @@ -79,13 +79,17 @@ int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const AST_APP_ARG(port); ); - if (!value) { + if (!reg) { return -1; } - if (!reg) { + reg->expire = -1; + reg->timeout = -1; + + if (!value) { return -1; } + ast_copy_string(buf, value, sizeof(buf)); /*! register => [peer?][transport://]user[@domain][:secret[:authuser]]@host[:port][/extension][~expiry] @@ -261,7 +265,6 @@ int sip_parse_register_line(struct sip_registry *reg, int default_expiry, const ast_string_field_set(reg, regdomain, ast_strip_quoted(S_OR(user2.domain, ""), "\"", "\"")); reg->transport = transport; - reg->timeout = reg->expire = -1; reg->portno = portnum; reg->regdomainport = domainport; reg->callid_valid = FALSE; diff --git a/main/channel.c b/main/channel.c index 4c1b20660b0a45111d70ff8d416ed464ec4f4a05..6e5132f7bff516a731fd7717d20bf4696058f146 100644 --- a/main/channel.c +++ b/main/channel.c @@ -873,6 +873,7 @@ __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char ast_channel_hold_state_set(tmp, AST_CONTROL_UNHOLD); ast_channel_streamid_set(tmp, -1); + ast_channel_vstreamid_set(tmp, -1); ast_channel_fin_set(tmp, global_fin); ast_channel_fout_set(tmp, global_fout); diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 097e4de23ce36e70441245914e022d02f3fd2086..5875aaecaf954fb55c31fcdb008f2f775fdadea2 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -3265,6 +3265,7 @@ static int dundi_send(struct dundi_transaction *trans, int cmdresp, int flags, i pack = ast_calloc(1, len); if (pack) { pack->h = (struct dundi_hdr *)(pack->data); + pack->retransid = -1; if (cmdresp != DUNDI_COMMAND_ACK) { pack->retransid = ast_sched_add(sched, trans->retranstimer, dundi_rexmit, pack); pack->retrans = DUNDI_DEFAULT_RETRANS - 1;