summaryrefslogtreecommitdiff
path: root/ext/socket/rubysocket.h
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/rubysocket.h')
-rw-r--r--ext/socket/rubysocket.h23
1 files changed, 5 insertions, 18 deletions
diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
index a7755660e9..c0d40addca 100644
--- a/ext/socket/rubysocket.h
+++ b/ext/socket/rubysocket.h
@@ -432,30 +432,17 @@ NORETURN(void rsock_sys_fail_sockaddr(const char *, struct sockaddr *addr, sockl
NORETURN(void rsock_sys_fail_raddrinfo(const char *, VALUE rai));
NORETURN(void rsock_sys_fail_raddrinfo_or_sockaddr(const char *, VALUE addr, VALUE rai));
-/*
- * It is safe on Linux to attempt using a socket without waiting on it in
- * all cases. For some syscalls (e.g. accept/accept4), blocking on the
- * syscall instead of relying on select/poll allows the kernel to use
- * "wake-one" behavior and avoid the thundering herd problem.
- * This is likely safe on all other *nix-like systems, so this safe list
- * can be expanded by interested parties.
- */
-#if defined(__linux__)
-static inline int rsock_maybe_fd_writable(int fd) { return 1; }
-static inline void rsock_maybe_wait_fd(int fd) { }
-# ifdef MSG_DONTWAIT
-# define MSG_DONTWAIT_RELIABLE 1
-# endif
-#else /* some systems (mswin/mingw) need these. ref: r36946 */
-# define rsock_maybe_fd_writable(fd) rb_thread_fd_writable((fd))
-# define rsock_maybe_wait_fd(fd) rb_thread_wait_fd((fd))
+#if defined(__MINGW32__) || defined(_WIN32)
+#define RSOCK_WAIT_BEFORE_BLOCKING
#endif
/*
* some OSes may support MSG_DONTWAIT inconsistently depending on socket
* type, we only expect Linux to support it consistently for all socket types.
*/
-#ifndef MSG_DONTWAIT_RELIABLE
+#if defined(MSG_DONTWAIT) && defined(__linux__)
+# define MSG_DONTWAIT_RELIABLE 1
+#else
# define MSG_DONTWAIT_RELIABLE 0
#endif