Commit e6ca5da1 authored by Martin Sustrik's avatar Martin Sustrik

Windows build fixed

parent b15f6959
...@@ -70,6 +70,7 @@ uint64_t zmq::fd_signaler_t::poll () ...@@ -70,6 +70,7 @@ uint64_t zmq::fd_signaler_t::poll ()
// TODO: Can we do a blocking read on non-blocking eventfd? // TODO: Can we do a blocking read on non-blocking eventfd?
// It's not needed as for now, so let it stay unimplemented. // It's not needed as for now, so let it stay unimplemented.
zmq_assert (false); zmq_assert (false);
return 0;
} }
uint64_t zmq::fd_signaler_t::check () uint64_t zmq::fd_signaler_t::check ()
...@@ -129,7 +130,13 @@ zmq::fd_signaler_t::fd_signaler_t () ...@@ -129,7 +130,13 @@ zmq::fd_signaler_t::fd_signaler_t ()
// Accept connection from w. // Accept connection from w.
r = accept (listener, NULL, NULL); r = accept (listener, NULL, NULL);
wsa_assert (r != INVALID_SOCKET); wsa_assert (r != INVALID_SOCKET);
// Set the read site of the pair to non-blocking mode.
//unsigned long argp = 1;
//rc = ioctlsocket (r, FIONBIO, &argp);
//wsa_assert (rc != SOCKET_ERROR);
// We don't need the listening socket anymore. Close it.
rc = closesocket (listener); rc = closesocket (listener);
wsa_assert (rc != SOCKET_ERROR); wsa_assert (rc != SOCKET_ERROR);
} }
...@@ -156,25 +163,19 @@ void zmq::fd_signaler_t::signal (int signal_) ...@@ -156,25 +163,19 @@ void zmq::fd_signaler_t::signal (int signal_)
uint64_t zmq::fd_signaler_t::poll () uint64_t zmq::fd_signaler_t::poll ()
{ {
// If there are signals available, return straight away. // TODO: Can we do a blocking read on non-blocking socket?
uint64_t signals = check (); // It's not needed as for now, so let it stay unimplemented.
if (signals) zmq_assert (false);
return signals; return 0;
// If there are no signals, wait until at least one signal arrives.
unsigned char sig;
int nbytes = recv (r, (char*) &sig, 1, 0);
win_assert (nbytes != -1);
return uint64_t (1) << sig;
} }
uint64_t zmq::fd_signaler_t::check () uint64_t zmq::fd_signaler_t::check ()
{ {
unsigned char buffer [32]; unsigned char buffer [32];
int nbytes = recv (r, (char*) buffer, 32, MSG_DONTWAIT); int nbytes = recv (r, (char*) buffer, 32, 0);
if (nbytes == -1 && errno == EAGAIN) if (nbytes == -1 && WSAGetLastError () == WSAEWOULDBLOCK)
return 0; return 0;
win_assert (nbytes != -1); wsa_assert (nbytes != -1);
uint64_t signals = 0; uint64_t signals = 0;
for (int pos = 0; pos != nbytes; pos++) { for (int pos = 0; pos != nbytes; pos++) {
......
...@@ -69,16 +69,19 @@ int zmq::p2p_t::xsetsockopt (int option_, const void *optval_, ...@@ -69,16 +69,19 @@ int zmq::p2p_t::xsetsockopt (int option_, const void *optval_,
int zmq::p2p_t::xsend (struct zmq_msg_t *msg_, int flags_) int zmq::p2p_t::xsend (struct zmq_msg_t *msg_, int flags_)
{ {
zmq_assert (false); zmq_assert (false);
return 0;
} }
int zmq::p2p_t::xflush () int zmq::p2p_t::xflush ()
{ {
zmq_assert (false); zmq_assert (false);
return 0;
} }
int zmq::p2p_t::xrecv (struct zmq_msg_t *msg_, int flags_) int zmq::p2p_t::xrecv (struct zmq_msg_t *msg_, int flags_)
{ {
zmq_assert (false); zmq_assert (false);
return 0;
} }
...@@ -155,6 +155,8 @@ int zmq::rep_t::xsend (struct zmq_msg_t *msg_, int flags_) ...@@ -155,6 +155,8 @@ int zmq::rep_t::xsend (struct zmq_msg_t *msg_, int flags_)
// Detach the message from the data buffer. // Detach the message from the data buffer.
int rc = zmq_msg_init (msg_); int rc = zmq_msg_init (msg_);
zmq_assert (rc == 0); zmq_assert (rc == 0);
return 0;
} }
int zmq::rep_t::xflush () int zmq::rep_t::xflush ()
......
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