[asterisk-dev] Channel file descriptors
John Martin
John.Martin at AuPix.com
Sun Oct 29 04:42:51 MST 2006
Hi Devs,
I was doing some debugging while integrating t140, into chan_sip, and
found some problems which were being caused by the wrong handlers being
called for the fd I was trying to use. As a result I'd like to propose
an increase to the number of file descriptors but wanted to get some
views on it.
Now, channel.h has the following code:
#define AST_MAX_FDS 8
/*
* We have AST_MAX_FDS file descriptors in a channel.
* Some of them have a fixed use:
*/
#define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe
*/
#define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd
*/
#define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for
pass through */
#define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator
*/
It was obvious what was causing the problem for me (I'd picked fds[4]
for t140) but I also noticed that the t38 stuff in chan_sip uses fds[5]
for its file descriptor, which is equivalent to fds(8-3) i.e.
AST_AGENT_FD. I don't know what might happen if t38 uses the same
descriptor as an agent, perhaps this can't happen at the same time in
the same thread, but sounds like it could cause undetermined behaviour
if someone tried to maybe send a fax to an endpoint that was also logged
in as an agent???
Perhaps AST_MAX_FDS should be increased, to say 10, which would take
AST_AGENT_FD out of the way of t38, and is what I've done for my t140
support, since I also need more fds.
It might also be a good idea to define the FDs as, for instance:
#define AST_MAX_FDS 10
/*
* We have AST_MAX_FDS file descriptors in a channel.
* Some of them have a fixed use:
*/
#define AST_CHANNEL_FD0 (0) /*!< used by
channel */
#define AST_CHANNEL_FD1 (1) /*!< used by
channel */
#define AST_CHANNEL_FD2 (2) /*!< used by
channel */
#define AST_CHANNEL_FD3 (3) /*!< used by
channel */
#define AST_CHANNEL_FD4 (4) /*!< used by
channel */
#define AST_CHANNEL_FD5 (5) /*!< used by
channel */
#define AST_ALERT_FD (AST_MAX_FDS-1) /*!< used for alertpipe
*/
#define AST_TIMING_FD (AST_MAX_FDS-2) /*!< used for timingfd
*/
#define AST_AGENT_FD (AST_MAX_FDS-3) /*!< used by agents for
pass through */
#define AST_GENERATOR_FD (AST_MAX_FDS-4) /*!< used by generator
*/
The channel drivers could then have the file descriptors specified using
the AST_CHANNEL_FD0-5 and it would be clear that the descriptors are not
going to be used elsewhere.
Is there any reason why this can't be done?
John
John Martin, AuPix
More information about the asterisk-dev
mailing list