Skip to content

Commit

Permalink
Merge pull request open-mpi#12416 from jsquyres/pr/mpi-file-mutex-fix
Browse files Browse the repository at this point in the history
file.c: fix uninitialized mutex in MPI_File handle
  • Loading branch information
jsquyres authored Mar 20, 2024
2 parents 42e1cd8 + 2118615 commit e9a0e65
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ompi/file/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
return OMPI_ERR_OUT_OF_RESOURCE;
}

/* Create the mutex */
OBJ_CONSTRUCT(&file->f_lock, opal_mutex_t);

/* Select a module and actually open the file */

if (OMPI_SUCCESS != (ret = mca_io_base_file_select(file, NULL))) {
Expand All @@ -156,9 +153,6 @@ int ompi_file_open(struct ompi_communicator_t *comm, const char *filename,
*/
int ompi_file_close(ompi_file_t **file)
{

OBJ_DESTRUCT(&(*file)->f_lock);

(*file)->f_flags |= OMPI_FILE_ISCLOSED;
OBJ_RELEASE(*file);
*file = &ompi_mpi_file_null.file;
Expand Down Expand Up @@ -241,6 +235,7 @@ static void file_constructor(ompi_file_t *file)
file->f_comm = NULL;
file->f_filename = NULL;
file->f_amode = 0;
OBJ_CONSTRUCT(&file->f_lock, opal_mutex_t);

/* Initialize flags */

Expand Down Expand Up @@ -335,4 +330,6 @@ static void file_destructor(ompi_file_t *file)
opal_pointer_array_set_item(&ompi_file_f_to_c_table,
file->f_f_to_c_index, NULL);
}

OBJ_DESTRUCT(&(file->f_lock));
}

0 comments on commit e9a0e65

Please sign in to comment.