Fix resource leak in Subfiling example programs and tests (#5617)

This commit is contained in:
jhendersonHDF
2025-06-20 06:54:37 -05:00
committed by GitHub
parent 0743df227f
commit 51dd7758fe
5 changed files with 19 additions and 0 deletions
+2
View File
@@ -314,6 +314,7 @@ subfiling_write_custom(hid_t fapl_id, int mpi_size, int mpi_rank)
cleanup(EXAMPLE_FILE2, subfiling_fapl);
H5Pclose(subf_config.ioc_fapl_id);
H5Pclose(subfiling_fapl);
}
@@ -484,6 +485,7 @@ subfiling_write_precreate(hid_t fapl_id, int mpi_size, int mpi_rank)
cleanup(EXAMPLE_FILE3, subfiling_fapl);
H5Pclose(subf_config.ioc_fapl_id);
H5Pclose(subfiling_fapl);
}
@@ -290,6 +290,7 @@ CONTAINS
CALL cleanup(EXAMPLE_FILE, subfiling_fapl)
CALL H5Pclose_f(subf_config%ioc_fapl_id, status)
CALL H5Pclose_f(subfiling_fapl, status)
END SUBROUTINE subfiling_write_custom
@@ -457,6 +458,7 @@ CONTAINS
CALL cleanup(EXAMPLE_FILE, subfiling_fapl)
CALL H5Pclose_f(subf_config%ioc_fapl_id, status)
CALL H5Pclose_f(subfiling_fapl, status)
END SUBROUTINE subfiling_write_precreate
+6
View File
@@ -396,6 +396,12 @@ H5_DLL herr_t H5Pset_fapl_subfiling(hid_t fapl_id, const H5FD_subfiling_config_t
* the default values and then calling H5Pset_fapl_subfiling() with the configured
* H5FD_subfiling_config_t structure.
*
* The `ioc_fapl_id` field of the returned structure will be the ID of a copied or
* newly-created property list which should be closed with H5Pclose() when the
* configuration structure is no longer in use. An application should also be sure to
* close this property list ID first if a different property list ID will be assigned
* to the `ioc_fapl_id` field.
*
* \note H5Pget_fapl_subfiling() returns the #H5FD_SUBFILING driver properties as they
* were initially set for the File Access Property List using H5Pset_fapl_subfiling().
* Alternatively, the driver properties can be modified at runtime according to values
+3
View File
@@ -182,6 +182,9 @@ create_subfiling_ioc_fapl(MPI_Comm comm, MPI_Info info, bool custom_config,
if (H5Pset_fapl_subfiling(ret_value, &subfiling_conf) < 0)
TEST_ERROR;
if (H5Pclose(subfiling_conf.ioc_fapl_id < 0))
TEST_ERROR;
}
return ret_value;
+6
View File
@@ -477,6 +477,12 @@ setup_vfd_test_file(int file_name_id, char *file_name, int mpi_size, H5FD_mpio_x
}
/* Assign the IOC fapl as the underlying VPD */
if ((pass) && (H5Pclose(subfiling_conf.ioc_fapl_id) == FAIL)) {
pass = false;
failure_mssg = "Can't close default IOC FAPL.";
}
subfiling_conf.ioc_fapl_id = ioc_fapl;
/* Now we can set the SUBFILING fapl before returning. */