Commit 47754bc5 authored by David Goodell's avatar David Goodell
Browse files

[svn-r10801] ROMIO: error checking for MPI_Comm and MPI_Info objects

1). There was error checking on the comm object in
    MPI_Comm_test_inter(comm, &flag); So if the return value of
    MPI_Comm_test_inter is not MPI_SUCCESS, then the comm is either an
    invalid MPI_Comm handle or intercommunicator handle.
2). A new macro MPIO_CHECK_INFO is added into adioi_error.h. It will
    call MPI_Info_dup, unless there is no more memory space left , as
    long as the info object is valid, this function will return
    MPI_SUCCESS; or it will return an error code. So by checking the
    return value of MPI_Info_dup, we could achieve the purpose of
    checking MPI_Info handles.

Based on patch 0006 from the second round of IBM's error checking
patches.  Replaces 0009 from the first round and augments r10637.
parent 208d90e6
...@@ -160,3 +160,14 @@ if ((fh->file_system == ADIO_PIOFS) || \ ...@@ -160,3 +160,14 @@ if ((fh->file_system == ADIO_PIOFS) || \
#define ADIOI_TEST_DEFERRED(fh, myname, error_code)\ #define ADIOI_TEST_DEFERRED(fh, myname, error_code)\
if(! (fh)->is_open ) {\ if(! (fh)->is_open ) {\
ADIO_ImmediateOpen((fh), (error_code)); } ADIO_ImmediateOpen((fh), (error_code)); }
/* Check MPI_Info object by calling MPI_Info_dup, if the info object is valid
then the dup operation will succeed */
#define MPIO_CHECK_INFO(info, error_code) { \
MPI_Info dupinfo; \
error_code = MPI_Info_dup(info, &dupinfo); \
if(error_code != MPI_SUCCESS) goto fn_fail; \
if (dupinfo != MPI_INFO_NULL) { \
MPI_Info_free(&dupinfo); \
} \
}
...@@ -46,7 +46,7 @@ Output Parameters: ...@@ -46,7 +46,7 @@ Output Parameters:
int MPI_File_open(MPI_Comm comm, const char *filename, int amode, int MPI_File_open(MPI_Comm comm, const char *filename, int amode,
MPI_Info info, MPI_File *fh) MPI_Info info, MPI_File *fh)
{ {
int error_code, file_system, flag, tmp_amode=0, rank; int error_code = MPI_SUCCESS, file_system, flag, tmp_amode=0, rank;
char *tmp; char *tmp;
MPI_Comm dupcomm; MPI_Comm dupcomm;
ADIOI_Fns *fsops; ADIOI_Fns *fsops;
...@@ -61,13 +61,15 @@ int MPI_File_open(MPI_Comm comm, const char *filename, int amode, ...@@ -61,13 +61,15 @@ int MPI_File_open(MPI_Comm comm, const char *filename, int amode,
/* --BEGIN ERROR HANDLING-- */ /* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_COMM(comm, myname, error_code); MPIO_CHECK_COMM(comm, myname, error_code);
if(info != MPI_INFO_NULL)
MPIO_CHECK_INFO(info, error_code);
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
MPI_Comm_test_inter(comm, &flag); error_code = MPI_Comm_test_inter(comm, &flag);
/* --BEGIN ERROR HANDLING-- */ /* --BEGIN ERROR HANDLING-- */
if (flag) if (error_code || flag)
{ {
error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, error_code = MPIO_Err_create_code(error_code, MPIR_ERR_RECOVERABLE,
myname, __LINE__, MPI_ERR_COMM, myname, __LINE__, MPI_ERR_COMM,
"**commnotintra", 0); "**commnotintra", 0);
goto fn_fail; goto fn_fail;
......
...@@ -44,6 +44,7 @@ int MPI_File_set_info(MPI_File fh, MPI_Info info) ...@@ -44,6 +44,7 @@ int MPI_File_set_info(MPI_File fh, MPI_Info info)
/* --BEGIN ERROR HANDLING-- */ /* --BEGIN ERROR HANDLING-- */
MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code); MPIO_CHECK_FILE_HANDLE(adio_fh, myname, error_code);
MPIO_CHECK_INFO(info, error_code);
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
/* set new info */ /* set new info */
...@@ -58,4 +59,6 @@ fn_exit: ...@@ -58,4 +59,6 @@ fn_exit:
MPIU_THREAD_CS_EXIT(ALLFUNC,); MPIU_THREAD_CS_EXIT(ALLFUNC,);
return error_code; return error_code;
fn_fail:
goto fn_exit;
} }
...@@ -106,6 +106,9 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype, ...@@ -106,6 +106,9 @@ int MPI_File_set_view(MPI_File fh, MPI_Offset disp, MPI_Datatype etype,
error_code = MPIO_Err_return_file(adio_fh, error_code); error_code = MPIO_Err_return_file(adio_fh, error_code);
goto fn_exit; goto fn_exit;
} }
if(info != MPI_INFO_NULL){
MPIO_CHECK_INFO(info, error_code);
}
/* --END ERROR HANDLING-- */ /* --END ERROR HANDLING-- */
MPI_Type_size(filetype, &filetype_size); MPI_Type_size(filetype, &filetype_size);
...@@ -191,4 +194,9 @@ fn_exit: ...@@ -191,4 +194,9 @@ fn_exit:
MPIU_THREAD_CS_EXIT(ALLFUNC,); MPIU_THREAD_CS_EXIT(ALLFUNC,);
return error_code; return error_code;
fn_fail:
/* --BEGIN ERROR HANDLING-- */
error_code = MPIO_Err_return_file(fh, error_code);
goto fn_exit;
/* --END ERROR HANDLING-- */
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment