move poll wrapper on top of select (only used on Windows) to the ix namespace

This commit is contained in:
Benjamin Sergeant 2019-09-08 11:14:49 -07:00
parent ae3856c10f
commit 48cefe5525
6 changed files with 16 additions and 10 deletions

View File

@ -1 +1 @@
6.0.0 6.1.0

View File

@ -1,6 +1,10 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [6.1.0] - 2019-09-08
- move poll wrapper on top of select (only used on Windows) to the ix namespace
## [6.0.1] - 2019-09-05 ## [6.0.1] - 2019-09-05
- add cobra metrics publisher + server unittest - add cobra metrics publisher + server unittest

View File

@ -34,10 +34,7 @@ namespace ix
return true; return true;
#endif #endif
} }
}
// This function should be in the global namespace
#ifdef _WIN32
// //
// That function could 'return WSAPoll(pfd, nfds, timeout);' // That function could 'return WSAPoll(pfd, nfds, timeout);'
// but WSAPoll is said to have weird behaviors on the internet // but WSAPoll is said to have weird behaviors on the internet
@ -47,6 +44,7 @@ namespace ix
// //
int poll(struct pollfd *fds, nfds_t nfds, int timeout) int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{ {
#ifdef _WIN32
int maxfd = 0; int maxfd = 0;
fd_set readfds, writefds, errorfds; fd_set readfds, writefds, errorfds;
FD_ZERO(&readfds); FD_ZERO(&readfds);
@ -107,5 +105,9 @@ namespace ix
} }
return ret; return ret;
} #else
return ::poll(fds, nfds, timeout);
#endif #endif
}
} // namespace ix

View File

@ -13,11 +13,9 @@
#include <io.h> #include <io.h>
#include <ws2def.h> #include <ws2def.h>
// Define our own poll on Windows // Define our own poll on Windows, as a wrapper on top of select
typedef unsigned long int nfds_t; typedef unsigned long int nfds_t;
int poll(struct pollfd* fds, nfds_t nfds, int timeout);
#else #else
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h> #include <errno.h>
@ -35,4 +33,6 @@ namespace ix
{ {
bool initNetSystem(); bool initNetSystem();
bool uninitNetSystem(); bool uninitNetSystem();
int poll(struct pollfd* fds, nfds_t nfds, int timeout);
} // namespace ix } // namespace ix

View File

@ -79,7 +79,7 @@ namespace ix
} }
} }
int ret = ::poll(fds, nfds, timeoutMs); int ret = ix::poll(fds, nfds, timeoutMs);
PollResultType pollResult = PollResultType::ReadyForRead; PollResultType pollResult = PollResultType::ReadyForRead;
if (ret < 0) if (ret < 0)

View File

@ -6,4 +6,4 @@
#pragma once #pragma once
#define IX_WEBSOCKET_VERSION "6.0.0" #define IX_WEBSOCKET_VERSION "6.1.0"