diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-18 18:13:30 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-18 18:13:30 +0000 |
commit | fadbb925a6a118790d8d661fea3956bb0f76348a (patch) | |
tree | ca4c58d32d12949e8d08cb69a652b5e3f7fd0e58 /apps/netutils/ftpd | |
parent | 376af5201c555ee163045a8103d8e592f9a1b1bc (diff) | |
download | px4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.tar.gz px4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.tar.bz2 px4-nuttx-fadbb925a6a118790d8d661fea3956bb0f76348a.zip |
Correct and error in recv() and recvfrom() return value
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4402 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/netutils/ftpd')
-rwxr-xr-x | apps/netutils/ftpd/ftpd.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/apps/netutils/ftpd/ftpd.c b/apps/netutils/ftpd/ftpd.c index f6ddf64b8..3db7b1603 100755 --- a/apps/netutils/ftpd/ftpd.c +++ b/apps/netutils/ftpd/ftpd.c @@ -796,7 +796,7 @@ static int ftpd_rxpoll(int sd, int timeout) if (ret == 0) { - nvdbg("poll() timed out\n"); + //nvdbg("poll() timed out\n"); return -ETIMEDOUT; } else if (ret < 0) @@ -870,7 +870,14 @@ static int ftpd_accept(int sd, FAR void *addr, FAR socklen_t *addrlen, ret = ftpd_rxpoll(sd, timeout); if (ret < 0) { - nvdbg("ftpd_rxpoll() failed: %d\n", ret); + /* Only report interesting, infrequent errors (not the common timeout) */ + +#ifdef CONFIG_DEBUG_NET + if (ret != -ETIMEDOUT) + { + ndbg("ftpd_rxpoll() failed: %d\n", ret); + } +#endif return ret; } } @@ -909,34 +916,18 @@ static ssize_t ftpd_recv(int sd, FAR void *data, size_t size, int timeout) } } - /* Receive the data... waiting if necessary */ + /* Receive the data... waiting if necessary. The client side will break the + * connection after the file has been sent. Zero (end-of-file) should be + * received in this case. + */ ret = recv(sd, data, size, 0); if (ret < 0) { int errval = errno; - /* Special case some TCP read errors. The client side will break the - * connection after the file has been sent. - */ -#warning FIXME - /* When the client breaks the connection, the NuttX socket layer will - * return an error with errno == ENOTCONN. This is wrong! It should - * return 0 (end-of-file) in that case! We work around the bug and - * report end-of-file for that case here. This needs to be fixed - * someday. - */ - - if (errval == ENOTCONN) - { - nvdbg("Connection lost, returning end-of-file\n"); - ret = 0; - } - else - { - ndbg("recv() failed: %d\n", errval); - return -errval; - } + ndbg("recv() failed: %d\n", errval); + return -errval; } return ret; @@ -4342,7 +4333,14 @@ int ftpd_session(FTPD_SESSION handle, int timeout) &session->cmd.addrlen, timeout); if (session->cmd.sd < 0) { - ndbg("ftpd_accept() failed: %d\n", session->cmd.sd); + /* Only report interesting, infrequent errors (not the common timeout) */ + +#ifdef CONFIG_DEBUG_NET + if (session->cmd.sd != -ETIMEDOUT) + { + ndbg("ftpd_accept() failed: %d\n", session->cmd.sd); + } +#endif ret = session->cmd.sd; goto errout_with_session; } |