Permalink
Browse files

Switch off ogr-output streaming mode for non default io contexts (#4858)

  • Loading branch information...
tbonfort committed Jan 31, 2014
1 parent 74f9382 commit 3d174b45a2d9809edb674971c3b620ded2d28d50
Showing with 24 additions and 0 deletions.
  1. +17 −0 mapio.c
  2. +1 −0 mapio.h
  3. +6 −0 mapogroutput.c
View
17 mapio.c
@@ -145,6 +145,23 @@ static msIOContextGroup *msIO_GetContextGroup()
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() */
/************************************************************************/
View
@@ -108,6 +108,7 @@ extern "C" {
void MS_DLL_EXPORT msIO_Cleanup(void);
char MS_DLL_EXPORT *msIO_stripStdoutBufferContentType(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 */
View
@@ -536,6 +536,12 @@ int msOGRWriteFromQuery( mapObj *map, outputFormatObj *format, int sendheaders )
/* Determine the output datasource name to use. */
/* ==================================================================== */
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? */

0 comments on commit 3d174b4

Please sign in to comment.