99 * University of Stuttgart. All rights reserved.
1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
12- * Copyright (c) 2008-2015 University of Houston. All rights reserved.
12+ * Copyright (c) 2008-2021 University of Houston. All rights reserved.
1313 * Copyright (c) 2015-2018 Research Organization for Information Science
1414 * and Technology (RIST). All rights reserved.
1515 * $COPYRIGHT$
3333#include "ompi/constants.h"
3434#include "ompi/mca/fbtl/fbtl.h"
3535
36+ #define MAX_ATTEMPTS 10
37+
3638ssize_t mca_fbtl_posix_ipreadv (ompio_file_t * fh ,
3739 ompi_request_t * request )
3840{
@@ -44,7 +46,7 @@ ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *fh,
4446
4547 data = (mca_fbtl_posix_request_data_t * ) malloc ( sizeof (mca_fbtl_posix_request_data_t ));
4648 if ( NULL == data ) {
47- opal_output (1 ,"could not allocate memory\n" );
49+ opal_output (1 ,"mca_fbtl_posix_ipreadv: could not allocate memory\n" );
4850 return 0 ;
4951 }
5052
@@ -56,14 +58,14 @@ ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *fh,
5658 data -> aio_reqs = (struct aiocb * ) malloc (sizeof (struct aiocb ) *
5759 fh -> f_num_of_io_entries );
5860 if (NULL == data -> aio_reqs ) {
59- opal_output (1 , "OUT OF MEMORY \n" );
61+ opal_output (1 , "mca_fbtl_posix_ipreadv: could not allocate memory \n" );
6062 free (data );
6163 return 0 ;
6264 }
6365
6466 data -> aio_req_status = (int * ) malloc (sizeof (int ) * fh -> f_num_of_io_entries );
6567 if (NULL == data -> aio_req_status ) {
66- opal_output (1 , "OUT OF MEMORY \n" );
68+ opal_output (1 , "mca_fbtl_posix_ipreadv: could not allocate memory \n" );
6769 free (data -> aio_reqs );
6870 free (data );
6971 return 0 ;
@@ -103,14 +105,22 @@ ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *fh,
103105 }
104106
105107 for (i = 0 ; i < data -> aio_last_active_req ; i ++ ) {
106- if (-1 == aio_read (& data -> aio_reqs [i ])) {
107- opal_output (1 , "mca_fbtl_posix_ipreadv: error in aio_read(): %s" , strerror (errno ));
108- mca_fbtl_posix_unlock ( & data -> aio_lock , data -> aio_fh );
109- free (data -> aio_reqs );
110- free (data -> aio_req_status );
111- free (data );
112- return OMPI_ERROR ;
113- }
108+ int counter = 0 ;
109+ while ( MAX_ATTEMPTS > counter ) {
110+ if ( -1 != aio_read (& data -> aio_reqs [i ]) ) {
111+ break ;
112+ }
113+ counter ++ ;
114+ mca_common_ompio_progress ();
115+ }
116+ if ( MAX_ATTEMPTS == counter ) {
117+ opal_output (1 , "mca_fbtl_posix_ipreadv: error in aio_read(): errno %d %s" , errno , strerror (errno ));
118+ mca_fbtl_posix_unlock ( & data -> aio_lock , data -> aio_fh );
119+ free (data -> aio_reqs );
120+ free (data -> aio_req_status );
121+ free (data );
122+ return OMPI_ERROR ;
123+ }
114124 }
115125
116126 req -> req_data = data ;
0 commit comments