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 ()
message (FATAL_ERROR "Invalid polling method")
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 (POLLER STREQUAL "select")
set (API_POLLER "select")
......@@ -886,8 +891,9 @@ endif ()
if (MSVC)
# default for all sources is to use precompiled headers
foreach(source ${sources})
if (NOT ${source} STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp")
foreach(source ${sources})
# 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}
PROPERTIES
COMPILE_FLAGS "/Yuprecompiled.hpp"
......@@ -901,11 +907,6 @@ if (MSVC)
COMPILE_FLAGS "/Ycprecompiled.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 ()
......
......@@ -28,23 +28,29 @@
*/
#include "precompiled.hpp"
#include "epoll.hpp"
#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 <string.h>
#include <unistd.h>
#include <signal.h>
#include <algorithm>
#include <new>
#include "macros.hpp"
#include "epoll.hpp"
#include "err.hpp"
#include "config.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_) :
worker_poller_base_t (ctx_)
{
......@@ -56,7 +62,7 @@ zmq::epoll_t::epoll_t (const zmq::thread_ctx_t &ctx_) :
#else
epoll_fd = epoll_create (1);
#endif
errno_assert (epoll_fd != -1);
errno_assert (epoll_fd != epoll_retired_fd);
}
zmq::epoll_t::~epoll_t ()
......@@ -64,7 +70,11 @@ zmq::epoll_t::~epoll_t ()
// Wait till the worker thread exits.
stop_worker ();
#ifdef ZMQ_HAVE_WINDOWS
epoll_close (epoll_fd);
#else
close (epoll_fd);
#endif
for (retired_t::iterator it = retired.begin (); it != retired.end ();
++it) {
LIBZMQ_DELETE (*it);
......
......@@ -35,7 +35,12 @@
#if defined ZMQ_IOTHREAD_POLLER_USE_EPOLL
#include <vector>
#if defined ZMQ_HAVE_WINDOWS
#include "../external/wepoll/wepoll.h"
#else
#include <sys/epoll.h>
#endif
#include "ctx.hpp"
#include "fd.hpp"
......@@ -70,11 +75,22 @@ class epoll_t : public worker_poller_base_t
static int max_fds ();
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.
void loop ();
// Main epoll file descriptor
fd_t epoll_fd;
epoll_fd_t epoll_fd;
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