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

This commit is contained in:
Dragos Oancea authored and Andrey Volk committed 2019-12-05 21:55:46 +04:00
1 parent 5274dd1f9c
commit b124b607d7
4 files changed
+140 -3

No files matched your search

+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) {