-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpi/romio/adio/ad_nfs/ad_nfs_wait.c
        -:    0:Graph:ad_nfs_wait.gcno
        -:    0:Data:ad_nfs_wait.gcda
        -:    0:Runs:224
        -:    0:Programs:67
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    2:/* 
        -:    3: *   Copyright (C) 1997 University of Chicago. 
        -:    4: *   See COPYRIGHT notice in top-level directory.
        -:    5: */
        -:    6:
        -:    7:#include "ad_nfs.h"
        -:    8:
        -:    9:void ADIOI_NFS_ReadComplete(ADIO_Request *request, ADIO_Status *status,
        -:   10:			    int *error_code)
    #####:   11:{
        -:   12:	return;
        -:   13:#if 0
        -:   14:#ifdef ROMIO_HAVE_WORKING_AIO
        -:   15:    int err;
        -:   16:    static char myname[] = "ADIOI_NFS_READCOMPLETE";
        -:   17:#ifdef ROMIO_HAVE_STRUCT_AIOCB_WITH_AIO_HANDLE
        -:   18:    struct aiocb *tmp1;
        -:   19:#endif
        -:   20:#endif
        -:   21:
        -:   22:    if (*request == ADIO_REQUEST_NULL) {
        -:   23:	*error_code = MPI_SUCCESS;
        -:   24:	return;
        -:   25:    }
        -:   26:    
        -:   27:#ifdef ROMIO_HAVE_AIO_SUSPEND_TWO_ARGS
        -:   28:/* old IBM */
        -:   29:    if ((*request)->queued) {
        -:   30:	do {
        -:   31:	    err = aio_suspend(1, (struct aiocb **) &((*request)->handle));
        -:   32:	} while ((err == -1) && (errno == EINTR));
        -:   33:
        -:   34:	tmp1 = (struct aiocb *) (*request)->handle;
        -:   35:	if (err != -1) {
        -:   36:	    err = aio_return(tmp1->aio_handle);
        -:   37:	    (*request)->nbytes = err;
        -:   38:	    errno = aio_error(tmp1->aio_handle);
        -:   39:	}
        -:   40:	else (*request)->nbytes = -1;
        -:   41:
        -:   42:/* on DEC, it is required to call aio_return to dequeue the request.
        -:   43:   IBM man pages don't indicate what function to use for dequeue.
        -:   44:   I'm assuming it is aio_return! */
        -:   45:
        -:   46:	if (err == -1) {
        -:   47:	    *error_code = MPIO_Err_create_code(MPI_SUCCESS,
        -:   48:					       MPIR_ERR_RECOVERABLE, myname,
        -:   49:					       __LINE__, MPI_ERR_IO, "**io",
        -:   50:					       "**io %s", strerror(errno));
        -:   51:	}
        -:   52:	else *error_code = MPI_SUCCESS;
        -:   53:    }
        -:   54:    else *error_code = MPI_SUCCESS;  /* if ( (*request)->queued ) */
        -:   55:
        -:   56:#ifdef HAVE_STATUS_SET_BYTES
        -:   57:    if ((*request)->nbytes != -1)
        -:   58:	MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
        -:   59:#endif
        -:   60:
        -:   61:#elif defined(ROMIO_HAVE_WORKING_AIO)
        -:   62:/* all other aio types */
        -:   63:    if ((*request)->queued) {
        -:   64:	do {
        -:   65:	    err = aio_suspend((const struct aiocb **) &((*request)->handle), 1, 0);
        -:   66:	} while ((err == -1) && (errno == EINTR));
        -:   67:
        -:   68:	if (err != -1) {
        -:   69:	    err = aio_return((struct aiocb *) (*request)->handle); 
        -:   70:	    (*request)->nbytes = err;
        -:   71:	    errno = aio_error((struct aiocb *) (*request)->handle);
        -:   72:	}
        -:   73:	else (*request)->nbytes = -1;
        -:   74:
        -:   75:	if (err == -1) {
        -:   76:	    *error_code = MPIO_Err_create_code(MPI_SUCCESS,
        -:   77:					       MPIR_ERR_RECOVERABLE, myname,
        -:   78:					       __LINE__, MPI_ERR_IO, "**io",
        -:   79:					       "**io %s", strerror(errno));
        -:   80:	}
        -:   81:	else *error_code = MPI_SUCCESS;
        -:   82:    }
        -:   83:    else *error_code = MPI_SUCCESS;  /* if ((*request)->queued) ... */
        -:   84:#ifdef HAVE_STATUS_SET_BYTES
        -:   85:    if ((*request)->nbytes != -1)
        -:   86:	MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
        -:   87:#endif
        -:   88:#endif
        -:   89:
        -:   90:#ifdef ROMIO_HAVE_WORKING_AIO
        -:   91:    if ((*request)->queued != -1) {
        -:   92:
        -:   93:	/* queued = -1 is an internal hack used when the request must
        -:   94:	   be completed, but the request object should not be
        -:   95:	   freed. This is used in ADIOI_Complete_async, because the user
        -:   96:	   will call MPI_Wait later, which would require status to
        -:   97:	   be filled. Ugly but works. queued = -1 should be used only
        -:   98:	   in ADIOI_Complete_async. 
        -:   99:           This should not affect the user in any way. */
        -:  100:
        -:  101:	/* if request is still queued in the system, it is also there
        -:  102:           on ADIOI_Async_list. Delete it from there. */
        -:  103:	if ((*request)->queued) ADIOI_Del_req_from_list(request);
        -:  104:
        -:  105:	(*request)->fd->async_count--;
        -:  106:	if ((*request)->handle) ADIOI_Free((*request)->handle);
        -:  107:	ADIOI_Free_request((ADIOI_Req_node *) (*request));
        -:  108:	*request = ADIO_REQUEST_NULL;
        -:  109:    }
        -:  110:
        -:  111:#else
        -:  112:/* no aio */
        -:  113:
        -:  114:#ifdef HAVE_STATUS_SET_BYTES
        -:  115:    MPIR_Status_set_bytes(status, (*request)->datatype, (*request)->nbytes);
        -:  116:#endif
        -:  117:    (*request)->fd->async_count--;
        -:  118:    ADIOI_Free_request((ADIOI_Req_node *) (*request));
        -:  119:    *request = ADIO_REQUEST_NULL;
        -:  120:    *error_code = MPI_SUCCESS;
        -:  121:#endif    
        -:  122:#endif
        -:  123:}
        -:  124:
        -:  125:
        -:  126:void ADIOI_NFS_WriteComplete(ADIO_Request *request, ADIO_Status *status,
        -:  127:			     int *error_code)
    #####:  128:{
    #####:  129:    ADIOI_NFS_ReadComplete(request, status, error_code);
    #####:  130:}