Project

General

Profile

Bug #998

fastcgi prints an additional empty line for each packet of type FCGI_STDERR

Added by Anonymous over 13 years ago. Updated almost 13 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_fastcgi
Target version:
-
ASK QUESTIONS IN Forums:

Description

every time a fastcgi script writes an error using (for example for the C API) :

FCGX_FPrintF(err, "This is an error message");

2 packets of type FCGI_STDERR are generated (the first one containing the message and the second one of length 0), but lighttpd print both generating an empty lane as shown by (from the errorlog) :

2007-01-27 23:13:02: (mod_fastcgi.c.2519) FastCGI-stderr: This is an error message
2007-01-27 23:13:02: (mod_fastcgi.c.2519) FastCGI-stderr:

attached patches for lighttpd-1.4.x and trunk with a fix that uses the same logic applied for packets of type FCGI_STDOUT

-- carenas


Files

lighttpd-1.4.x-fastcgi-quiet-error.patch (423 Bytes) lighttpd-1.4.x-fastcgi-quiet-error.patch patch for lighttpd 1.4.x's mod_fastcgi to skip printing empty error packets -- carenas Anonymous, 2007-01-28 07:32
lighttpd-fastcgi-quiet-error.patch (369 Bytes) lighttpd-fastcgi-quiet-error.patch patch for lighttpd 1.5 (trunk)'s mod_fastcgi to skip printing empty error packets -- carenas Anonymous, 2007-01-28 07:39
#1

Updated by carenas over 13 years ago

in lighttpd 1.5 the implementation used for mod_proxy_backend_fastcgi doesn't show this problem as shown in :


mod_proxy_backend_fastcgi.c.476: (trace) (fastcgi-stderr) this is an error message
mod_proxy_backend_fastcgi.c.476: (trace) (fastcgi-stderr) this is an error message
#2

Updated by carenas over 13 years ago

a fastcgi program using the fcgi_stdio emulation is shown below:


#include "fcgi_config.h" 
#include "fcgi_stdio.h" 

int main()
{
   while (FCGI_Accept() >=0) {
      printf("Content-type: text/html\r\n");
      printf("\r\n");
      printf("This is some content");
      fprintf(stderr, "This is some error");
   }
   return 0;
}

a fastcgi C program using the native API :


#include "fcgi_config.h" 
#include "fcgiapp.h" 

int main()
{
   FCGX_Stream *in, *out, *err;
   FCGX_ParamArray envp;

   while (FCGX_Accept(&int, &out, &err, &envp) >= 0) {
      FCGX_FPrintF(out, "This is some content");
      FCGX_FPrintF(err, "This is some error");
   }

   return 0;
}
#3

Updated by Anonymous over 13 years ago

this patch however doesn't solve problem with PHP-FCGI error logs:


2007-01-30 02:26:31: (mod_fastcgi.c.2504) FastCGI-stderr: error

2007-01-30 02:26:37: (mod_fastcgi.c.2504) FastCGI-stderr: error

2007-01-30 02:26:38: (mod_fastcgi.c.2504) FastCGI-stderr: error

#!ShellExample
$ cat z.php
tore
<?

error_log("error");

-- Elan Ruusamäe <glen

#4

Updated by carenas over 13 years ago

the problem with PHP is a bug in PHP not in lighttpd or fastcgi as error_log is printing a an extra "CRLF" at the end of the message

http://bugs.php.net/bug.php?id=31472

interestingly enough though this patch "fixes" the problem by redirecting stderr into the log file as can be seen if instead the following script is used :


<?php
  $stderr = fopen("php://stderr", "w");
  fputs ($stderr, "error\n");
  fclose ($stderr);
?>
#5

Updated by glen over 13 years ago

applied in r1606 and r1607.

#6

Updated by glen over 13 years ago

  • Status changed from New to Fixed
  • Resolution set to fixed

Also available in: Atom