|
|
@ -1167,11 +1167,13 @@ enum AST_LOCK_RESULT ast_lock_path(const char *path)
|
|
|
|
time(&start);
|
|
|
|
time(&start);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1180,12 +1182,22 @@ 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;
|
|
|
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
|
|
|
|
s = alloca(strlen(path) + 10);
|
|
|
|
s = alloca(strlen(path) + 10);
|
|
|
|
if (!s)
|
|
|
|
if (!s) {
|
|
|
|
|
|
|
|
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)
|
|
|
|