00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "ad_xfs.h"
00010
00011 int ADIOI_XFS_ReadDone(ADIO_Request *request, ADIO_Status *status, int *error_code)
00012 {
00013 int err, done=0;
00014 #ifndef PRINT_ERR_MSG
00015 static char myname[] = "ADIOI_XFS_READDONE";
00016 #endif
00017
00018 if (*request == ADIO_REQUEST_NULL) {
00019 *error_code = MPI_SUCCESS;
00020 return 1;
00021 }
00022
00023 if ((*request)->queued) {
00024 errno = aio_error64((const aiocb64_t *) (*request)->handle);
00025 if (errno == EINPROGRESS) {
00026 done = 0;
00027 *error_code = MPI_SUCCESS;
00028 }
00029 else {
00030 err = aio_return64((aiocb64_t *) (*request)->handle);
00031 (*request)->nbytes = err;
00032 errno = aio_error64((const aiocb64_t *) (*request)->handle);
00033
00034 done = 1;
00035 #ifdef PRINT_ERR_MSG
00036 *error_code = (err == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
00037 #else
00038 if (err == -1) {
00039 *error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
00040 myname, "I/O Error", "%s", strerror(errno));
00041 ADIOI_Error((*request)->fd, *error_code, myname);
00042 }
00043 else *error_code = MPI_SUCCESS;
00044 #endif
00045 }
00046 }
00047 else {
00048 done = 1;
00049 *error_code = MPI_SUCCESS;
00050 }
00051 #ifdef HAVE_STATUS_SET_BYTES
00052 if (done && ((*request)->nbytes != -1))
00053 MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
00054 #endif
00055
00056 if (done) {
00057
00058
00059 if ((*request)->queued) ADIOI_Del_req_from_list(request);
00060
00061 (*request)->fd->async_count--;
00062 if ((*request)->handle) ADIOI_Free((*request)->handle);
00063 ADIOI_Free_request((ADIOI_Req_node *) (*request));
00064 *request = ADIO_REQUEST_NULL;
00065
00066 }
00067 return done;
00068 }
00069
00070
00071 int ADIOI_XFS_WriteDone(ADIO_Request *request, ADIO_Status *status, int *error_code)
00072 {
00073 return ADIOI_XFS_ReadDone(request, status, error_code);
00074 }