Skip to content

Commit

Permalink
Switch off ogr-output streaming mode for non default io contexts (#4858)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Mar 7, 2014
1 parent 74f9382 commit 3d174b4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions mapio.c
Expand Up @@ -145,6 +145,23 @@ static msIOContextGroup *msIO_GetContextGroup()
return group; return group;
} }


/* returns MS_TRUE if the msIO standard output hasn't been redirected */
int msIO_isStdContext() {
msIOContextGroup *group = io_context_list;
int nThreadId = msGetThreadId();
if(!group || group->thread_id != nThreadId) {
group = msIO_GetContextGroup();
if(!group) {
return MS_FALSE; /* probably a bug */
}
}
if(group->stderr_context.cbData == (void*)stderr &&
group->stdin_context.cbData == (void*)stdin &&
group->stdout_context.cbData == (void*)stdout)
return MS_TRUE;
return MS_FALSE;
}

/************************************************************************/ /************************************************************************/
/* msIO_getHandler() */ /* msIO_getHandler() */
/************************************************************************/ /************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions mapio.h
Expand Up @@ -108,6 +108,7 @@ extern "C" {
void MS_DLL_EXPORT msIO_Cleanup(void); void MS_DLL_EXPORT msIO_Cleanup(void);
char MS_DLL_EXPORT *msIO_stripStdoutBufferContentType(void); char MS_DLL_EXPORT *msIO_stripStdoutBufferContentType(void);
void MS_DLL_EXPORT msIO_stripStdoutBufferContentHeaders(void); void MS_DLL_EXPORT msIO_stripStdoutBufferContentHeaders(void);
int MS_DLL_EXPORT msIO_isStdContext(void);


/* this is just for setting normal stdout's to binary mode on windows */ /* this is just for setting normal stdout's to binary mode on windows */


Expand Down
6 changes: 6 additions & 0 deletions mapogroutput.c
Expand Up @@ -536,6 +536,12 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
/* Determine the output datasource name to use. */ /* Determine the output datasource name to use. */
/* ==================================================================== */ /* ==================================================================== */
storage = msGetOutputFormatOption( format, "STORAGE", "filesystem" ); storage = msGetOutputFormatOption( format, "STORAGE", "filesystem" );
if( EQUAL(storage,"stream") && !msIO_isStdContext() ) {
/* bug #4858, streaming output won't work if standard output has been
* redirected, we switch to memory output in this case
*/
storage = "memory";
}


/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Where are we putting stuff? */ /* Where are we putting stuff? */
Expand Down

0 comments on commit 3d174b4

Please sign in to comment.