Fix errors in return value from non-blocking read

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2018 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-08-15 17:19:08 +00:00
parent 69544599c3
commit 2035b33670
1 changed files with 9 additions and 3 deletions

View File

@ -704,7 +704,7 @@ static void recvfrom_init(FAR struct socket *psock, FAR void *buf, size_t len,
#if defined(CONFIG_NET_UDP) || defined(CONFIG_NET_TCP)
static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate)
{
int save_errno = *get_errno_ptr(); /* In case something we do changes it */
int save_errno = errno; /* In case something we do changes it */
/* Release semaphore in the state structure */
@ -896,7 +896,13 @@ static ssize_t tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
{
/* Nothing was received */
return -EAGAIN;
ret = -EAGAIN;
}
else
{
/* The return value is the number of bytes read from the read-ahead buffer */
ret = state.rf_recvlen;
}
}
@ -1091,7 +1097,7 @@ ssize_t recvfrom(int sockfd, FAR void *buf, size_t len, int flags,
return ret;
errout:
*get_errno_ptr() = err;
errno = err;
return ERROR;
}