*/
#include <config.h>
+
+#ifndef DISABLE_SOCKETS
+
#include <glib.h>
#include <pthread.h>
#include <errno.h>
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
-#include <sys/poll.h>
#ifdef HAVE_SYS_FILIO_H
#include <sys/filio.h> /* defines FIONBIO and FIONREAD */
#endif
#include <mono/io-layer/socket-private.h>
#include <mono/io-layer/handles-private.h>
#include <mono/io-layer/socket-wrappers.h>
+#include <mono/utils/mono-poll.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
}
if (connect (fd, serv_addr, addrlen) == -1) {
- struct pollfd fds;
+ mono_pollfd fds;
int so_error;
socklen_t len;
fds.fd = fd;
fds.events = POLLOUT;
- while (poll (&fds, 1, -1) == -1 &&
+ while (mono_poll (&fds, 1, -1) == -1 &&
!_wapi_thread_cur_apc_pending ()) {
if (errno != EINTR) {
errnum = errno_to_WSA (errno, __func__);
g_message ("%s: send error: %s", __func__, strerror (errno));
#endif
+#ifdef O_NONBLOCK
+ /* At least linux returns EAGAIN/EWOULDBLOCK when the timeout has been set on
+ * a blocking socket. See bug #599488 */
+ if (errnum == EAGAIN) {
+ ret = fcntl (fd, F_GETFL, 0);
+ if (ret != -1 && (ret & O_NONBLOCK) == 0)
+ errnum = ETIMEDOUT;
+ }
+#endif /* O_NONBLOCK */
errnum = errno_to_WSA (errnum, __func__);
WSASetLastError (errnum);
*sent = ret;
return 0;
}
+
+#endif /* ifndef DISABLE_SOCKETS */