[Asterisk-code-review] Audit improper usage of scheduler exposed by 5c713fdf18f. (v... (asterisk[certified/13.1])
Richard Mudgett
asteriskteam at digium.com
Tue Dec 1 11:51:39 CST 2015
Richard Mudgett has uploaded a new change for review.
https://gerrit.asterisk.org/1739
Change subject: Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)
......................................................................
Audit improper usage of scheduler exposed by 5c713fdf18f. (v13 additions)
chan_sip.c:
* Initialize mwi subscription scheduler ids earlier because of ASTOBJ to
ao2 conversion.
* Initialize register scheduler ids earlier because of ASTOBJ to ao2
conversion.
chan_skinny.c:
* Fix more scheduler usage for the valid 0 id value.
ASTERISK-25476
Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95
---
M channels/chan_sip.c
M channels/chan_skinny.c
2 files changed, 26 insertions(+), 13 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/39/1739/1
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index c3e775d..9844fa9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -9394,6 +9394,9 @@
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;
@@ -9467,6 +9470,8 @@
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;
@@ -9481,7 +9486,6 @@
}
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 b68a84d..72a53fa 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -1365,6 +1365,12 @@
/* 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 @@
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){
@@ -5583,6 +5589,7 @@
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 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
{
@@ -7427,7 +7432,7 @@
{
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 @@
{
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 @@
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 @@
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);
--
To view, visit https://gerrit.asterisk.org/1739
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If9f0e5d99638b2f9d102d1ebc9c5a14b2d706e95
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: certified/13.1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
More information about the asterisk-code-review
mailing list