diff options
author | bbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-09-09 18:51:52 +0000 |
---|---|---|
committer | bbryant <bbryant@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-09-09 18:51:52 +0000 |
commit | 722eb3c4c3cfa1c0cee915c949c5f95199ee24dd (patch) | |
tree | 25683963c5e51bdedd6211cd0ea92a85639505c3 /res/res_pktccops.c | |
parent | 815b5b09da5e555add7bba3d8fca588e7611248a (diff) |
Merged revisions 285710 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.6.2
........
r285710 | bbryant | 2010-09-09 14:50:13 -0400 (Thu, 09 Sep 2010) | 8 lines
Fixes an issue with dialplan pattern matching where the specificity for pattern ranges and pattern special characters was inconsistent.
(closes issue #16903)
Reported by: Nick_Lewis
Patches:
pbx.c-specificity.patch uploaded by Nick Lewis (license 657)
Tested by: Nick_Lewis
........
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@285711 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_pktccops.c')
-rw-r--r-- | res/res_pktccops.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/res/res_pktccops.c b/res/res_pktccops.c index 8069e723d..33ecc3817 100644 --- a/res/res_pktccops.c +++ b/res/res_pktccops.c @@ -703,9 +703,8 @@ static void *do_pktccops(void *data) int res, nfds, len; struct copsmsg *recmsg, *sendmsg; struct copsmsg recmsgb, sendmsgb; - fd_set rfds; - struct timeval tv; - struct pktcobj *pobject; + struct pollfd *pfds = NULL, *tmp; + struct pktcobj *pobject; struct cops_cmts *cmts; struct cops_gate *gate; char *sobjp; @@ -719,9 +718,8 @@ static void *do_pktccops(void *data) ast_debug(3, "COPS: thread started\n"); for (;;) { - tv.tv_sec = 1; - tv.tv_usec = 0; - FD_ZERO(&rfds); + ast_free(pfds); + pfds = NULL; nfds = 0; AST_LIST_LOCK(&cmts_list); AST_LIST_TRAVERSE(&cmts_list, cmts, list) { @@ -735,15 +733,27 @@ static void *do_pktccops(void *data) } } if (cmts->sfd > 0) { - FD_SET(cmts->sfd, &rfds); - if (cmts->sfd > nfds) nfds = cmts->sfd; + if (!(tmp = ast_realloc(pfds, (nfds + 1) * sizeof(*pfds)))) { + continue; + } + pfds = tmp; + pfds[nfds].fd = cmts->sfd; + pfds[nfds].events = POLLIN; + pfds[nfds].revents = 0; + nfds++; } else { cmts->sfd = cops_connect(cmts->host, cmts->port); if (cmts->sfd > 0) { cmts->state = 1; if (cmts->sfd > 0) { - FD_SET(cmts->sfd, &rfds); - if (cmts->sfd > nfds) nfds = cmts->sfd; + if (!(tmp = ast_realloc(pfds, (nfds + 1) * sizeof(*pfds)))) { + continue; + } + pfds = tmp; + pfds[nfds].fd = cmts->sfd; + pfds[nfds].events = POLLIN; + pfds[nfds].revents = 0; + nfds++; } } } @@ -781,10 +791,11 @@ static void *do_pktccops(void *data) if (pktcreload == 2) { pktcreload = 0; } - if ((res = select(nfds + 1, &rfds, NULL, NULL, &tv))) { + if ((res = ast_poll(pfds, nfds, 1000))) { AST_LIST_LOCK(&cmts_list); AST_LIST_TRAVERSE(&cmts_list, cmts, list) { - if (FD_ISSET(cmts->sfd, &rfds)) { + int idx; + if ((idx = ast_poll_fd_index(pfds, nfds, cmts->sfd)) > -1 && (pfds[idx].revents & POLLIN)) { len = cops_getmsg(cmts->sfd, recmsg); if (len > 0) { ast_debug(3, "COPS: got from %s:\n Header: versflag=0x%.2x opcode=%i clienttype=0x%.4x msglength=%i\n", |