Showing 2 changed files with 12 additions and 8 deletions
+1 -1
lib/Gitprep.pm
... ...
@@ -347,7 +347,7 @@ sub startup {
347 347
   }
348 348
   
349 349
   # Smart HTTP Buffer size
350
-  $ENV{GITPREP_SMART_HTTP_BUFFER_SIZE} ||= 8192;
350
+  $ENV{GITPREP_SMART_HTTP_BUFFER_SIZE} ||= 16384;
351 351
 }
352 352
 
353 353
 1;
+11 -7
templates/smart-http/service.html.ep
... ...
@@ -33,18 +33,21 @@
33 33
   $self->render_later;
34 34
   
35 35
   # Write
36
-  my $buf = '';
37 36
   my $s = IO::Select->new($cout, $cerr);
38 37
   my $buffer_size = $ENV{GITPREP_SMART_HTTP_BUFFER_SIZE};
39 38
   my $cb;
39
+  my $error;
40
+  my $output;
41
+  my @ready;
40 42
   $cb = sub {
41 43
     my $c = shift;
42
-    if (my @ready = $s->can_read) {
43
-      my $error;
44
-      my $output = '';
45
-      
44
+    if (@ready = $s->can_read) {
45
+      $output = '';
46 46
       for my $handle (@ready) {
47
-        while (sysread($handle, $buf, $buffer_size)) {
47
+        
48
+        if (sysread($handle, my $buf, $buffer_size)) {
49
+          #warn `ps axuww|grep gitprep` if $k % 3000 == 0;
50
+          
48 51
           if ($handle == $cerr) {
49 52
             $error .= $buf;
50 53
           }
... ...
@@ -54,10 +57,11 @@
54 57
         }
55 58
         $s->remove($handle) if eof($handle);
56 59
       }
57
-      app->log->error($error) if defined $error;
58 60
       $c->write_chunk($output, $cb);
59 61
     }
60 62
     else {
63
+      app->log->error($error) if defined $error;
64
+      $c->finish;
61 65
       close $cout;
62 66
       close $cerr;
63 67
       waitpid($pid, 0);