|
@@ -740,15 +740,15 @@ typedef struct DIR {
|
|
struct dirent result;
|
|
struct dirent result;
|
|
} DIR;
|
|
} DIR;
|
|
|
|
|
|
-#if defined(_WIN32)
|
|
|
|
-#if !defined(HAVE_POLL)
|
|
|
|
-struct pollfd {
|
|
|
|
|
|
+#if defined(HAVE_POLL)
|
|
|
|
+#define mg_pollfd pollfd
|
|
|
|
+#else
|
|
|
|
+struct mg_pollfd {
|
|
SOCKET fd;
|
|
SOCKET fd;
|
|
short events;
|
|
short events;
|
|
short revents;
|
|
short revents;
|
|
};
|
|
};
|
|
#endif
|
|
#endif
|
|
-#endif
|
|
|
|
|
|
|
|
/* Mark required libraries */
|
|
/* Mark required libraries */
|
|
#if defined(_MSC_VER)
|
|
#if defined(_MSC_VER)
|
|
@@ -829,6 +829,8 @@ typedef int SOCKET;
|
|
#define socklen_t int
|
|
#define socklen_t int
|
|
#endif /* hpux */
|
|
#endif /* hpux */
|
|
|
|
|
|
|
|
+#define mg_pollfd pollfd
|
|
|
|
+
|
|
#endif /* defined(_WIN32) - WINDOWS vs UNIX include block */
|
|
#endif /* defined(_WIN32) - WINDOWS vs UNIX include block */
|
|
|
|
|
|
/* Maximum queue length for pending connections. This value is passed as
|
|
/* Maximum queue length for pending connections. This value is passed as
|
|
@@ -2598,7 +2600,7 @@ struct mg_context {
|
|
int context_type; /* See CONTEXT_* above */
|
|
int context_type; /* See CONTEXT_* above */
|
|
|
|
|
|
struct socket *listening_sockets;
|
|
struct socket *listening_sockets;
|
|
- struct pollfd *listening_socket_fds;
|
|
|
|
|
|
+ struct mg_pollfd *listening_socket_fds;
|
|
unsigned int num_listening_sockets;
|
|
unsigned int num_listening_sockets;
|
|
|
|
|
|
struct mg_connection *worker_connections; /* The connection struct, pre-
|
|
struct mg_connection *worker_connections; /* The connection struct, pre-
|
|
@@ -5387,13 +5389,16 @@ mg_readdir(DIR *dir)
|
|
|
|
|
|
|
|
|
|
#if !defined(HAVE_POLL)
|
|
#if !defined(HAVE_POLL)
|
|
|
|
+#undef POLLIN
|
|
|
|
+#undef POLLPRI
|
|
|
|
+#undef POLLOUT
|
|
#define POLLIN (1) /* Data ready - read will not block. */
|
|
#define POLLIN (1) /* Data ready - read will not block. */
|
|
#define POLLPRI (2) /* Priority data ready. */
|
|
#define POLLPRI (2) /* Priority data ready. */
|
|
#define POLLOUT (4) /* Send queue not full - write will not block. */
|
|
#define POLLOUT (4) /* Send queue not full - write will not block. */
|
|
|
|
|
|
FUNCTION_MAY_BE_UNUSED
|
|
FUNCTION_MAY_BE_UNUSED
|
|
static int
|
|
static int
|
|
-poll(struct pollfd *pfd, unsigned int n, int milliseconds)
|
|
|
|
|
|
+poll(struct mg_pollfd *pfd, unsigned int n, int milliseconds)
|
|
{
|
|
{
|
|
struct timeval tv;
|
|
struct timeval tv;
|
|
fd_set rset;
|
|
fd_set rset;
|
|
@@ -6062,7 +6067,7 @@ get_random(void)
|
|
|
|
|
|
|
|
|
|
static int
|
|
static int
|
|
-mg_poll(struct pollfd *pfd,
|
|
|
|
|
|
+mg_poll(struct mg_pollfd *pfd,
|
|
unsigned int n,
|
|
unsigned int n,
|
|
int milliseconds,
|
|
int milliseconds,
|
|
volatile int *stop_server)
|
|
volatile int *stop_server)
|
|
@@ -6226,7 +6231,7 @@ push_inner(struct mg_context *ctx,
|
|
mg_sleep(5);
|
|
mg_sleep(5);
|
|
} else {
|
|
} else {
|
|
/* For sockets, wait for the socket using poll */
|
|
/* For sockets, wait for the socket using poll */
|
|
- struct pollfd pfd[1];
|
|
|
|
|
|
+ struct mg_pollfd pfd[1];
|
|
int pollres;
|
|
int pollres;
|
|
|
|
|
|
pfd[0].fd = sock;
|
|
pfd[0].fd = sock;
|
|
@@ -6367,7 +6372,7 @@ pull_inner(FILE *fp,
|
|
|
|
|
|
} else if (conn->ssl != NULL) {
|
|
} else if (conn->ssl != NULL) {
|
|
|
|
|
|
- struct pollfd pfd[1];
|
|
|
|
|
|
+ struct mg_pollfd pfd[1];
|
|
int pollres;
|
|
int pollres;
|
|
|
|
|
|
pfd[0].fd = conn->client.sock;
|
|
pfd[0].fd = conn->client.sock;
|
|
@@ -6406,7 +6411,7 @@ pull_inner(FILE *fp,
|
|
#endif
|
|
#endif
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- struct pollfd pfd[1];
|
|
|
|
|
|
+ struct mg_pollfd pfd[1];
|
|
int pollres;
|
|
int pollres;
|
|
|
|
|
|
pfd[0].fd = conn->client.sock;
|
|
pfd[0].fd = conn->client.sock;
|
|
@@ -8916,7 +8921,7 @@ connect_socket(struct mg_context *ctx /* may be NULL */,
|
|
#endif
|
|
#endif
|
|
|
|
|
|
/* Data for poll */
|
|
/* Data for poll */
|
|
- struct pollfd pfd[1];
|
|
|
|
|
|
+ struct mg_pollfd pfd[1];
|
|
int pollres;
|
|
int pollres;
|
|
int ms_wait = 10000; /* 10 second timeout */
|
|
int ms_wait = 10000; /* 10 second timeout */
|
|
|
|
|
|
@@ -14466,7 +14471,7 @@ set_ports_option(struct mg_context *phys_ctx)
|
|
struct vec vec;
|
|
struct vec vec;
|
|
struct socket so, *ptr;
|
|
struct socket so, *ptr;
|
|
|
|
|
|
- struct pollfd *pfd;
|
|
|
|
|
|
+ struct mg_pollfd *pfd;
|
|
union usa usa;
|
|
union usa usa;
|
|
socklen_t len;
|
|
socklen_t len;
|
|
int ip_version;
|
|
int ip_version;
|
|
@@ -14690,7 +14695,7 @@ set_ports_option(struct mg_context *phys_ctx)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if ((pfd = (struct pollfd *)
|
|
|
|
|
|
+ if ((pfd = (struct mg_pollfd *)
|
|
mg_realloc_ctx(phys_ctx->listening_socket_fds,
|
|
mg_realloc_ctx(phys_ctx->listening_socket_fds,
|
|
(phys_ctx->num_listening_sockets + 1)
|
|
(phys_ctx->num_listening_sockets + 1)
|
|
* sizeof(phys_ctx->listening_socket_fds[0]),
|
|
* sizeof(phys_ctx->listening_socket_fds[0]),
|
|
@@ -18047,7 +18052,7 @@ master_thread_run(void *thread_func_param)
|
|
{
|
|
{
|
|
struct mg_context *ctx = (struct mg_context *)thread_func_param;
|
|
struct mg_context *ctx = (struct mg_context *)thread_func_param;
|
|
struct mg_workerTLS tls;
|
|
struct mg_workerTLS tls;
|
|
- struct pollfd *pfd;
|
|
|
|
|
|
+ struct mg_pollfd *pfd;
|
|
unsigned int i;
|
|
unsigned int i;
|
|
unsigned int workerthreadcount;
|
|
unsigned int workerthreadcount;
|
|
|
|
|