diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-20 14:07:17 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2003-03-20 14:07:17 +0000 |
commit | e7d2472e11382a238d3e07404001917c441a211d (patch) | |
tree | 8c50d60457db0d948b621a5c57729e00df56d5df /channels | |
parent | 6ff1dd3a9faf381313fd257e8c59278fae163c0d (diff) |
Use new timer interface for timing iax2
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@662 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-x | channels/chan_iax2.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index b5212d381..8af5c6751 100755 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -3456,27 +3456,38 @@ static int timing_read(int *id, int fd, short events, void *cbdata) struct iax2_peer *peer; int processed = 0; int totalcalls = 0; + int x = -1; if (iaxtrunkdebug) ast_verbose("Beginning trunk processing\n"); - /* Read and ignore from the pseudo channel for timing */ - res = read(fd, buf, sizeof(buf)); - if (res > 0) { - /* For each peer that supports trunking... */ - ast_pthread_mutex_lock(&peerl.lock); - peer = peerl.peers; - while(peer) { - if (peer->trunk) { - processed++; - res = send_trunk(peer); - if (iaxtrunkdebug) - ast_verbose("Processed trunk peer '%s' with %d call(s)\n", peer->name, res); - totalcalls += res; - res = 0; - } - peer = peer->next; + if (events & AST_IO_PRI) { + /* Great, this is a timing interface, just call the ioctl */ + if (ioctl(fd, ZT_TIMERACK, x)) + ast_log(LOG_WARNING, "Unable to acknowledge zap timer\n"); + res = 0; + } else { + /* Read and ignore from the pseudo channel for timing */ + res = read(fd, buf, sizeof(buf)); + if (res < 1) { + ast_log(LOG_WARNING, "Unable to read from timing fd\n"); + ast_pthread_mutex_unlock(&peerl.lock); + return 1; } - ast_pthread_mutex_unlock(&peerl.lock); } + /* For each peer that supports trunking... */ + ast_pthread_mutex_lock(&peerl.lock); + peer = peerl.peers; + while(peer) { + if (peer->trunk) { + processed++; + res = send_trunk(peer); + if (iaxtrunkdebug) + ast_verbose("Processed trunk peer '%s' with %d call(s)\n", peer->name, res); + totalcalls += res; + res = 0; + } + peer = peer->next; + } + ast_pthread_mutex_unlock(&peerl.lock); if (iaxtrunkdebug) ast_verbose("Ending trunk processing with %d peers and %d calls processed\n", processed, totalcalls); iaxtrunkdebug =0; @@ -4522,7 +4533,7 @@ static void *network_thread(void *ignore) /* Establish I/O callback for socket read */ ast_io_add(io, netsocket, socket_read, AST_IO_IN, NULL); if (timingfd > -1) - ast_io_add(io, timingfd, timing_read, AST_IO_IN, NULL); + ast_io_add(io, timingfd, timing_read, AST_IO_IN | AST_IO_PRI, NULL); for(;;) { /* Go through the queue, sending messages which have not yet been sent, and scheduling retransmissions if appropriate */ @@ -4880,7 +4891,8 @@ static void set_timing(void) #ifdef IAX_TRUNKING int bs = trunkfreq * 8; if (timingfd > -1) { - if (ioctl(timingfd, ZT_SET_BLOCKSIZE, &bs)) + if (ioctl(timingfd, ZT_TIMERCONFIG, &bs) && + ioctl(timingfd, ZT_SET_BLOCKSIZE, &bs)) ast_log(LOG_WARNING, "Unable to set blocksize on timing source\n"); } #endif @@ -5416,7 +5428,9 @@ int load_module(void) sin.sin_addr.s_addr = INADDR_ANY; #ifdef IAX_TRUNKING - timingfd = open("/dev/zap/pseudo", O_RDWR); + timingfd = open("/dev/zap/timer", O_RDWR); + if (timingfd < 0) + timingfd = open("/dev/zap/pseudo", O_RDWR); if (timingfd < 0) ast_log(LOG_WARNING, "Unable to open IAX timing interface: %s\n", strerror(errno)); #endif |