[asterisk-dev] select() and friends in Asterisk limit fd usage to 1024

Atis Lezdins atis at iq-labs.net
Thu Oct 15 10:10:24 CDT 2009


On Thu, Oct 15, 2009 at 12:04 AM, Moises Silva <moises.silva at gmail.com> wrote:
> Howdy,
> I have been testing an Asterisk module that creates lots of RTP sessions,
> therefore consuming lots of file descriptors. I had been using Asterisk
> 1.6.1.6 for that. At some point after exceeding 1024 file descriptors,
> several threads in Asterisk start using a lot of cpu. I started digging and
> I have reasons ( live stack traces point to that ) to think the problem is
> due to res/res_timing_pthread.c using select in read_pipe().
> According to "man 2 select", executing FD_SET in a file descriptor negative,
> equal or larger than FD_SETSIZE (which is 1024 typically), results in
> undefined behavior. In the past in other systems I have seen that is pretty
> common to end up eating lots of cpu when select() keeps returning one or
> more file descriptors as ready when they are really not, due to fd_set
> overflow.
> I was pretty much in a hurry and just downgraded to 1.4 to continue running
> the testing, 1.4 seems to work fine (which seems to confirm my
> res_timing_pthread.c hypothesis).
> To fix this problem I see 2 possibilities. Either we get rid completely of
> select when poll is available (which is supposed to be a bit slower than
> select) or we to add a new compilation flag to allow users to decide,
> something like LOTS_OF_FDS, in such cases Asterisk would simply not use
> select and use poll in ast_select, and any place where select() is hard
> coded should be moved to use ast_select or some other wrapper.
> Thoughts?

Hi Moses,

I've been experiencing some memory/cpu issues with res_timing_pthread,
and there is an open issue about that:
https://issues.asterisk.org/view.php?id=15973

I wonder if You could test this with 1.6.1.6 and res_timing_dahdi instead?

If this is the cause, I would be glad to see it fixed, but for now i'm
fine with using DAHDI's dummy timing source.

Regards,
Atis

-- 
Atis Lezdins,
VoIP Project Manager / Developer,
IQ Labs Inc,
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Cell Phone: +1 800 7300689
Work phone: +1 800 7502835



More information about the asterisk-dev mailing list