Summary:ASTERISK-00567: [patch] libiax2 in blocking mode bug
Reporter:adam (adam)Labels:
Date Opened:2003-11-23 19:00:07.000-0600Date Closed:2004-09-25 02:53:49
Versions:Frequency of
Environment:Attachments:( 0) iaxpatch.diff
Description:in iax_get_event(), if you request blocking, it blocks until it receives a packet. This is incorrect as it can miss scheduled event. eg A pending event is due in 10 ms but a packet only arrives 30ms later. This causes the pending event to be delayed by 20ms.

in code terms,change this (in iax.c)
select(netfd + 1, &fds, NULL, NULL,NULL);

to this

int nextEventTime = iax_time_to_next_event();

if(nextEventTime < 0)
select(netfd + 1, &fds, NULL, NULL,NULL);
struct timeval nextEvent;

nextEvent.tv_sec = nextEventTime % 1000;
nextEvent.tv_usec = nextEventTime * 1000;

select(netfd + 1, &fds, NULL, NULL, &nextEvent);
Comments:By: adam (adam) 2003-11-23 19:15:40.000-0600

oops, my milliseconds -> timeval conversion was broken

should have been
nextEvent.tv_sec = nextEventTime / 1000;
nextEvent.tv_usec = (nextEventTime - nextEvent.tv_sec * 1000) * 1000;

use the most recent patch

edited on: 11-23-03 19:11

By: Paul Cadach (pcadach) 2003-11-23 22:53:33.000-0600

Hm-m-m... Usually in Asterisk's internals milliseconds->timeval conversion does by:
nextEvent.tv_sec = nextEventTime / 1000;
nextEvent.tv_usec = (nextEventTime % 1000) * 1000;

By: adam (adam) 2003-11-23 23:15:09.000-0600

yea, that looks nicer (mines faster though :p) - can't be bothered changing the patch again :)

By: Brian West (bkw918) 2003-11-24 18:49:19.000-0600

This doesn't apply can you re-submit a new diff against lastest CVS of libiax2?

By: adam (adam) 2003-11-24 18:54:58.000-0600

that's what the second file (well now the only file) does

By: Brian West (bkw918) 2003-11-24 19:57:53.000-0600

Yes I removed the old file to cut confusion.

By: Brian West (bkw918) 2003-11-24 20:01:21.000-0600

This patch doesn't apply.  Please regenerate.

patching file src/iax.c
patch unexpectedly ends in middle of line
Hunk #1 FAILED at 2418.
1 out of 1 hunk FAILED -- saving rejects to file src/iax.c.rej

By: adam (adam) 2003-11-24 21:36:40.000-0600

sorry, I copy-pasted from my terminal which seemed to break it (probably tab -> space or something) - i've added another one or alternatively use the link below


By: Mark Spencer (markster) 2004-03-21 16:30:59.000-0600

Fixed in CVS