Index: channels/chan_iax2.c =================================================================== --- channels/chan_iax2.c (revision 48358) +++ channels/chan_iax2.c (working copy) @@ -488,7 +488,7 @@ /*! Next outgoing timestamp if everything is good */ unsigned int nextpred; /*! True if the last voice we transmitted was not silence/CNG */ - int notsilenttx; + unsigned int notsilenttx:1; /*! Ping time */ unsigned int pingtime; /*! Max time for initial response */ @@ -770,9 +770,42 @@ ast_verbose(buf); } -/* XXX We probably should use a mutex when working with this XXX */ +/*! + * \brief an array of iax2 pvt structures + * + * The container for active chan_iax2_pvt strucutures is implemented as an + * array for extremely quick direct access to the correct pvt strucuture + * based on the local call number. The local call number is used as the + * index into the array where the associated pvt structure is stored. + */ static struct chan_iax2_pvt *iaxs[IAX_MAX_CALLS]; +/*! + * \brief chan_iax2_pvt strucuture locks + * + * These locks are used when accessing a pvt strucuture in the iaxs array. + * The index used here is the same as used in the iaxs array. It is the + * local call number for the associated pvt struct. + */ static ast_mutex_t iaxsl[IAX_MAX_CALLS]; +/*! + * \brief The last time a call number was used + * + * It is important to know the last time that a call number was used locally so + * that it is not used again too soon. The reason for this is the same as the + * reason that the TCP protocol state machine requires a "TIME WAIT" state. + * + * For example, say that a call is up. Then, the remote side sends a HANGUP, + * which we respond to with an ACK. However, there is no way to know whether + * the ACK made it there successfully. If it were to get lost, the remote + * side may retransmit the HANGUP. If in the meantime, this call number has + * been reused locally, given the right set of circumstances, this retransmitted + * HANGUP could potentially improperly hang up the new session. So, to avoid + * this potential issue, we must wait a specified timeout period before reusing + * a local call number. + * + * The specified time that we must wait before reusing a local call number is + * defined as MIN_REUSE_TIME, with a default of 60 seconds. + */ static struct timeval lastused[IAX_MAX_CALLS]; static enum ast_bridge_result iax2_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);