Skip to content

Commit

Permalink
Merge branch 'bug-4093'
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Apr 9, 2012
2 parents 31ca079 + ff95406 commit 4638731
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
9 changes: 7 additions & 2 deletions mapgd.c
Expand Up @@ -51,9 +51,14 @@ int msGDSetup() {
return MS_SUCCESS;
}

void msGDCleanup() {
void msGDCleanup(int signal) {
#ifdef USE_GD_FT
gdFontCacheShutdown();
if(!signal) {
/* there's a potential deadlock if we're killed by a signal and the font
cache is already locked. We don't tear down the fontcache in this case
to avoid it (issue 4093)*/
gdFontCacheShutdown();
}
#endif
}

Expand Down
13 changes: 6 additions & 7 deletions mapserv.c
Expand Up @@ -44,7 +44,6 @@ MS_CVSID("$Id$")
/************************************************************************/
/* FastCGI cleanup functions. */
/************************************************************************/
static int exitSignal;
#ifndef WIN32
void msCleanupOnSignal( int nInData )
{
Expand All @@ -53,7 +52,8 @@ void msCleanupOnSignal( int nInData )
/* normal stdio functions. */
msIO_installHandlers( NULL, NULL, NULL );
msIO_fprintf( stderr, "In msCleanupOnSignal.\n" );
exitSignal = 1;
msCleanup(1);
exit(0);
}
#endif

Expand All @@ -70,7 +70,7 @@ void msCleanupOnExit( void )
fprintf( fp_out, "In msCleanupOnExit\n" );
fclose( fp_out );
#endif
msCleanup();
msCleanup(1);
}
#endif

Expand All @@ -83,13 +83,12 @@ int main(int argc, char *argv[]) {
struct mstimeval execstarttime, execendtime;
struct mstimeval requeststarttime, requestendtime;
mapservObj* mapserv = NULL;
exitSignal = 0;
msSetup();

/* Use MS_ERRORFILE and MS_DEBUGLEVEL env vars if set */
if( msDebugInitFromEnv() != MS_SUCCESS ) {
msCGIWriteError(mapserv);
msCleanup();
msCleanup(0);
exit(0);
}

Expand Down Expand Up @@ -162,7 +161,7 @@ int main(int argc, char *argv[]) {

/* In FastCGI case we loop accepting multiple requests. In normal CGI */
/* use we only accept and process one request. */
while( !exitSignal && FCGI_Accept() >= 0 ) {
while( FCGI_Accept() >= 0 ) {
#endif /* def USE_FASTCGI */
/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -229,6 +228,6 @@ int main(int argc, char *argv[]) {
(execendtime.tv_sec+execendtime.tv_usec/1.0e6)-
(execstarttime.tv_sec+execstarttime.tv_usec/1.0e6) );
}
msCleanup();
msCleanup(0);
exit( 0 );
}
4 changes: 2 additions & 2 deletions mapserver.h
Expand Up @@ -1731,7 +1731,7 @@ struct layerVTable {
MS_DLL_EXPORT int msSaveImage(mapObj *map, imageObj *img, char *filename);
MS_DLL_EXPORT void msFreeImage(imageObj *img);
MS_DLL_EXPORT int msSetup(void);
MS_DLL_EXPORT void msCleanup(void);
MS_DLL_EXPORT void msCleanup(int signal);
MS_DLL_EXPORT mapObj *msLoadMapFromString(char *buffer, char *new_mappath);

/* Function prototypes, not wrapable */
Expand Down Expand Up @@ -2265,7 +2265,7 @@ MS_DLL_EXPORT imageObj *msImageCreateIM(int width, int height, outputFormatObj *
MS_DLL_EXPORT imageObj *msImageLoadGD( const char *filename );
MS_DLL_EXPORT imageObj *msImageLoadGDCtx( gdIOCtx *ctx, const char *driver );
MS_DLL_EXPORT int msGDSetup();
MS_DLL_EXPORT void msGDCleanup();
MS_DLL_EXPORT void msGDCleanup(int signal);
#endif
MS_DLL_EXPORT void msImageStartLayerIM(mapObj *map, layerObj *layer, imageObj *image);
MS_DLL_EXPORT int msSaveImageIM(imageObj* img, char *filename, outputFormatObj *format);
Expand Down
4 changes: 2 additions & 2 deletions maputil.c
Expand Up @@ -1881,7 +1881,7 @@ int msSetup()

/* This is intended to be a function to cleanup anything that "hangs around"
when all maps are destroyed, like Registered GDAL drivers, and so forth. */
void msCleanup()
void msCleanup(int signal)
{
msForceTmpFileBase( NULL );
msConnPoolFinalCleanup();
Expand Down Expand Up @@ -1911,7 +1911,7 @@ void msCleanup()
#endif

#ifdef USE_GD
msGDCleanup();
msGDCleanup(signal);
#endif

#ifdef USE_GEOS
Expand Down
14 changes: 7 additions & 7 deletions shp2img.c
Expand Up @@ -119,7 +119,7 @@ int main(int argc, char *argv[])
if ( msDebugInitFromEnv() != MS_SUCCESS )
{
msWriteError(stderr);
msCleanup();
msCleanup(0);
exit(1);
}

Expand All @@ -129,7 +129,7 @@ int main(int argc, char *argv[])
map = msLoadMap(argv[i+1], NULL);
if(!map) {
msWriteError(stderr);
msCleanup();
msCleanup(0);
exit(1);
}
msApplyDefaultSubstitutions(map);
Expand All @@ -138,7 +138,7 @@ int main(int argc, char *argv[])

if(!map) {
fprintf(stderr, "Mapfile (-m) option not specified.\n");
msCleanup();
msCleanup(0);
exit(1);
}

Expand Down Expand Up @@ -243,7 +243,7 @@ int main(int argc, char *argv[])
if( argc <= i+4 ) {
fprintf( stderr,
"Argument -e needs 4 space separated numbers as argument.\n" );
msCleanup();
msCleanup(0);
exit(1);
}
map->extent.minx = atof(argv[i+1]);
Expand Down Expand Up @@ -271,7 +271,7 @@ int main(int argc, char *argv[])
}
if (layer_found==0) {
fprintf(stderr, "Layer (-l) \"%s\" not found\n", layers[j]);
msCleanup();
msCleanup(0);
exit(1);
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ int main(int argc, char *argv[])
msWriteError(stderr);

msFreeMap(map);
msCleanup();
msCleanup(0);
exit(1);
}

Expand All @@ -321,7 +321,7 @@ int main(int argc, char *argv[])
(requeststarttime.tv_sec+requeststarttime.tv_usec/1.0e6) );
}

msCleanup();
msCleanup(0);

} /* for(draws=0; draws<iterations; draws++) { */
return(0);
Expand Down

0 comments on commit 4638731

Please sign in to comment.