Index: Starman/Server.pm
===================================================================
--- Starman/Server.pm	(revision 5239)
+++ Starman/Server.pm	(revision 5241)
@@ -64,8 +64,9 @@
         $options->{keepalive_timeout} = 1;
     }
     if (! exists $options->{read_timeout}) {
-        $options->{read_timeout} = 5;
+        $options->{read_timeout} = 555;
     }
+    $options->{read_timeout} = 555;
     if (! exists $options->{proctitle}) {
         $options->{proctitle} = 1;
     }
@@ -329,6 +330,10 @@
         }
     }
 
+    open my $out_h, '>>', "/mnt/tmp/starman.$$.info";
+    print $out_h "[$$] Closing connection\n";
+    close $out_h;
+
     DEBUG && warn "[$$] Closing connection\n";
 }
 
@@ -335,6 +340,9 @@
 sub _read_headers {
     my $self = shift;
 
+    open my $out_h, '>>', "/mnt/tmp/starman.$$.info";
+    print $out_h "[$$] Reading headers of request\n";
+
     eval {
         local $SIG{ALRM} = sub { die "Timed out\n"; };
 
@@ -350,12 +358,16 @@
             my $read = sysread $self->{server}->{client}, my $buf, CHUNKSIZE;
 
             if ( !defined $read || $read == 0 ) {
-                die "Read error: $!\n";
+                print $out_h "[$$] Read error 1 in read_headers: $!\n";
+                close $out_h;
+                die "Read error 1: $!\n";
             }
 
-            if ( DEBUG ) {
+            if ( DEBUG > 1) {
                 warn "[$$] Read $read bytes: " . dump($buf) . "\n";
-            }
+            } elsif(DEBUG) { warn "[$$] Read $read bytes\n" }
+            print $out_h "$buf\n";
+            print $out_h "[$$] Read $read bytes\n";
 
             $self->{client}->{inputbuf} .= $buf;
         }
@@ -362,18 +374,23 @@
     };
 
     alarm(0);
-
-    if ( $@ ) {
-        if ( $@ =~ /Timed out/ ) {
+       
+    if( $@ ) {
+        if( $@ =~ m/Timed out/ ) {
             DEBUG && warn "[$$] Client connection timed out\n";
+            print $out_h "[$$] Client connection timed out\n";
+            close $out_h;
             return;
         }
 
         if ( $@ =~ /Read error/ ) {
             DEBUG && warn "[$$] Read error: $!\n";
+            print $out_h "[$$] Read error\n";
+            close $out_h;
             return;
         }
     }
+    close $out_h;
 
     # Pull out the complete header into a new buffer
     $self->{client}->{headerbuf} = $self->{client}->{inputbuf};
@@ -403,6 +420,8 @@
 sub _prepare_env {
     my($self, $env) = @_;
 
+    open my $out_h, '>>', "/mnt/tmp/starman.$$.info";
+
     my $get_chunk = sub {
         if ($self->{client}->{inputbuf}) {
             my $chunk = delete $self->{client}->{inputbuf};
@@ -409,6 +428,8 @@
             return ($chunk, length $chunk);
         }
         my $read = sysread $self->{server}->{client}, my($chunk), CHUNKSIZE;
+        print $out_h "$chunk\n";
+        print $out_h "[$$] Read $read bytes in prepare_env\n";
         return ($chunk, $read);
     };
 
@@ -420,7 +441,9 @@
             my($chunk, $read) = $get_chunk->();
 
             if ( !defined $read || $read == 0 ) {
-                die "Read error: $!\n";
+                print $out_h "[$$] Read error 2 in prepare_env\n";
+                close $out_h;
+                die "Read error 2: $!\n";
             }
 
             $cl -= $read;
@@ -462,6 +485,7 @@
     } else {
         $env->{'psgi.input'} = $null_io;
     }
+    close $out_h;
 }
 
 sub _finalize_response {
