Fix crash during CDR update.

The ast_cdr_setcid() and ast_cdr_update() were shown in ASTERISK-18836 to
be called by different threads for the same channel.  The channel driver
thread and the PBX thread running dialplan.

* Add lock protection around CDR API calls that access an ast_channel
pointer.

(closes issue ASTERISK-18836)
Reported by: gpluser

Review: https://reviewboard.asterisk.org/r/1628/
........

Merged revisions 348362 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 348363 from http://svn.asterisk.org/svn/asterisk/branches/10


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@348364 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2011-12-16 21:10:19 +00:00
parent 8baea2b35e
commit b05d4603c4
9 changed files with 109 additions and 30 deletions

View File

@@ -213,6 +213,7 @@ void ast_cdr_discard(struct ast_cdr *cdr);
* \param cdr Call Detail Record to use for channel
* \param chan Channel to bind CDR with
* Initializes a CDR and associates it with a particular channel
* \note The channel should be locked before calling.
* \return 0 by default
*/
int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
@@ -222,6 +223,7 @@ int ast_cdr_init(struct ast_cdr *cdr, struct ast_channel *chan);
* \param cdr Call Detail Record to use for channel
* \param chan Channel to bind CDR with
* Initializes a CDR and associates it with a particular channel
* \note The channel should be locked before calling.
* \return 0 by default
*/
int ast_cdr_setcid(struct ast_cdr *cdr, struct ast_channel *chan);
@@ -414,22 +416,40 @@ char *ast_cdr_flags2str(int flags);
*/
void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from);
/*! \brief Set account code, will generate AMI event */
/*!
* \brief Set account code, will generate AMI event
* \note The channel should be locked before calling.
*/
int ast_cdr_setaccount(struct ast_channel *chan, const char *account);
/*! \brief Set the peer account */
/*!
* \brief Set the peer account
* \note The channel should be locked before calling.
*/
int ast_cdr_setpeeraccount(struct ast_channel *chan, const char *account);
/*! \brief Set AMA flags for channel */
/*!
* \brief Set AMA flags for channel
* \note The channel should be locked before calling.
*/
int ast_cdr_setamaflags(struct ast_channel *chan, const char *amaflags);
/*! \brief Set CDR user field for channel (stored in CDR) */
/*!
* \brief Set CDR user field for channel (stored in CDR)
* \note The channel should be locked before calling.
*/
int ast_cdr_setuserfield(struct ast_channel *chan, const char *userfield);
/*! \brief Append to CDR user field for channel (stored in CDR) */
/*!
* \brief Append to CDR user field for channel (stored in CDR)
* \note The channel should be locked before calling.
*/
int ast_cdr_appenduserfield(struct ast_channel *chan, const char *userfield);
/*! Update CDR on a channel */
/*!
* \brief Update CDR on a channel
* \note The channel should be locked before calling.
*/
int ast_cdr_update(struct ast_channel *chan);