Hi,
Sorry to be late.
Katarina WONG wrote:
> I am trying to use send_fd under Apache 2.0.50 (with mod_ruby svn
> revision 30) but no luck. This code
> works fine with Apache 1.3.31 but when launched under 2.0.50, the
> answering httpd starts eating up all the CPU with no response.
(snip)
> File.open( fileName ) { |file| r.send_fd(file) }
Apache::Request#send_fd was broken on Apache2:(
Can you try the attaced patch?
Shugo
Index: request.c
===================================================================
--- request.c (revision 30)
+++ request.c (working copy)
@@ -1472,12 +1472,14 @@
static VALUE request_send_fd(VALUE self, VALUE io)
{
OpenFile *fptr;
+ request_data *data;
#ifdef APACHE2
apr_size_t bytes_sent;
+ apr_file_t *file;
+ int fd;
#else
long bytes_sent;
#endif
- request_data *data;
request_set_sync(self, Qtrue);
rb_apache_request_flush(self);
@@ -1486,7 +1488,11 @@
GetOpenFile(io, fptr);
#ifdef APACHE2
- ap_send_fd((apr_file_t *)fptr->f, data->request, 0, -1, &bytes_sent);
+ fd = fileno(fptr->f);
+ if (apr_os_file_put(&file, &fd, 0, data->request->pool) != APR_SUCCESS) {
+ rb_raise(rb_eIOError, "apr_os_file_put() failed");
+ }
+ ap_send_fd(file, data->request, 0, -1, &bytes_sent);
#else
bytes_sent = ap_send_fd_length(fptr->f, data->request, -1);
#endif