summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorLuigi Rizzo <rizzo@icir.org>2006-04-16 19:05:19 +0000
committerLuigi Rizzo <rizzo@icir.org>2006-04-16 19:05:19 +0000
commite304a986fdb02a44ef32197e64522a3600904134 (patch)
tree37507061a746444092d63a7abd8d99b7a18670bd /res
parentd29f8a677ed463fb5f0d0895660c5601c78e5f95 (diff)
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
Diffstat (limited to 'res')
-rw-r--r--res/res_features.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/res/res_features.c b/res/res_features.c
index d789d7657..90d4a88b4 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -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 */
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 nrfds, nefds;
FD_ZERO(&rfds);
FD_ZERO(&efds);
for (;;) {
- ms = -1;
- max = -1;
+ struct parkeduser *pu, *pl, *pt = NULL;
+ 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);
pl = NULL;
pu = parkinglot;
- FD_ZERO(&nrfds);
- FD_ZERO(&nefds);
while(pu) {
+ int tms; /* timeout for this item */
+ int x; /* fd index in channel */
+ struct ast_context *con;
+
if (pu->notquiteyet) {
/* Pretend this one isn't here yet */
pl = pu;
@@ -1471,6 +1473,7 @@ static void *do_parking_thread(void *ignore)
}
}
if (con) {
+ char returnexten[AST_MAX_EXTENSION];
snprintf(returnexten, sizeof(returnexten), "%s||t", peername);
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);
} else {
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))
ast_set_flag(pu->chan, AST_FLAG_EXCEPTION);
else
@@ -1571,7 +1579,7 @@ static void *do_parking_thread(void *ignore)
}
goto std; /* XXX Ick: jumping into an else statement??? XXX */
}
- }
+
} /* end for */
if (x >= AST_MAX_FDS) {
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);
- cur = parkinglot;
- while(cur) {
+ for (cur = parkinglot; cur; cur = cur->next) {
ast_cli(fd, "%4d %25s (%-15s %-12s %-4d) %6lds\n"
,cur->parkingnum, cur->chan->name, cur->context, cur->exten
,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
- cur = cur->next;
numparked++;
}
ast_cli(fd, "%d parked call%s.\n", numparked, (numparked != 1) ? "s" : "");