mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 19:52:48 +00:00
Merged revisions 37441-37442 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r37441 | kpfleming | 2006-07-12 10:46:56 -0500 (Wed, 12 Jul 2006) | 3 lines fix a case where ast_lock_path() could leave a randomly-named lock file hanging around make ast_unlock_path actually report when unlocking fails ........ r37442 | kpfleming | 2006-07-12 10:53:53 -0500 (Wed, 12 Jul 2006) | 2 lines fix a weird case where a lock file could be left (but would happen almost never) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@37514 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
18
app.c
18
app.c
@@ -931,11 +931,13 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
|
|||||||
start = time(NULL);
|
start = time(NULL);
|
||||||
while (((res = link(fs, s)) < 0) && (errno == EEXIST) && (time(NULL) - start < 5))
|
while (((res = link(fs, s)) < 0) && (errno == EEXIST) && (time(NULL) - start < 5))
|
||||||
usleep(1);
|
usleep(1);
|
||||||
|
|
||||||
|
unlink(fs);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno));
|
ast_log(LOG_WARNING, "Failed to lock path '%s': %s\n", path, strerror(errno));
|
||||||
return AST_LOCK_TIMEOUT;
|
return AST_LOCK_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
unlink(fs);
|
|
||||||
ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
|
ast_log(LOG_DEBUG, "Locked path '%s'\n", path);
|
||||||
return AST_LOCK_SUCCESS;
|
return AST_LOCK_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -944,11 +946,21 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
|
|||||||
int ast_unlock_path(const char *path)
|
int ast_unlock_path(const char *path)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
if (!(s = alloca(strlen(path) + 10)))
|
int res;
|
||||||
|
|
||||||
|
if (!(s = alloca(strlen(path) + 10))) {
|
||||||
|
ast_log(LOG_WARNING, "Out of memory!\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock");
|
snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock");
|
||||||
|
|
||||||
|
if ((res = unlink(s)))
|
||||||
|
ast_log(LOG_ERROR, "Could not unlock path '%s': %s\n", path, strerror(errno));
|
||||||
|
else
|
||||||
ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
|
ast_log(LOG_DEBUG, "Unlocked path '%s'\n", path);
|
||||||
return unlink(s);
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
|
int ast_record_review(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, const char *path)
|
||||||
|
@@ -2651,6 +2651,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
|
|||||||
if (option_debug)
|
if (option_debug)
|
||||||
ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
|
ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
|
||||||
unlink(tmptxtfile);
|
unlink(tmptxtfile);
|
||||||
|
ast_unlock_path(dir);
|
||||||
} else {
|
} else {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
make_file(fn, sizeof(fn), dir, msgnum);
|
make_file(fn, sizeof(fn), dir, msgnum);
|
||||||
|
Reference in New Issue
Block a user