Changeset 8644 for trunk/src/kernel32


Ignore:
Timestamp:
Jun 11, 2002, 2:52:03 PM (23 years ago)
Author:
sandervl
Message:

Overlapped IO bugfixes

Location:
trunk/src/kernel32
Files:
2 edited

Legend:

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

    r7605 r8644  
    1 /* $Id: hmcomm.cpp,v 1.34 2001-12-10 14:04:24 sandervl Exp $ */
     1/* $Id: hmcomm.cpp,v 1.35 2002-06-11 12:51:43 sandervl Exp $ */
    22
    33/*
     
    297297    PHMHANDLEDATA pHMHandleData;
    298298    BOOL          ret;
    299     ULONG         ulBytesRead;
     299    ULONG         ulBytesRead, len;
    300300
    301301    pHMHandleData = HMQueryHandleData(lpRequest->hHandle);
     
    317317#endif
    318318
    319     ret = OSLibDosRead(pHMHandleData->hHMHandle, (LPVOID)lpRequest->lpBuffer, lpRequest->nNumberOfBytes,
    320                        &ulBytesRead);
     319    ret = OSLibDosRead(pHMHandleData->hHMHandle, (LPVOID)lpRequest->lpBuffer, lpRequest->nNumberOfBytes, &ulBytesRead);
    321320
    322321    *lpdwResult = (ret) ? ulBytesRead : 0;
     
    327326    }
    328327    else {
    329         //testestestest
     328#ifdef DEBUG
    330329        dprintf2(("%d Bytes read:", ulBytesRead));
    331         for(int i=0;i<ulBytesRead;i++) {
     330        for(int i=0;i<min(ulBytesRead, 16);i++) {
    332331            dprintf2(("%x %c", ((char *)lpRequest->lpBuffer)[i], ((char *)lpRequest->lpBuffer)[i]));
    333332        }
    334         //testestestset
     333#endif
    335334    }
    336335    return GetLastError();
     
    352351    }
    353352
    354     //testestestest
     353#ifdef DEBUG
    355354    dprintf2(("Bytes to write:"));
    356     for(int i=0;i<lpRequest->nNumberOfBytes;i++) {
     355    for(int i=0;i<min(lpRequest->nNumberOfBytes, 16);i++) {
    357356        dprintf2(("%x %c", ((char *)lpRequest->lpBuffer)[i], ((char *)lpRequest->lpBuffer)[i]));
    358357    }
    359     //testestestset
     358#endif
    360359
    361360    ret = OSLibDosWrite(pHMHandleData->hHMHandle, (LPVOID)lpRequest->lpBuffer, lpRequest->nNumberOfBytes,
     
    593592        dprintf(("!ERROR!: ReadFile failed with rc %d", GetLastError()));
    594593    }
     594#ifdef DEBUG
    595595    else {
    596         //testestestest
    597596        dprintf2(("%d Bytes read:", ulBytesRead));
    598         for(int i=0;i<ulBytesRead;i++) {
     597        for(int i=0;i<min(ulBytesRead, 16);i++) {
    599598            dprintf2(("%x %c", ((char *)lpBuffer)[i], ((char *)lpBuffer)[i]));
    600599        }
    601         //testestestset
    602     }
     600    }
     601#endif
    603602    return ret;
    604603}
  • trunk/src/kernel32/overlappedio.cpp

    r8638 r8644  
    1 /* $Id: overlappedio.cpp,v 1.15 2002-06-10 17:46:53 sandervl Exp $ */
     1/* $Id: overlappedio.cpp,v 1.16 2002-06-11 12:51:43 sandervl Exp $ */
    22
    33/*
     
    154154    OverlappedIOHandler *lpOverlappedObj;
    155155
    156     if(threadparam == NULL) {
     156    if(threadparam == NULL || threadparam->lpOverlappedObj == NULL) {
    157157        DebugInt3();
    158158        return 0;
     
    222222            pending[index]  = lpRequest->next;
    223223
    224             //add to in process list
     224            //add to the head of process list
    225225            lpRequest->next = pending[ASYNC_INDEX_BUSY];
    226226            pending[ASYNC_INDEX_BUSY] = lpRequest;
     
    230230            hHandle      = lpRequest->hHandle;
    231231
     232#ifdef DEBUG
     233            switch(lpRequest->dwAsyncType) {
     234            case ASYNCIO_READ:
     235            case ASYNCIO_WRITE:
     236            case ASYNCIO_POLL:
     237                break;
     238            default:
     239                DebugInt3();
     240                break;
     241            }
     242#endif
    232243            switch(dwOperation) {
    233244            case ASYNCIO_READ:
     
    298309            }
    299310            //remove from in-process list and delete async request object
    300             findAndRemoveRequest(ASYNC_INDEX_BUSY, hHandle);
     311            removeRequest(ASYNC_INDEX_BUSY, lpRequest);
    301312            delete lpRequest;
    302313        } //while(TRUE)
     
    346357    else index = ASYNC_INDEX_WRITE;
    347358
    348     ::EnterCriticalSection(&critsect);
    349     if(pending[index]) {
    350          current = pending[index];
    351          while(current->next) {
    352              current = current->next;
    353          }
    354          current->next = lpRequest;
    355     }
    356     else pending[index] = lpRequest;
    357     ::LeaveCriticalSection(&critsect);
     359    addRequest(index, lpRequest);
    358360
    359361    lpOverlapped->Internal     = STATUS_PENDING;
     
    404406    lpRequest->next                = NULL;
    405407
    406     ::EnterCriticalSection(&critsect);
    407     if(pending[ASYNC_INDEX_READ]) {
    408          current = pending[ASYNC_INDEX_READ];
    409          while(current->next) {
    410              current = current->next;
    411          }
    412          current->next = lpRequest;
    413     }
    414     else pending[ASYNC_INDEX_READ] = lpRequest;
    415     ::LeaveCriticalSection(&critsect);
     408    addRequest(ASYNC_INDEX_READ, lpRequest);
    416409
    417410    lpOverlapped->Internal     = STATUS_PENDING;
     
    490483    }
    491484
    492     ::EnterCriticalSection(&critsect);
    493     if(pending[ASYNC_INDEX_POLL]) {
    494          current = pending[ASYNC_INDEX_READ];
    495          while(current->next) {
    496              current = current->next;
    497          }
    498          current->next = lpRequest;
    499     }
    500     else pending[ASYNC_INDEX_POLL] = lpRequest;
    501     ::LeaveCriticalSection(&critsect);
     485    addRequest(ASYNC_INDEX_POLL, lpRequest);
    502486
    503487    //wake up async thread
     
    584568//******************************************************************************
    585569//******************************************************************************
    586 
     570void OverlappedIOHandler::addRequest(int index, LPASYNCIOREQUEST lpRequest)
     571{
     572    LPASYNCIOREQUEST current;
     573
     574    ::EnterCriticalSection(&critsect);
     575    if(pending[index]) {
     576         current = pending[index];
     577         while(current->next) {
     578             current = current->next;
     579         }
     580         current->next = lpRequest;
     581    }
     582    else pending[index] = lpRequest;
     583    ::LeaveCriticalSection(&critsect);
     584}
     585//******************************************************************************
     586//******************************************************************************
     587void OverlappedIOHandler::removeRequest(int index, LPASYNCIOREQUEST lpRequest)
     588{
     589    LPASYNCIOREQUEST current;
     590
     591    ::EnterCriticalSection(&critsect);
     592    if(pending[index]) {
     593        if(pending[index] == lpRequest) {
     594            pending[index] = lpRequest->next;
     595        }
     596        else {
     597            current = pending[index];
     598            while(current->next && current->next != lpRequest) {
     599                current = current->next;
     600            }
     601            if(current->next) {
     602                current->next = lpRequest->next;
     603            }
     604            else {
     605                dprintf(("!ERROR!: request %x not found!!!!!!", lpRequest));
     606                DebugInt3();
     607            }
     608        }
     609    }
     610    //else removed from list by cancelio
     611    ::LeaveCriticalSection(&critsect);
     612}
     613//******************************************************************************
     614//******************************************************************************
     615
Note: See TracChangeset for help on using the changeset viewer.