On Tue, 9 Jan 2001, Paul Buder wrote:

> I am using a CPAN module called Socket::PassAccessRights
> that uses the recvmsg and sendmsg system calls to pass
> file descriptors over a socket.  More specifically, I have a
> long living program (not modperl) that needs to communicate
> with the Apache descriptors for STDIN and STDOUT given to a CGI
> or modperl script.
> 
> The following works as an ordinary CGI but not under modperl.
> use IO::Socket;
> use Socket::PassAccessRights;
> 
> $client=IO::Socket::UNIX->new(Type => SOCK_STREAM,
> Peer => '/tmp/socket') or die $!;
> 
> Socket::PassAccessRights::sendfd(fileno($client), fileno(STDIN)) or die;
> Socket::PassAccessRights::sendfd(fileno($client), fileno(STDOUT)) or die;
> 
> # The only info my server needs from Apache other than
> # the descriptors, this is POST'ed data.
> print $client $ENV{CONTENT_LENGTH}, "\n";
> # end of script
> 
> This doesn't work under modperl.  I suspect that is because
> STDIN and STDOUT are not normal in some sense under modperl
> but I don't know enough to get any handle on it.

right, apache i/o is not stdio.  this might help, please let us know if it
does or not.  you might also need to $r->rflush before your socket thingy
writes to the fd.

Index: src/modules/perl/Apache.xs
===================================================================
RCS file: /home/cvs/modperl/src/modules/perl/Apache.xs,v
retrieving revision 1.119
diff -u -r1.119 Apache.xs
--- src/modules/perl/Apache.xs  2000/12/29 17:10:08     1.119
+++ src/modules/perl/Apache.xs  2001/01/26 06:19:30
@@ -603,7 +603,7 @@
     Apache r
 
     CODE:
-    RETVAL = fileno(stdout);
+    RETVAL = r->connection->client->fd;
 
     OUTPUT:
     RETVAL

Reply via email to