mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-04 05:15:22 +00:00 
			
		
		
		
	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:
		@@ -213,14 +213,20 @@ static int auth_exec(struct ast_channel *chan, const char *data)
 | 
			
		||||
						continue;
 | 
			
		||||
					ast_md5_hash(md5passwd, passwd);
 | 
			
		||||
					if (!strcmp(md5passwd, md5secret)) {
 | 
			
		||||
						if (ast_test_flag(&flags,OPT_ACCOUNT))
 | 
			
		||||
						if (ast_test_flag(&flags,OPT_ACCOUNT)) {
 | 
			
		||||
							ast_channel_lock(chan);
 | 
			
		||||
							ast_cdr_setaccount(chan, buf);
 | 
			
		||||
							ast_channel_unlock(chan);
 | 
			
		||||
						}
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				} else {
 | 
			
		||||
					if (!strcmp(passwd, buf)) {
 | 
			
		||||
						if (ast_test_flag(&flags, OPT_ACCOUNT))
 | 
			
		||||
						if (ast_test_flag(&flags, OPT_ACCOUNT)) {
 | 
			
		||||
							ast_channel_lock(chan);
 | 
			
		||||
							ast_cdr_setaccount(chan, buf);
 | 
			
		||||
							ast_channel_unlock(chan);
 | 
			
		||||
						}
 | 
			
		||||
						break;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
@@ -242,8 +248,11 @@ static int auth_exec(struct ast_channel *chan, const char *data)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if ((retries < 3) && !res) {
 | 
			
		||||
		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE))
 | 
			
		||||
		if (ast_test_flag(&flags,OPT_ACCOUNT) && !ast_test_flag(&flags,OPT_MULTIPLE)) {
 | 
			
		||||
			ast_channel_lock(chan);
 | 
			
		||||
			ast_cdr_setaccount(chan, passwd);
 | 
			
		||||
			ast_channel_unlock(chan);
 | 
			
		||||
		}
 | 
			
		||||
		if (!(res = ast_streamfile(chan, "auth-thankyou", chan->language)))
 | 
			
		||||
			res = ast_waitstream(chan, "");
 | 
			
		||||
	} else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user