mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 11:58:40 +00:00
Use new timer interface for timing iax2
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@662 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -3456,11 +3456,23 @@ 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");
|
||||
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 > 0) {
|
||||
if (res < 1) {
|
||||
ast_log(LOG_WARNING, "Unable to read from timing fd\n");
|
||||
ast_pthread_mutex_unlock(&peerl.lock);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/* For each peer that supports trunking... */
|
||||
ast_pthread_mutex_lock(&peerl.lock);
|
||||
peer = peerl.peers;
|
||||
@@ -3476,7 +3488,6 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
|
||||
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,6 +5428,8 @@ int load_module(void)
|
||||
sin.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
#ifdef IAX_TRUNKING
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user