summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-13 14:39:59 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-05-13 14:39:59 +0000
commit93722421fea0a6a7d5f3dbd74c0e5f7335b9f697 (patch)
tree54b8439111db7f7e0d9b7de68bc36a8c41993fc6
parent92150c020c6ea250146d8eb82bb51fb9c1605125 (diff)
downloadnuttx-93722421fea0a6a7d5f3dbd74c0e5f7335b9f697.tar.gz
nuttx-93722421fea0a6a7d5f3dbd74c0e5f7335b9f697.tar.bz2
nuttx-93722421fea0a6a7d5f3dbd74c0e5f7335b9f697.zip
fclose() was not flushing buffered data
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3603 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-xapps/ChangeLog.txt2
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/Documentation/NuttX.html14
-rw-r--r--nuttx/lib/stdio/lib_fclose.c59
4 files changed, 72 insertions, 7 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index fb585f1e8..d52bf44f9 100755
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -46,4 +46,4 @@
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 \ No newline at end of file
+ on initial check-in.
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 919f34062..981e04717 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -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. \ No newline at end of file
+ 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.
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index e6c5a824d..592fff318 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -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 &lt;spudmonkey@racsa.co.cr&gt;
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 &lt;spudmonkey@racsa.co.cr&gt;
@@ -2221,6 +2228,11 @@ apps-6.3 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
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 &lt;spudmonkey@racsa.co.cr&gt;
diff --git a/nuttx/lib/stdio/lib_fclose.c b/nuttx/lib/stdio/lib_fclose.c
index 8d53b387b..06f970e11 100644
--- a/nuttx/lib/stdio/lib_fclose.c
+++ b/nuttx/lib/stdio/lib_fclose.c
@@ -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;
}