Home | Info | Community | Development | myReactOS | Contact Us
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(); } }