finally unfuck windows bits

pull/283/head
Rick V 5 years ago
parent 69189214e0
commit ea7301fecf
No known key found for this signature in database
GPG Key ID: C0EDC8723FDC3465

@ -1,10 +1,10 @@
#include <ev/ev_win32.hpp>
// a single event queue for the TUN interface
HANDLE tun_event_queue = INVALID_HANDLE_VALUE;
static HANDLE tun_event_queue = INVALID_HANDLE_VALUE;
// we hand the kernel our thread handles to process completion events
HANDLE* kThreadPool;
static HANDLE* kThreadPool;
// list of TUN listeners (useful for exits or other nodes with multiple TUNs)
std::list< win32_tun_io* > tun_listeners;
@ -182,28 +182,31 @@ tun_ev_loop(void* unused)
void
exit_tun_loop()
{
// if we get all-ones in the queue, thread exits, and we clean up
PostQueuedCompletionStatus(tun_event_queue, 0, ~0, nullptr);
// kill the kernel's thread pool
int i = (&kThreadPool)[1] - kThreadPool; // get the size of our thread pool
llarp::LogInfo("closing ", i, " threads");
WaitForMultipleObjects(i, kThreadPool, TRUE, INFINITE);
for(int j = 0; j < i; ++j)
CloseHandle(kThreadPool[j]);
delete[] kThreadPool;
// the IOCP refcount is decreased each time an associated fd
// is closed
// the fds are closed in their destructors
// once we get to zero, we can safely close the event port
auto itr = tun_listeners.begin();
while(itr != tun_listeners.end())
if(kThreadPool)
{
delete(*itr);
itr = tun_listeners.erase(itr);
// if we get all-ones in the queue, thread exits, and we clean up
PostQueuedCompletionStatus(tun_event_queue, 0, ~0, nullptr);
// kill the kernel's thread pool
int i = (&kThreadPool)[1] - kThreadPool; // get the size of our thread pool
llarp::LogInfo("closing ", i, " threads");
WaitForMultipleObjects(i, kThreadPool, TRUE, INFINITE);
for(int j = 0; j < i; ++j)
CloseHandle(kThreadPool[j]);
delete[] kThreadPool;
// the IOCP refcount is decreased each time an associated fd
// is closed
// the fds are closed in their destructors
// once we get to zero, we can safely close the event port
auto itr = tun_listeners.begin();
while(itr != tun_listeners.end())
{
delete(*itr);
itr = tun_listeners.erase(itr);
}
CloseHandle(tun_event_queue);
}
CloseHandle(tun_event_queue);
}
namespace llarp
@ -274,8 +277,8 @@ namespace llarp
int err = WSAGetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, LANG_NEUTRAL,
ebuf, 1024, nullptr);
int l = strlen(ebuf);
ebuf[l-2] = '\0'; // remove line break
int l = strlen(ebuf);
ebuf[l - 2] = '\0'; // remove line break
llarp::LogError("error connecting: ", ebuf, " [", err, "]");
_conn->error(_conn);
}
@ -291,8 +294,8 @@ namespace llarp
int err = WSAGetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, err, LANG_NEUTRAL,
ebuf, 1024, nullptr);
int l = strlen(ebuf);
ebuf[l-2] = '\0'; // remove line break
int l = strlen(ebuf);
ebuf[l - 2] = '\0'; // remove line break
llarp::LogError("failed to accept on ", fd, ":", ebuf, " [", err, "]");
return -1;
}
@ -630,5 +633,8 @@ llarp_win32_loop::udp_close(llarp_udp_io* l)
void
llarp_win32_loop::stop()
{
// do nothing
if(upollfd)
upoll_destroy(upollfd);
upollfd = nullptr;
llarp::LogDebug("destroy upoll");
}

@ -115,8 +115,6 @@ struct llarp_win32_loop : public llarp_ev_loop
~llarp_win32_loop()
{
if(upollfd)
upoll_destroy(upollfd);
}
bool

@ -71,6 +71,7 @@ uhash_delete(uhash_t* hash, intptr_t key)
{
ulist_remove(q);
free(q);
q = NULL;
return 1;
}
}
@ -88,6 +89,7 @@ uhash_destroy(uhash_t* hash)
uitem_t* n = ulist_data(q, uitem_t, list);
ulist_remove(q);
free(n);
n = NULL;
}
}
return 0;
@ -118,8 +120,10 @@ upoll_destroy(upoll_t* upq)
n = ulist_data(n, unote_t, queue);
ulist_remove(q);
free(n);
n = NULL;
}
free(upq);
upq = NULL;
}
int
@ -155,6 +159,7 @@ upoll_ctl(upoll_t* upq, int op, intptr_t fd, upoll_event_t* event)
ulist_remove(&note->queue);
uhash_delete(upq->table, fd);
free(note);
note = NULL;
break;
}
case UPOLL_CTL_MOD:

@ -32,7 +32,7 @@ TEST_F(TestINIParser, TestParseOneSection)
itr = sect.find("key");
ASSERT_NE(itr, sect.end());
#if __cplusplus >= 201703L
ASSERT_STREQ(itr->second.data(), "val");
ASSERT_STREQ(llarp::string_view_string(itr->second).c_str(), "val");
#else
ASSERT_STREQ(itr->second.c_str(), "val");
#endif

Loading…
Cancel
Save