more readability fixes - localize some variables and invert
a condition in an 'if' statement to reduce the nesting depth. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20623 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
d29f8a677e
commit
e304a986fd
1 changed files with 25 additions and 19 deletions
|
@ -1423,29 +1423,31 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
|
||||||
/*! \brief Take care of parked calls and unpark them if needed */
|
/*! \brief Take care of parked calls and unpark them if needed */
|
||||||
static void *do_parking_thread(void *ignore)
|
static void *do_parking_thread(void *ignore)
|
||||||
{
|
{
|
||||||
int ms, tms, max;
|
|
||||||
struct parkeduser *pu, *pl, *pt = NULL;
|
|
||||||
struct timeval tv;
|
|
||||||
struct ast_frame *f;
|
|
||||||
char exten[AST_MAX_EXTENSION];
|
|
||||||
char *peername,*cp;
|
|
||||||
char returnexten[AST_MAX_EXTENSION];
|
|
||||||
struct ast_context *con;
|
|
||||||
int x;
|
|
||||||
fd_set rfds, efds;
|
fd_set rfds, efds;
|
||||||
fd_set nrfds, nefds;
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_ZERO(&efds);
|
FD_ZERO(&efds);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ms = -1;
|
struct parkeduser *pu, *pl, *pt = NULL;
|
||||||
max = -1;
|
int ms = -1; /* select timeout, uninitialized */
|
||||||
|
int max = -1; /* max fd, none there yet */
|
||||||
|
fd_set nrfds, nefds;
|
||||||
|
|
||||||
|
struct timeval tv;
|
||||||
|
char exten[AST_MAX_EXTENSION];
|
||||||
|
char *peername,*cp;
|
||||||
|
|
||||||
|
FD_ZERO(&nrfds);
|
||||||
|
FD_ZERO(&nefds);
|
||||||
|
|
||||||
ast_mutex_lock(&parking_lock);
|
ast_mutex_lock(&parking_lock);
|
||||||
pl = NULL;
|
pl = NULL;
|
||||||
pu = parkinglot;
|
pu = parkinglot;
|
||||||
FD_ZERO(&nrfds);
|
|
||||||
FD_ZERO(&nefds);
|
|
||||||
while(pu) {
|
while(pu) {
|
||||||
|
int tms; /* timeout for this item */
|
||||||
|
int x; /* fd index in channel */
|
||||||
|
struct ast_context *con;
|
||||||
|
|
||||||
if (pu->notquiteyet) {
|
if (pu->notquiteyet) {
|
||||||
/* Pretend this one isn't here yet */
|
/* Pretend this one isn't here yet */
|
||||||
pl = pu;
|
pl = pu;
|
||||||
|
@ -1471,6 +1473,7 @@ static void *do_parking_thread(void *ignore)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (con) {
|
if (con) {
|
||||||
|
char returnexten[AST_MAX_EXTENSION];
|
||||||
snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
|
snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
|
||||||
ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), FREE, registrar);
|
ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), FREE, registrar);
|
||||||
}
|
}
|
||||||
|
@ -1520,7 +1523,12 @@ static void *do_parking_thread(void *ignore)
|
||||||
free(pt);
|
free(pt);
|
||||||
} else {
|
} else {
|
||||||
for (x = 0; x < AST_MAX_FDS; x++) {
|
for (x = 0; x < AST_MAX_FDS; x++) {
|
||||||
if ((pu->chan->fds[x] > -1) && (FD_ISSET(pu->chan->fds[x], &rfds) || FD_ISSET(pu->chan->fds[x], &efds))) {
|
struct ast_frame *f;
|
||||||
|
|
||||||
|
if (pu->chan->fds[x] < 0 || (!FD_ISSET(pu->chan->fds[x], &rfds) && !FD_ISSET(pu->chan->fds[x], &efds)))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* XXX reindent next block */
|
||||||
if (FD_ISSET(pu->chan->fds[x], &efds))
|
if (FD_ISSET(pu->chan->fds[x], &efds))
|
||||||
ast_set_flag(pu->chan, AST_FLAG_EXCEPTION);
|
ast_set_flag(pu->chan, AST_FLAG_EXCEPTION);
|
||||||
else
|
else
|
||||||
|
@ -1571,7 +1579,7 @@ static void *do_parking_thread(void *ignore)
|
||||||
}
|
}
|
||||||
goto std; /* XXX Ick: jumping into an else statement??? XXX */
|
goto std; /* XXX Ick: jumping into an else statement??? XXX */
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} /* end for */
|
} /* end for */
|
||||||
if (x >= AST_MAX_FDS) {
|
if (x >= AST_MAX_FDS) {
|
||||||
std: for (x=0; x<AST_MAX_FDS; x++) {
|
std: for (x=0; x<AST_MAX_FDS; x++) {
|
||||||
|
@ -1824,13 +1832,11 @@ static int handle_parkedcalls(int fd, int argc, char *argv[])
|
||||||
|
|
||||||
ast_mutex_lock(&parking_lock);
|
ast_mutex_lock(&parking_lock);
|
||||||
|
|
||||||
cur = parkinglot;
|
for (cur = parkinglot; cur; cur = cur->next) {
|
||||||
while(cur) {
|
|
||||||
ast_cli(fd, "%4d %25s (%-15s %-12s %-4d) %6lds\n"
|
ast_cli(fd, "%4d %25s (%-15s %-12s %-4d) %6lds\n"
|
||||||
,cur->parkingnum, cur->chan->name, cur->context, cur->exten
|
,cur->parkingnum, cur->chan->name, cur->context, cur->exten
|
||||||
,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
|
,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
|
||||||
|
|
||||||
cur = cur->next;
|
|
||||||
numparked++;
|
numparked++;
|
||||||
}
|
}
|
||||||
ast_cli(fd, "%d parked call%s.\n", numparked, (numparked != 1) ? "s" : "");
|
ast_cli(fd, "%d parked call%s.\n", numparked, (numparked != 1) ? "s" : "");
|
||||||
|
|
Loading…
Reference in a new issue