|
|
|
@ -365,38 +365,28 @@ struct llarp_win32_loop : public llarp_ev_loop
|
|
|
|
|
int
|
|
|
|
|
tick(int ms)
|
|
|
|
|
{
|
|
|
|
|
// The only field we really care about is
|
|
|
|
|
// the listener_id, as it contains the address
|
|
|
|
|
// of the ev_io instance.
|
|
|
|
|
DWORD iolen = 0;
|
|
|
|
|
// ULONG_PTR is guaranteed to be the same size
|
|
|
|
|
// as an arch-specific pointer value
|
|
|
|
|
ULONG_PTR ev_id = 0;
|
|
|
|
|
WSAOVERLAPPED* qdata = nullptr;
|
|
|
|
|
int idx = 0;
|
|
|
|
|
BOOL result =
|
|
|
|
|
::GetQueuedCompletionStatus(iocpfd, &iolen, &ev_id, &qdata, ms);
|
|
|
|
|
|
|
|
|
|
llarp::ev_io* ev = reinterpret_cast< llarp::ev_io* >(ev_id);
|
|
|
|
|
if(ev && qdata)
|
|
|
|
|
OVERLAPPED_ENTRY events[1024];
|
|
|
|
|
ULONG numEvents = 0;
|
|
|
|
|
if(::GetQueuedCompletionStatusEx(iocpfd, events, 1024, &numEvents, ms,
|
|
|
|
|
false))
|
|
|
|
|
{
|
|
|
|
|
llarp::LogDebug("size: ", iolen, "\tev_id: ", ev_id, "\tqdata: ", qdata);
|
|
|
|
|
if(ev->write)
|
|
|
|
|
ev->flush_write();
|
|
|
|
|
else
|
|
|
|
|
ev->read(readbuf, iolen);
|
|
|
|
|
++idx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!idx)
|
|
|
|
|
return -1;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
result = idx;
|
|
|
|
|
tick_listeners();
|
|
|
|
|
for(ULONG idx = 0; idx < numEvents; ++idx)
|
|
|
|
|
{
|
|
|
|
|
llarp::ev_io* ev =
|
|
|
|
|
reinterpret_cast< llarp::ev_io* >(events[idx].lpCompletionKey);
|
|
|
|
|
if(ev)
|
|
|
|
|
{
|
|
|
|
|
if(ev->write)
|
|
|
|
|
ev->flush_write();
|
|
|
|
|
auto amount =
|
|
|
|
|
std::min(EV_READ_BUF_SZ, events[idx].dwNumberOfBytesTransferred);
|
|
|
|
|
memcpy(readbuf, events[idx].lpOverlapped->Pointer, amount);
|
|
|
|
|
ev->read(readbuf, amount);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
tick_listeners();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ok apparently this isn't being used yet...
|
|
|
|
|