fclose() was not flushing buffered data
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3603 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
2f14661f8d
commit
6cd596fc6b
@ -1749,4 +1749,6 @@
|
||||
configuration for RGMP. RGMP is a project for running GPOS and
|
||||
RTOS simultaneously on multi-processor platforms. See
|
||||
http://rgmp.sourceforge.net/wiki/index.php/Main_Page for further
|
||||
information about RGMP.
|
||||
information about RGMP.
|
||||
* lib/stdio/lib_fclose.c: Must flush all buffered data when the file is closed.
|
||||
Instead, it was discarding the buffered data.
|
||||
|
@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: May 12, 2011</p>
|
||||
<p>Last Updated: May 13, 2011</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -2209,6 +2209,13 @@ nuttx-6.3 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
nxbe_colormap was change to nxbe_configure... apparently "search-and-replace"
|
||||
error. This error was not noticed before because most NX platforms do not use
|
||||
colormapping.
|
||||
* arch/rgmp and configs/rgmp. Add architecture support and build
|
||||
configuration for RGMP. RGMP is a project for running GPOS and
|
||||
RTOS simultaneously on multi-processor platforms. See
|
||||
http://rgmp.sourceforge.net/wiki/index.php/Main_Page for further
|
||||
information about RGMP.
|
||||
* lib/stdio/lib_fclose.c: Must flush all buffered data when the file is closed.
|
||||
Instead, it was discarding the buffered data.
|
||||
|
||||
apps-6.3 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
@ -2221,6 +2228,11 @@ apps-6.3 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
then a make error occurs because tools/mkdep.sh is called with no files.
|
||||
* system/free: Move Uros' custom free command from vsn/free
|
||||
* system/install: Add a new install command submitted by Uros Platise.
|
||||
* examples/rgmpp. Add a placeholder for an RGMP build example.
|
||||
RGMP is a project for running GPOS and RTOS simultaneously on
|
||||
multi-processor platforms. See http://rgmp.sourceforge.net/wiki/index.php/Main_Page
|
||||
for further information about RGMP. NOTE: This is an empty example
|
||||
on initial check-in.
|
||||
|
||||
pascal-3.0 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
|
||||
|
@ -50,14 +50,53 @@
|
||||
* Global Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: fclose
|
||||
*
|
||||
* Description
|
||||
* The fclose() function will flush the stream pointed to by stream
|
||||
* (writing any buffered output data using lib_fflush()) and close the
|
||||
* underlying file descriptor.
|
||||
*
|
||||
* Returned Value:
|
||||
* Upon successful completion 0 is returned. Otherwise, EOF is returned
|
||||
* and the global variable errno is set to indicate the error. In either
|
||||
* case any further access (including another call to fclose()) to the
|
||||
* stream results in undefined behaviour.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int fclose(FAR FILE *stream)
|
||||
{
|
||||
int ret = OK;
|
||||
int err = EINVAL;
|
||||
int ret = ERROR;
|
||||
|
||||
/* Verify that a stream was provided. */
|
||||
|
||||
if (stream)
|
||||
{
|
||||
/* Flush the stream */
|
||||
|
||||
ret = lib_fflush(stream, true);
|
||||
err = errno;
|
||||
|
||||
/* Close the underlying file descriptor */
|
||||
|
||||
if (stream->fs_filedes > 0)
|
||||
{
|
||||
ret = close(stream->fs_filedes);
|
||||
/* Close the file and save the return status */
|
||||
|
||||
int status = close(stream->fs_filedes);
|
||||
|
||||
/* If close() returns an error but flush() did not then make
|
||||
* sure that we return the close() error condition.
|
||||
*/
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
ret = status;
|
||||
err = errno;
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
@ -65,7 +104,7 @@ int fclose(FAR FILE *stream)
|
||||
|
||||
sem_destroy(&stream->fs_sem);
|
||||
|
||||
/* release the buffer */
|
||||
/* Release the buffer */
|
||||
|
||||
if (stream->fs_bufstart)
|
||||
{
|
||||
@ -90,6 +129,18 @@ int fclose(FAR FILE *stream)
|
||||
stream->fs_filedes = -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
/* On an error, reset the errno to the first error encountered and return
|
||||
* EOF.
|
||||
*/
|
||||
|
||||
if (ret != OK)
|
||||
{
|
||||
set_errno(err);
|
||||
return EOF;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user