Ignore:
Timestamp:
Dec 7, 2001, 12:28:11 PM (24 years ago)
Author:
sandervl
Message:

overlappedio, com & lpt updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/overlappedio.cpp

    r7560 r7564  
    1 /* $Id: overlappedio.cpp,v 1.5 2001-12-06 15:57:52 sandervl Exp $ */
     1/* $Id: overlappedio.cpp,v 1.6 2001-12-07 11:28:11 sandervl Exp $ */
    22
    33/*
     
    2525//******************************************************************************
    2626//******************************************************************************
    27 OverlappedIOHandler::OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler, 
    28                                          LPOVERLAPPED_HANDLER lpWriteHandler, 
     27OverlappedIOHandler::OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler,
     28                                         LPOVERLAPPED_HANDLER lpWriteHandler,
    2929                                         LPOVERLAPPED_HANDLER lpPollHandler) :
    3030                   hThreadRead(0), hThreadWrite(0), hThreadPoll(0)
     
    4949    hEventWrite  = ::CreateEventA(NULL, FALSE, FALSE, NULL);
    5050
    51     //the exit event semaphore is manual reset, because signalling this event
     51    //the exit event semaphore is manual reset, because this event
    5252    //must be able to wake up multiple threads
    5353    hEventExit   = ::CreateEventA(NULL, TRUE, FALSE, NULL);
     
    5858        goto failed;
    5959    }
    60    
     60
    6161    DWORD dwThreadId;
    6262    LPOVERLAPPED_THREAD_PARAM threadparam;
     
    8989    }
    9090
    91     if((lpPollHandler && !hThreadPoll) || !hThreadRead || (lpWriteHandler && !hThreadWrite)) 
     91    if((lpPollHandler && !hThreadPoll) || !hThreadRead || (lpWriteHandler && !hThreadWrite))
    9292    {
    9393        DebugInt3();
     
    9797    return;
    9898
    99 outofmem: 
     99outofmem:
    100100    errcode = OutOfMemory;
    101101    //fall through
    102102failed:
    103     //SvL: NOTE: We might not fail gracefully when threads have already been 
     103    //SvL: NOTE: We might not fail gracefully when threads have already been
    104104    //           created. (thread accessing memory that has been freed)
    105105    //           Don't feel like wasting time to fix this as this should never
     
    223223        case ASYNCIO_READ:
    224224        case ASYNCIO_READWRITE:
    225             lpReadHandler(lpRequest, &dwResult, NULL);
     225            lpReadHandler(lpRequest, &dwResult, NULL);
    226226            lpOverlapped->Internal     = lpRequest->dwLastError;
    227227            lpOverlapped->InternalHigh = dwResult;
     
    235235
    236236        case ASYNCIO_WRITE:
    237             lpWriteHandler(lpRequest, &dwResult, NULL);
     237            lpWriteHandler(lpRequest, &dwResult, NULL);
    238238            lpOverlapped->Internal     = lpRequest->dwLastError;
    239239            lpOverlapped->InternalHigh = dwResult;
     
    247247
    248248        case ASYNCIO_POLL:
    249             while(TRUE) 
     249            while(TRUE)
    250250            {
    251251                dwTimeOut = 0;
     
    281281                                    LPOVERLAPPED  lpOverlapped,
    282282                                    LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
    283                                     DWORD         dwUserData)
     283                                    DWORD         dwUserData,
     284                                    DWORD         dwTimeOut)
    284285{
    285286    LPASYNCIOREQUEST lpRequest, current;
     
    290291        return FALSE;
    291292    }
    292  
     293
    293294    lpRequest = new ASYNCIOREQUEST;
    294295    if(lpRequest == NULL) {
     
    304305    lpRequest->lpCompletionRoutine = lpCompletionRoutine;
    305306    lpRequest->dwUserData          = dwUserData;
     307    lpRequest->dwTimeOut           = dwTimeOut;
    306308    lpRequest->next                = NULL;
    307309
     
    322324    ::LeaveCriticalSection(&critsect);
    323325
    324     lpOverlapped->Internal     = STATUS_PENDING;
     326    lpOverlapped->Internal     = ERROR_IO_PENDING;
    325327    lpOverlapped->InternalHigh = 0;
    326328    lpOverlapped->Offset       = 0;
     
    343345                                   LPOVERLAPPED  lpOverlapped,
    344346                                   LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
    345                                    DWORD         dwUserData)
     347                                   DWORD         dwUserData,
     348                                   DWORD         dwTimeOut)
    346349{
    347350    LPASYNCIOREQUEST lpRequest, current;
     
    351354        return FALSE;
    352355    }
    353  
     356
    354357    lpRequest = new ASYNCIOREQUEST;
    355358    if(lpRequest == NULL) {
     
    365368    lpRequest->lpCompletionRoutine = lpCompletionRoutine;
    366369    lpRequest->dwUserData          = dwUserData;
     370    lpRequest->dwTimeOut           = dwTimeOut;
    367371    lpRequest->next                = NULL;
    368372
     
    378382    ::LeaveCriticalSection(&critsect);
    379383
    380     lpOverlapped->Internal     = STATUS_PENDING;
     384    lpOverlapped->Internal     = ERROR_IO_PENDING;
    381385    lpOverlapped->InternalHigh = 0;
    382386    lpOverlapped->Offset       = 0;
     
    396400                                       LPOVERLAPPED  lpOverlapped,
    397401                                       LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine,
    398                                        DWORD         dwUserData)
     402                                       DWORD         dwUserData,
     403                                       DWORD         dwTimeOut)
    399404{
    400405    LPASYNCIOREQUEST lpRequest, current;
     
    404409        return FALSE;
    405410    }
    406  
     411
    407412    lpRequest = new ASYNCIOREQUEST;
    408413    if(lpRequest == NULL) {
     
    418423    lpRequest->lpCompletionRoutine = lpCompletionRoutine;
    419424    lpRequest->dwUserData          = dwUserData;
     425    lpRequest->dwTimeOut           = dwTimeOut;
    420426    lpRequest->next                = NULL;
    421427
     
    431437    ::LeaveCriticalSection(&critsect);
    432438
    433     lpOverlapped->Internal     = STATUS_PENDING;
     439    lpOverlapped->Internal     = ERROR_IO_PENDING;
    434440    lpOverlapped->InternalHigh = 0;
    435441    lpOverlapped->Offset       = 0;
     
    449455    LPASYNCIOREQUEST lpRequest;
    450456
    451     for(int i=ASYNC_INDEX_READ;i<NR_ASYNC_OPERATIONS;i++) 
     457    for(int i=ASYNC_INDEX_READ;i<NR_ASYNC_OPERATIONS;i++)
    452458    {
    453459        while(TRUE) {
     
    468474                                              LPOVERLAPPED  lpOverlapped,
    469475                                              LPDWORD       lpcbTransfer,
    470                                               DWORD         dwTimeout)
     476                                              BOOL          fWait)
    471477{
    472478    DWORD ret;
    473479
    474     ret = ::WaitForSingleObject(lpOverlapped->hEvent, dwTimeout);
     480    ret = ::WaitForSingleObject(lpOverlapped->hEvent, (fWait) ? INFINITE : 0);
    475481
    476482    if(lpcbTransfer)
     
    488494
    489495    ::EnterCriticalSection(&critsect);
    490     if(pending[index]) 
     496    if(pending[index])
    491497    {
    492         if(pending[index]->hHandle != hHandle) 
     498        if(pending[index]->hHandle != hHandle)
    493499        {
    494500            lpRequest = pending[index];
Note: See TracChangeset for help on using the changeset viewer.