mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-10 16:06:09 +00:00
eventfd-style signaling removed
This commit is contained in:
parent
37128b7b1a
commit
1ffc6dd41f
26
configure.in
26
configure.in
@ -228,32 +228,6 @@ AC_HEADER_STDC
|
|||||||
AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \
|
AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \
|
||||||
stdlib.h string.h sys/socket.h sys/time.h unistd.h limits.h)
|
stdlib.h string.h sys/socket.h sys/time.h unistd.h limits.h)
|
||||||
|
|
||||||
# Force not to use eventfd
|
|
||||||
AC_ARG_ENABLE([eventfd], [AS_HELP_STRING([--disable-eventfd], [disable eventfd [default=no]])],
|
|
||||||
[disable_eventfd=yes], [disable_eventfd=no])
|
|
||||||
|
|
||||||
eventfd_headers="no"
|
|
||||||
eventfd_can_run="no"
|
|
||||||
|
|
||||||
if test "x$disable_eventfd" != "xyes"; then
|
|
||||||
# Check if we have eventfd.h header file.
|
|
||||||
AC_CHECK_HEADERS(sys/eventfd.h, [eventfd_headers=yes])
|
|
||||||
|
|
||||||
AC_MSG_CHECKING([for sys/eventfd.h functionality])
|
|
||||||
|
|
||||||
AC_RUN_IFELSE(
|
|
||||||
[AC_LANG_PROGRAM([[#include <sys/eventfd.h>
|
|
||||||
#include <assert.h>]],
|
|
||||||
[[int fd = eventfd (0, 0); assert (fd != -1);]])],
|
|
||||||
[eventfd_can_run=yes], [], eventfd_can_run=no)
|
|
||||||
|
|
||||||
AC_MSG_RESULT([$eventfd_can_run])
|
|
||||||
|
|
||||||
if test "x$eventfd_headers" = "xyes" -a "x$eventfd_can_run" = "xyes"; then
|
|
||||||
AC_DEFINE(ZMQ_HAVE_EVENTFD, 1,[Have eventfd extension.])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if we have ifaddrs.h header file.
|
# Check if we have ifaddrs.h header file.
|
||||||
AC_CHECK_HEADERS(ifaddrs.h, [AC_DEFINE(ZMQ_HAVE_IFADDRS, 1, [Have ifaddrs.h header.])])
|
AC_CHECK_HEADERS(ifaddrs.h, [AC_DEFINE(ZMQ_HAVE_IFADDRS, 1, [Have ifaddrs.h header.])])
|
||||||
|
|
||||||
|
@ -32,83 +32,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_EVENTFD
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
|
|
||||||
#include <sys/eventfd.h>
|
|
||||||
|
|
||||||
zmq::signaler_t::signaler_t ()
|
|
||||||
{
|
|
||||||
// Create eventfd object.
|
|
||||||
fd = eventfd (0, 0);
|
|
||||||
errno_assert (fd != -1);
|
|
||||||
|
|
||||||
// Set to non-blocking mode.
|
|
||||||
int flags = fcntl (fd, F_GETFL, 0);
|
|
||||||
if (flags == -1)
|
|
||||||
flags = 0;
|
|
||||||
int rc = fcntl (fd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
errno_assert (rc != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
zmq::signaler_t::~signaler_t ()
|
|
||||||
{
|
|
||||||
int rc = close (fd);
|
|
||||||
errno_assert (rc != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void zmq::signaler_t::signal (int signal_)
|
|
||||||
{
|
|
||||||
zmq_assert (signal_ >= 0 && signal_ < 64);
|
|
||||||
uint64_t inc = 1;
|
|
||||||
inc <<= signal_;
|
|
||||||
ssize_t sz = write (fd, &inc, sizeof (uint64_t));
|
|
||||||
errno_assert (sz == sizeof (uint64_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t zmq::signaler_t::poll ()
|
|
||||||
{
|
|
||||||
// Set to blocking mode.
|
|
||||||
int flags = fcntl (fd, F_GETFL, 0);
|
|
||||||
if (flags == -1)
|
|
||||||
flags = 0;
|
|
||||||
int rc = fcntl (fd, F_SETFL, flags & ~O_NONBLOCK);
|
|
||||||
errno_assert (rc != -1);
|
|
||||||
|
|
||||||
uint64_t signals;
|
|
||||||
ssize_t sz;
|
|
||||||
while (true) {
|
|
||||||
sz = read (fd, &signals, sizeof (uint64_t));
|
|
||||||
if (sz == -1) {
|
|
||||||
if (errno == EAGAIN || errno == EINTR)
|
|
||||||
continue;
|
|
||||||
errno_assert (false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set to non-blocking mode.
|
|
||||||
rc = fcntl (fd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
errno_assert (rc != -1);
|
|
||||||
|
|
||||||
return signals;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t zmq::signaler_t::check ()
|
|
||||||
{
|
|
||||||
uint64_t signals;
|
|
||||||
ssize_t sz = read (fd, &signals, sizeof (uint64_t));
|
|
||||||
if (sz == -1 && (errno == EAGAIN || errno == EINTR))
|
|
||||||
return 0;
|
|
||||||
errno_assert (sz != -1);
|
|
||||||
return signals;
|
|
||||||
}
|
|
||||||
|
|
||||||
zmq::fd_t zmq::signaler_t::get_fd ()
|
|
||||||
{
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined ZMQ_HAVE_WINDOWS
|
|
||||||
|
|
||||||
zmq::signaler_t::signaler_t ()
|
zmq::signaler_t::signaler_t ()
|
||||||
{
|
{
|
||||||
|
@ -58,17 +58,11 @@ namespace zmq
|
|||||||
// meantime, we'll create the socket pair manually.
|
// meantime, we'll create the socket pair manually.
|
||||||
static int socketpair (int domain_, int type_, int protocol_,
|
static int socketpair (int domain_, int type_, int protocol_,
|
||||||
int sv_ [2]);
|
int sv_ [2]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined ZMQ_HAVE_EVENTFD
|
|
||||||
// Eventfd descriptor.
|
|
||||||
fd_t fd;
|
|
||||||
#else
|
|
||||||
// Write & read end of the socketpair.
|
// Write & read end of the socketpair.
|
||||||
fd_t w;
|
fd_t w;
|
||||||
fd_t r;
|
fd_t r;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Disable copying of fd_signeler object.
|
// Disable copying of fd_signeler object.
|
||||||
signaler_t (const signaler_t&);
|
signaler_t (const signaler_t&);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user