mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-21 13:10:05 +00:00
Support for poll() (ie. WSAPoll()) on Windows
This commit is contained in:
parent
661061b4eb
commit
269315ca09
2
Makefile
2
Makefile
@ -18,7 +18,7 @@ WIN_CXX=x86_64-w64-mingw32-g++
|
||||
WIN_CFLAGS=-O3 #-g3 -fsanitize=address
|
||||
WIN_CXX_VANILLA_MINGW_OPT_DISABLES=-fno-tree-dce -fno-inline-small-functions
|
||||
WIN_CXX_MSYS2_MINGW_OPT_DISABLES=-fno-tree-dce -fno-tree-fre -fno-tree-vrp -fno-ipa-sra
|
||||
WIN_CXXFLAGS=-Wall -Wno-unknown-pragmas -std=c++17 -O3 $(WIN_CXX_OPT_DISABLES) -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address
|
||||
WIN_CXXFLAGS=-D_WIN32_WINNT=0x0601 -Wall -Wno-unknown-pragmas -std=c++17 -O3 $(WIN_CXX_OPT_DISABLES) -DPROTOCOL_VERSION=$(PROTOCOL_VERSION) -DGIT_VERSION=\"$(shell git describe --tags)\" #-g3 -fsanitize=address
|
||||
WIN_LDFLAGS=-static -lws2_32 -lwsock32 #-g3 -fsanitize=address
|
||||
WIN_SERVER=bin/winfusion.exe
|
||||
|
||||
|
@ -268,7 +268,7 @@ CNServer::CNServer(uint16_t p): port(p) {}
|
||||
|
||||
void CNServer::start() {
|
||||
int nfds = 1, oldnfds;
|
||||
struct pollfd fds[30]; // TODO: dynamically grow
|
||||
PollFD fds[30]; // TODO: dynamically grow
|
||||
|
||||
memset(&fds, 0, sizeof(fds));
|
||||
|
||||
@ -281,11 +281,11 @@ void CNServer::start() {
|
||||
while (active) {
|
||||
// the timeout is to ensure shard timers are ticking
|
||||
//std::cout << "pre-poll\n";
|
||||
int n = poll((struct pollfd *)&fds, nfds, 200);
|
||||
int n = poll((PollFD*)&fds, nfds, 200);
|
||||
//if (n > 0)
|
||||
// std::cout << "poll returned " << n << std::endl;
|
||||
if (n < 0) {
|
||||
perror("poll");
|
||||
if (SOCKETERROR(n)) {
|
||||
std::cout << "[FATAL] poll() returned error" << std::endl;
|
||||
terminate(0);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
typedef char buffer_t;
|
||||
#define PollFD WSAPOLLFD
|
||||
#define poll WSAPoll
|
||||
#define OF_ERRNO WSAGetLastError()
|
||||
#define OF_EWOULD WSAEWOULDBLOCK
|
||||
#define SOCKETINVALID(x) (x == INVALID_SOCKET)
|
||||
@ -32,6 +34,7 @@
|
||||
|
||||
typedef int SOCKET;
|
||||
typedef void buffer_t;
|
||||
#define PollFD struct pollfd
|
||||
#define OF_ERRNO errno
|
||||
#define OF_EWOULD EWOULDBLOCK
|
||||
#define SOCKETINVALID(x) (x < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user