Mercurial > ecos
changeset 2713:360689a2c1c5
* src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): Ensure the
files table can't change. Thanks to Xiaochen Zhou for the detective
work.
| author | jlarmour |
|---|---|
| date | Thu, 15 Jan 2009 03:33:52 +0000 |
| parents | 5a9dc4a9cb52 |
| children | 615dc33ccc6c |
| files | packages/language/c/libc/stdio/current/ChangeLog packages/language/c/libc/stdio/current/src/common/fflush.cxx |
| diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,9 @@ +2009-01-15 Jonathan Larmour <jifl@eCosCentric.com> + + * src/common/fflush.cxx (cyg_libc_stdio_flush_all_but): Ensure the + files table can't change. Thanks to Xiaochen Zhou for the detective + work. + 2008-07-21 Guenter Ebermann <guenter.ebermann@gmx.at> * src/common/fclose.cxx (fclose): Replace config-dependent use of
--- a/packages/language/c/libc/stdio/current/src/common/fflush.cxx +++ b/packages/language/c/libc/stdio/current/src/common/fflush.cxx @@ -82,7 +82,11 @@ cyg_libc_stdio_flush_all_but( Cyg_StdioS for (i=0; (i<FOPEN_MAX) && !err; i++) { if (files_flushed[i] == false) { - + // Don't let the files table change e.g. by closing the file. + if ( Cyg_libc_stdio_files::lock() ) { + err = EINTR; + break; + } stream = Cyg_libc_stdio_files::get_file_stream(i); if ((stream == NULL) || (stream == not_this_stream)) { @@ -118,6 +122,10 @@ cyg_libc_stdio_flush_all_but( Cyg_StdioS } } } // else + // We can unlock and relock every loop as we only care + // about flushing streams that were open prior to this + // call. Any new streams can be ignored. + Cyg_libc_stdio_files::unlock() } // if } // for } // do
