Commit 082b6aa6 authored by Simon Giesecke's avatar Simon Giesecke

Problem: epoll not supported under Windows

Solution: Use wepoll on Windows
parent c62df64b
...@@ -182,6 +182,11 @@ else () ...@@ -182,6 +182,11 @@ else ()
message (FATAL_ERROR "Invalid polling method") message (FATAL_ERROR "Invalid polling method")
endif () endif ()
if (POLLER STREQUAL "epoll" AND WIN32)
message (STATUS "Including wepoll")
list (APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/external/wepoll/wepoll.c ${CMAKE_CURRENT_SOURCE_DIR}/external/wepoll/wepoll.h)
endif()
if (API_POLLER STREQUAL "") if (API_POLLER STREQUAL "")
if (POLLER STREQUAL "select") if (POLLER STREQUAL "select")
set (API_POLLER "select") set (API_POLLER "select")
...@@ -886,8 +891,9 @@ endif () ...@@ -886,8 +891,9 @@ endif ()
if (MSVC) if (MSVC)
# default for all sources is to use precompiled headers # default for all sources is to use precompiled headers
foreach(source ${sources}) foreach(source ${sources})
if (NOT ${source} STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp") # C and C++ can not use the same precompiled header
if (${soruce} MATCHES ".cpp$" AND NOT ${source} STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp")
set_source_files_properties(${source} set_source_files_properties(${source}
PROPERTIES PROPERTIES
COMPILE_FLAGS "/Yuprecompiled.hpp" COMPILE_FLAGS "/Yuprecompiled.hpp"
...@@ -901,11 +907,6 @@ if (MSVC) ...@@ -901,11 +907,6 @@ if (MSVC)
COMPILE_FLAGS "/Ycprecompiled.hpp" COMPILE_FLAGS "/Ycprecompiled.hpp"
OBJECT_OUTPUTS precompiled.hpp OBJECT_OUTPUTS precompiled.hpp
) )
# C and C++ can not use the same precompiled header
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/tweetnacl.c
PROPERTIES
COMPILE_FLAGS "/Y-"
)
endif () endif ()
......
...@@ -28,23 +28,29 @@ ...@@ -28,23 +28,29 @@
*/ */
#include "precompiled.hpp" #include "precompiled.hpp"
#include "epoll.hpp"
#if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL #if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL
#include "epoll.hpp"
#if !defined ZMQ_HAVE_WINDOWS
#include <unistd.h>
#endif
#include <sys/epoll.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <signal.h> #include <signal.h>
#include <algorithm> #include <algorithm>
#include <new> #include <new>
#include "macros.hpp" #include "macros.hpp"
#include "epoll.hpp"
#include "err.hpp" #include "err.hpp"
#include "config.hpp" #include "config.hpp"
#include "i_poll_events.hpp" #include "i_poll_events.hpp"
#ifdef ZMQ_HAVE_WINDOWS
const zmq::epoll_t::epoll_fd_t zmq::epoll_t::epoll_retired_fd =
INVALID_HANDLE_VALUE;
#endif
zmq::epoll_t::epoll_t (const zmq::thread_ctx_t &ctx_) : zmq::epoll_t::epoll_t (const zmq::thread_ctx_t &ctx_) :
worker_poller_base_t (ctx_) worker_poller_base_t (ctx_)
{ {
...@@ -56,7 +62,7 @@ zmq::epoll_t::epoll_t (const zmq::thread_ctx_t &ctx_) : ...@@ -56,7 +62,7 @@ zmq::epoll_t::epoll_t (const zmq::thread_ctx_t &ctx_) :
#else #else
epoll_fd = epoll_create (1); epoll_fd = epoll_create (1);
#endif #endif
errno_assert (epoll_fd != -1); errno_assert (epoll_fd != epoll_retired_fd);
} }
zmq::epoll_t::~epoll_t () zmq::epoll_t::~epoll_t ()
...@@ -64,7 +70,11 @@ zmq::epoll_t::~epoll_t () ...@@ -64,7 +70,11 @@ zmq::epoll_t::~epoll_t ()
// Wait till the worker thread exits. // Wait till the worker thread exits.
stop_worker (); stop_worker ();
#ifdef ZMQ_HAVE_WINDOWS
epoll_close (epoll_fd);
#else
close (epoll_fd); close (epoll_fd);
#endif
for (retired_t::iterator it = retired.begin (); it != retired.end (); for (retired_t::iterator it = retired.begin (); it != retired.end ();
++it) { ++it) {
LIBZMQ_DELETE (*it); LIBZMQ_DELETE (*it);
......
...@@ -35,7 +35,12 @@ ...@@ -35,7 +35,12 @@
#if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL #if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL
#include <vector> #include <vector>
#if defined ZMQ_HAVE_WINDOWS
#include "../external/wepoll/wepoll.h"
#else
#include <sys/epoll.h> #include <sys/epoll.h>
#endif
#include "ctx.hpp" #include "ctx.hpp"
#include "fd.hpp" #include "fd.hpp"
...@@ -70,11 +75,22 @@ class epoll_t : public worker_poller_base_t ...@@ -70,11 +75,22 @@ class epoll_t : public worker_poller_base_t
static int max_fds (); static int max_fds ();
private: private:
#if defined ZMQ_HAVE_WINDOWS
typedef HANDLE epoll_fd_t;
static const epoll_fd_t epoll_retired_fd;
#else
typedef fd_t epoll_fd_t;
enum
{
epoll_retired_fd = retired_fd
};
#endif
// Main event loop. // Main event loop.
void loop (); void loop ();
// Main epoll file descriptor // Main epoll file descriptor
fd_t epoll_fd; epoll_fd_t epoll_fd;
struct poll_entry_t struct poll_entry_t
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment