diff options
author | dhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-12 20:24:24 +0000 |
---|---|---|
committer | dhubbard <dhubbard@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-12 20:24:24 +0000 |
commit | 1e36d1986b6a425ffd2d80cb9b1a72ca6c9ca587 (patch) | |
tree | 20ccd6548f02597b874db26aab45c473c3356954 /apps | |
parent | 9083e9bf0b5f6aa5cdbb18a1997870eb549bd74e (diff) |
remove a race condition for the creation of recordthread's, and fix a small memory leak. This closes issue# 10636
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@82286 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_meetme.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c index f1a7bcdec..3da5eaf89 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -331,6 +331,7 @@ struct ast_conference { unsigned int isdynamic:1; /*!< Created on the fly? */ unsigned int locked:1; /*!< Is the conference locked? */ pthread_t recordthread; /*!< thread for recording */ + ast_mutex_t recordthreadlock; /*!< control threads trying to start recordthread */ pthread_attr_t attr; /*!< thread attribute */ const char *recordingfilename; /*!< Filename to record the Conference into */ const char *recordingformat; /*!< Format to record the Conference in */ @@ -757,6 +758,8 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin ast_mutex_init(&cnf->playlock); ast_mutex_init(&cnf->listenlock); + cnf->recordthread = AST_PTHREADT_NULL; + ast_mutex_init(&cnf->recordthreadlock); ast_copy_string(cnf->confno, confno, sizeof(cnf->confno)); ast_copy_string(cnf->pin, pin, sizeof(cnf->pin)); ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin)); @@ -1253,7 +1256,10 @@ static int conf_free(struct ast_conference *conf) ast_hangup(conf->chan); else close(conf->fd); - + + ast_mutex_destroy(&conf->playlock); + ast_mutex_destroy(&conf->listenlock); + ast_mutex_destroy(&conf->recordthreadlock); free(conf); return 0; @@ -1429,7 +1435,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c } } - if ((conf->recording == MEETME_RECORD_OFF) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("zap", AST_FORMAT_SLINEAR, "pseudo", NULL)))) { + ast_mutex_lock(&conf->recordthreadlock); + if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("zap", AST_FORMAT_SLINEAR, "pseudo", NULL)))) { ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR); ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR); ztc.chan = 0; @@ -1446,6 +1453,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c pthread_attr_destroy(&conf->attr); } } + ast_mutex_unlock(&conf->recordthreadlock); time(&user->jointime); |