[asterisk-dev] Asterisk and file descriptors

Daniel Ferrer daniel at ipcontact.com.uy
Wed Oct 15 16:26:22 CDT 2008

We've experiencing some time ago somewhat what seems a file descriptor 
problem, sometimes we get this message:

[2008-10-15 17:57:34] WARNING[29952] format_wav.c: Unable to find our 

Another "flavours" of this warning also appears ("Unable to set/seek our 
position"), all related with a seek in a .wav file. The installation 
uses Asterisk 1.4.22, and have a lot of Queues that records incoming IAX 
calls via MixMonitor, (wav format) and Playback some .wav files.
I added some "debug" code, to print ftello/fseek error message in 
format_wav.c (added a "strerror(errno)" to ast_log) and error message 
varies: "Bad file descriptor", "Illegal seek", "Invalid argument". This 
happened since rev 138685, or before (maybe in 1.4.21 also, not sure).

The problem is that sometimes this occurs a lot, load average gets too 
high (>100) and machine gets unresponsive (if asterisk runs with 
realtime priority), with consecuent call degradation, etc. If I manually 
"soft hangup" these channels (those that triggers "Unable to find our 
position" warning), the machine goes to "normal" state, with a 
reasonable load, and system continues ok.

I tracked some time ago this issue, but seems that the amount of file 
descriptors is ok. If I do "ls -l /proc/PID/fd | wc -l" I get normally 
400-500 fd's. Looking at safe_asterisk's code, when there is no ulimit 
-n, it configures max open files to half of value in 
/proc/sys/fs/file-max, which is 103152 in our case, so this doesn't 
seems an issue.
Also seems that when this error is triggered, there's and audiohook 
message complaing of write/read factory:

2008-10-15 09:13:19] DEBUG[5728] audiohook.c: Failed to get 160 samples 
from write factory 0x844eed4
[2008-10-15 09:13:19] WARNING[5728] format_wav.c: Unable to find our 

The machine is a Quad Xeon 2.0Ghz per CPU with 2G RAM and it's running 
kernel 2.6.22 i686.

Any clue or something that I can debug ? I'll appreciate your valuable 


Ing. Daniel Ferrer
IPContact Software S.R.L.
(+5982) 4025420

More information about the asterisk-dev mailing list