MapServer / MapServer-import

3 stars 2 forks source link

WMS image output problems when FASTCGI is enabled #1153

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: bartvde@osgis.nl Date: 2004/12/31 - 15:31

Mapserv does produce an image, as does shp2img, the images cannot be displayed
though and seem to be mucked up.

I will make an attachment showing the mucked up output against a correct one.
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2005/01/03 - 16:05

This seems to be fixed after applying the fixes Frank has suggested to libfcgi.

binary io patch

It is critical that stdio be in binary mode when PNG and other binary images are
written to it. To accomplish this for stdio handled through the FastCGI library,
I had to do the following hack to libfcgi/fcgi_stdio.c within the fcgi-2.4.0
distribution.

In FCGI_Accept() made he following change:

    if(isCGI) {
        FCGI_stdin->stdio_stream = stdin;
        FCGI_stdin->fcgx_stream = NULL;
        FCGI_stdout->stdio_stream = stdout;
        FCGI_stdout->fcgx_stream = NULL;
        FCGI_stderr->stdio_stream = stderr;
        FCGI_stderr->fcgx_stream = NULL;

        /* FrankWarmerdam: added so that returning PNG and other binary data
           will still work */
  #ifdef _WIN32
        _setmode( _fileno(stdout), _O_BINARY);
  #endif

    } else {

Also, add the following just before the FCGI_Accept() function:

  #ifdef _WIN32
  #include <fcntl.h>
  #include <io.h>
  #endif

http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?FastCGIOnWin32