Fix an error handling bug in the fread logic

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5511 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo
2013-01-11 19:08:51 +00:00
parent eb413a9145
commit 901912f4e5
5 changed files with 26 additions and 14 deletions
+8 -8
View File
@@ -67,8 +67,8 @@
void lib_sem_initialize(FAR struct file_struct *stream)
{
/* Initialize the LIB semaphore to one (to support one-at-
* a-time access to private data sets.
/* Initialize the LIB semaphore to one (to support one-at-a-time access
* to private data sets.
*/
(void)sem_init(&stream->fs_sem, 0, 1);
@@ -98,13 +98,13 @@ void lib_take_semaphore(FAR struct file_struct *stream)
/* Take the semaphore (perhaps waiting) */
while (sem_wait(&stream->fs_sem) != 0)
{
/* The only case that an error should occr here is if
* the wait was awakened by a signal.
*/
{
/* The only case that an error should occr here is if the wait
* was awakened by a signal.
*/
ASSERT(get_errno() == EINTR);
}
ASSERT(get_errno() == EINTR);
}
/* We have it. Claim the stak and return */
-2
View File
@@ -86,5 +86,3 @@ void stream_semgive(FAR struct streamlist *list)
{
sem_post(&list->sl_sem);
}
+2 -1
View File
@@ -301,9 +301,10 @@ ssize_t lib_fread(FAR void *ptr, size_t count, FAR FILE *stream)
{
stream->fs_flags |= __FS_FLAG_EOF;
}
lib_give_semaphore(stream);
}
lib_give_semaphore(stream);
return bytes_read;
/* Error exits */