Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
CamlGI question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mike Hamburg <hamburg@f...>
Subject: Re: [Caml-list] CamlGI question [doh]
I'll try to help work out this bug in either Apache/FastCGI or Netcgi,
and if that doesn't work, I'll go to AJP.  I compiled mod_fastcgi-2.4.0
on Apache 2.0.53.  It successfully serves FastCGI pages written with
CamlGI, except that it sometimes pauses after 8k of data, and sometimes
breaks the pipe to the CGI.

Under Netcgi 1.0, the CGI version works but the FastCGI version does not
work at all.  The difference between the CGI and FastCGI versions is only:

let () = Netcgi_fcgi.serv main (`Direct "<br><hr><br>");
(* let cgi = new Netcgi.std_activation ()
let () =  main cgi *)

The application reads files from the outside world, and may launch
processes with fork+execv to thumbnail images.  It is multithreaded,
with at least 4 threads at all times: the main thread, a thumbnail cache
manager, a thread which handles signals (this cannot be done in a signal
handler, as it may block, so I wake up the handler thread instead), and
a thread which rereads the configuration files periodically, so that the
user does not have to send HUP.

The application usually raises Unix.Unix_error (EPIPE, "write", "") on
the line Netcgi_fcgi.serv main (`Direct "<br><hr><br>") or rather,
inside Netcgi_fcgi.serv at some point; I believe this occurs before main
is called.  The webserver also receives EPIPE and returns error 500. 
Sometimes, I get other errors: sometimes main gets called, and I get
Failure("send_output_header").  If this happens, then rollback_output
successfully prints "<br><hr><br>" but no more (i.e. no further
diagnostics).  Sometimes, the webserver times out waiting for the first
read, in which case the application still raises EPIPE.

Is there any more information that would help to debug the problem?


Alex Baretta wrote:

> If at all possible, rather than AJP I'd stick to FastCGI.  The code in
> Ocamlnet reportedly works fine, but I don't have experience with it.
> Are you sure that the broken pipe is caused by a bug in Ocamlnet and
> not in the web server?
> Alex 

Gerd Stolpmann wrote:

>Am Montag, den 18.04.2005, 23:26 -0400 schrieb Mike Hamburg:
>>I'm obviously too tired to be programming.  That should, of course, read
>>(1) fix a broken pipe error in Netcgi_fast or
>Well, we would need more details to help you.
>>(2) port the application to (and configure the webserver for) AJP
>Porting the application is quite simple, just follow the examples coming
>with Ocamlnet (in examples/jserv). For the webserver, you need mod_jk
>(jk=Jakarta). The configuration reference is here:
>Note that Ocamlnet only supports AJP-1.2, not 1.3 which is the current
>default for Tomcat.