J
Jim Surname
It seems that a number of people have run into this problem in different
situations. In my case, I have a large form in my Rails app with file
uploads (enctype="multipart/form-data").
When the form is submitted, the read_multipart method in CGI creates a
Tempfile for every element until the maximum number of open files is
reached and the process deadlocks.
The attached script will try to open new files forever. On my machine,
before updating Ruby, the script dies when trying to open the 510th
file.
On most platforms (not Windows), increasing the open file limit is
simple. The problem lies in the C Run-Time libs. This link explains the
situation better than I can:
http://msdn2.microsoft.com/en-us/library/6e3b887c(VS.71).aspx
I was able to increase the limit by adding a call to _setmaxstdio in the
Ruby main.c file and then compiling everything from source. Of course, I
can forsee my form growing in size to more than 2048 elements.
The ultimate fix will be to use the Win32 API or MFC for dealing with
files on Windows instead of the C Run-Time API, which should up the
limit to some insanely high number.
Attachments:
http://www.ruby-forum.com/attachment/1348/too_many_open_files.rb
situations. In my case, I have a large form in my Rails app with file
uploads (enctype="multipart/form-data").
When the form is submitted, the read_multipart method in CGI creates a
Tempfile for every element until the maximum number of open files is
reached and the process deadlocks.
The attached script will try to open new files forever. On my machine,
before updating Ruby, the script dies when trying to open the 510th
file.
On most platforms (not Windows), increasing the open file limit is
simple. The problem lies in the C Run-Time libs. This link explains the
situation better than I can:
http://msdn2.microsoft.com/en-us/library/6e3b887c(VS.71).aspx
I was able to increase the limit by adding a call to _setmaxstdio in the
Ruby main.c file and then compiling everything from source. Of course, I
can forsee my form growing in size to more than 2048 elements.
The ultimate fix will be to use the Win32 API or MFC for dealing with
files on Windows instead of the C Run-Time API, which should up the
limit to some insanely high number.
Attachments:
http://www.ruby-forum.com/attachment/1348/too_many_open_files.rb