ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

DWORD WINAPI WsAsyncThread ( IN PWSASYNCCONTEXT  Context)

Definition at line 701 of file async.c.

Referenced by WsAsyncCheckAndInitThread().

{
    PWSASYNCBLOCK AsyncBlock;
    PLIST_ENTRY Entry;
    HANDLE AsyncEvent = Context->AsyncEvent;
    PLIST_ENTRY ListHead = &Context->AsyncQueue;

    /* Set the blocking hook */
    WSASetBlockingHook((FARPROC)WsAsyncThreadBlockingHook);

    /* Loop */
    while (TRUE)
    {
        /* Wait for the event */
        WaitForSingleObject(AsyncEvent, INFINITE);

        /* Get the lock */
        WsAsyncLock();

        /* Process the queue */
        while (ListHead->Flink != ListHead)
        {
            /* Remove this entry and get the async block */
            Entry = RemoveHeadList(ListHead);
            AsyncBlock = CONTAINING_RECORD(Entry, WSASYNCBLOCK, AsyncQueue);

            /* Save the current task handle */
            WsAsyncCurrentTaskHandle = AsyncBlock->TaskHandle;

            /* Release the lock */
            WsAsyncUnlock();

            /* Check which operation to do */
            switch (AsyncBlock->Operation)
            {
                /* Get Host by Y */
                case WsAsyncGetHostByAddr: case WsAsyncGetHostByName:

                    /* Call the handler */
                    WsAsyncGetHost(AsyncBlock->TaskHandle,
                                   AsyncBlock->Operation,
                                   AsyncBlock->GetHost.hWnd,
                                   AsyncBlock->GetHost.wMsg,
                                   AsyncBlock->GetHost.ByWhat,
                                   AsyncBlock->GetHost.Length,
                                   AsyncBlock->GetHost.Type,
                                   AsyncBlock->GetHost.Buffer,
                                   AsyncBlock->GetHost.BufferLength);
                    break;

                /* Get Proto by Y */
                case WsAsyncGetProtoByNumber: case WsAsyncGetProtoByName:

                    /* Call the handler */
                    WsAsyncGetProto(AsyncBlock->TaskHandle,
                                    AsyncBlock->Operation,
                                    AsyncBlock->GetProto.hWnd,
                                    AsyncBlock->GetProto.wMsg,
                                    AsyncBlock->GetHost.ByWhat,
                                    AsyncBlock->GetProto.Buffer,
                                    AsyncBlock->GetProto.BufferLength);
                    break;

                /* Get Serv by Y */
                case WsAsyncGetServByPort: case WsAsyncGetServByName:

                    /* Call the handler */
                    WsAsyncGetServ(AsyncBlock->TaskHandle,
                                   AsyncBlock->Operation,
                                   AsyncBlock->GetServ.hWnd,
                                   AsyncBlock->GetServ.wMsg,
                                   AsyncBlock->GetServ.ByWhat,
                                   AsyncBlock->GetServ.Protocol,
                                   AsyncBlock->GetServ.Buffer,
                                   AsyncBlock->GetServ.BufferLength);
                    break;

                /* Termination */
                case WsAsyncTerminate:

                    /* Clean up the extra reference */
                    WSACleanup();

                    /* Free the context block */
                    WsAsyncFreeBlock(AsyncBlock);

                    /* Acquire the lock */
                    WsAsyncLock();

                    /* Loop the queue and flush it */
                    while (!IsListEmpty(ListHead))
                    {
                        Entry = RemoveHeadList(ListHead);
                        AsyncBlock = CONTAINING_RECORD(Entry,
                                                       WSASYNCBLOCK,
                                                       AsyncQueue);
                        WsAsyncFreeBlock(AsyncBlock);
                    }

                    /* Release lock */
                    WsAsyncUnlock();

                    /* Close the event, free the Context */
                    CloseHandle(AsyncEvent);
                    HeapFree(WsSockHeap, 0, Context);

                    /* Remove the extra DLL reference and kill us */
                    FreeLibraryAndExitThread(WsAsyncDllHandle, 0);

                default:
                    break;
            }

            /* Done processing */
            WsAsyncCurrentTaskHandle = NULL;

            /* Free this block, get lock and reloop */
            WsAsyncFreeBlock(AsyncBlock);
            WsAsyncLock();
        }

        /* Release the lock */
        WsAsyncUnlock();
    }
}

Generated on Sat May 26 2012 05:20:02 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.