[Core] Add PRE_CLOSED flag on file handle, add unit test.

This commit is contained in:
Dragos Oancea
2019-11-21 18:02:47 +00:00
committed by Andrey Volk
parent 5274dd1f9c
commit b124b607d7
4 changed files with 140 additions and 3 deletions
+2 -1
View File
@@ -1937,7 +1937,8 @@ typedef enum {
SWITCH_FILE_NOMUX = (1 << 17),
SWITCH_FILE_BREAK_ON_CHANGE = (1 << 18),
SWITCH_FILE_FLAG_VIDEO = (1 << 19),
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20)
SWITCH_FILE_FLAG_VIDEO_EOF = (1 << 20),
SWITCH_FILE_PRE_CLOSED = (1 << 21)
} switch_file_flag_enum_t;
typedef uint32_t switch_file_flag_t;
+4 -1
View File
@@ -915,6 +915,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_pre_close(switch_file_handle_t
}
switch_clear_flag_locked(fh, SWITCH_FILE_OPEN);
switch_set_flag_locked(fh, SWITCH_FILE_PRE_CLOSED);
if (fh->file_interface->file_pre_close) {
status = fh->file_interface->file_pre_close(fh);
@@ -929,10 +930,12 @@ SWITCH_DECLARE(switch_status_t) switch_core_file_close(switch_file_handle_t *fh)
if (switch_test_flag(fh, SWITCH_FILE_OPEN)) {
status = switch_core_file_pre_close(fh);
} else {
} else if (!switch_test_flag(fh, SWITCH_FILE_PRE_CLOSED)) {
return SWITCH_STATUS_FALSE;
}
switch_clear_flag_locked(fh, SWITCH_FILE_PRE_CLOSED);
fh->file_interface->file_close(fh);
if (fh->params) {