From 2035b33670c2ebebce0f945495da85334af8ff50 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 15 Aug 2009 17:19:08 +0000 Subject: [PATCH] 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 --- net/recvfrom.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/recvfrom.c b/net/recvfrom.c index e5fc27ac6a..2eaba9f133 100644 --- a/net/recvfrom.c +++ b/net/recvfrom.c @@ -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; }