Permalink
Browse files

Adjust number of file descriptors for Windows

Define `FD_SETSIZE` unless it is already present in Ruby configuration.

This works around `FD_SETSIZE` not defined in some releases of
RubyInstaller and solve the segfault caused by mismatch value between
Ruby and the extension.
  • Loading branch information...
1 parent 5c66eea commit 842bbe4cb5925d211255e24acb8fec45982a2c1d @luislavena luislavena committed Jun 21, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 ext/extconf.rb
View
@@ -87,6 +87,15 @@ def manual_ssl_config
add_define "HAVE_KQUEUE" if have_header("sys/event.h") and have_header("sys/queue.h")
end
+# Adjust number of file descriptors (FD) on Windows
+
+if RbConfig::CONFIG["host_os"] =~ /mingw/
+ found = RbConfig::CONFIG.values_at("CFLAGS", "CPPFLAGS").
+ any? { |v| v.include?("FD_SETSIZE") }
+
+ add_define "FD_SETSIZE=32767" unless found
+end
+
# Main platform invariances:
case RUBY_PLATFORM
@@ -163,4 +172,4 @@ def manual_ssl_config
SRC
TRY_LINK.sub!('$(CXX)', '$(CC)')
-create_makefile "rubyeventmachine"
+create_makefile "rubyeventmachine"

0 comments on commit 842bbe4

Please sign in to comment.