in reply to Re^4: Inline C + IO::Handle
in thread FCGI + Inline::C fast stream out!

If you're interested in optimising and don't need a generic solution, then Re^2: Inline C + IO::Handle is going to be fastest. Replace MyFH with whichever namespace the FCGI handle is tied to. Magic is (relatively) slow, and this will avoid it completely.

Replies are listed 'Best First'.
Re^6: Inline C + IO::Handle
by mrakus (Initiate) on Apr 17, 2009 at 17:59 UTC
    I try to do this, but C function dont print to stream :( Maybe i have mistake in code?
    sub main { my $proc_manager = new FCGI::ProcManager({ n_processes => $PRO +CESSES}); my $socket = FCGI::OpenSocket($SOCKET, 100); my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV +, $socket); my (undef, $out, undef) = $request->GetHandles(); $proc_manager->pm_manage(); while($request->Accept() >= 0){ $proc_manager->pm_pre_dispatch(); my $cgi = CGI::Fast->new(); print "Content-type: text/html\r\n\r\n"; my_print_c($out); $proc_manager->pm_post_dispatch(); } FCGI::CloseSocket($socket); } __END__ __C__ void my_print_c(SV * fh) { dSP; ENTER; SAVETMPS; PUSHMARK(SP); XPUSHs(sv_2mortal(fh)); XPUSHs(sv_2mortal(newSVpv("TEXT", 0))); PUTBACK; call_pv("PRINT", G_DISCARD); FREETMPS; LEAVE; }

      You're doing

      PRINT($out, "TEXT");

      when you want to do

      tied(*$out)->PRINT("TEXT");
        Hmmm... I misled... :)
        I have to print text to fastcgi stream from C code, not perl code. Maybe i something not understand :(