struct sched_param sched;
memset(&sched, 0, sizeof(sched));
#ifdef __linux__
+#undef sched_setscheduler
if (pri) {
sched.sched_priority = 10;
if (sched_setscheduler(0, SCHED_RR, &sched)) {
ast_verbose("Set to realtime thread\n");
} else {
sched.sched_priority = 0;
- if (sched_setscheduler(0, SCHED_OTHER, &sched)) {
- ast_log(LOG_WARNING, "Unable to set normal priority\n");
- return -1;
- }
+ /* According to the manpage, this can never fail, with these parameters. */
+ sched_setscheduler(0, SCHED_OTHER, &sched);
}
#else
+#undef setpriority
if (pri) {
if (setpriority(PRIO_PROCESS, 0, -10) == -1) {
ast_log(LOG_WARNING, "Unable to set high priority\n");
if (option_verbose)
ast_verbose("Set to high priority\n");
} else {
- if (setpriority(PRIO_PROCESS, 0, 0) == -1) {
- ast_log(LOG_WARNING, "Unable to set normal priority\n");
- return -1;
- }
+ /* According to the manpage, this can never fail, with these parameters. */
+ setpriority(PRIO_PROCESS, 0, 0);
}
#endif
return 0;
res = local_queue_frame(p, isoutbound, &answer, ast);
} else
ast_log(LOG_WARNING, "Huh? Local is being asked to answer?\n");
- ast_mutex_unlock(&p->lock);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
return res;
}
ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
res = 0;
}
- ast_mutex_unlock(&p->lock);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
return res;
}
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
f.subclass = condition;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
ast_mutex_lock(&p->lock);
isoutbound = IS_OUTBOUND(ast, p);
f.subclass = digit;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
f.subclass = subclass;
f.data = (char *)data;
f.datalen = datalen;
- res = local_queue_frame(p, isoutbound, &f, ast);
- ast_mutex_unlock(&p->lock);
+ if (!(res = local_queue_frame(p, isoutbound, &f, ast)))
+ ast_mutex_unlock(&p->lock);
return res;
}
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
struct local_pvt *cur, *prev=NULL;
struct ast_channel *ochan = NULL;
- int glaredetect;
+ int glaredetect, res = 0;
if (!p)
return -1;
/* Need to actually hangup since there is no PBX */
ochan = p->chan;
else
- local_queue_frame(p, isoutbound, &f, NULL);
- ast_mutex_unlock(&p->lock);
+ res = local_queue_frame(p, isoutbound, &f, NULL);
+ if (!res)
+ ast_mutex_unlock(&p->lock);
if (ochan)
ast_hangup(ochan);
return 0;