diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-20 00:41:33 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-01-20 00:41:33 +0000 |
commit | 28a0cf4aa03e0a43d63492844ef3f3eee9da84a5 (patch) | |
tree | c6747a24d9b95fcc7d54938f8cbbcc0cd7bfca06 /nuttx | |
parent | 598b4b28793536198ffd145b895e2821334332da (diff) | |
download | px4-firmware-28a0cf4aa03e0a43d63492844ef3f3eee9da84a5.tar.gz px4-firmware-28a0cf4aa03e0a43d63492844ef3f3eee9da84a5.tar.bz2 px4-firmware-28a0cf4aa03e0a43d63492844ef3f3eee9da84a5.zip |
Yet another repair for the previouis botched recvfrom() fix; Fix telnet driver: It needs to break out of the read loop if 0 (meaning not conneced) of a value < 0 (an error) is encountered.
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5541 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/ChangeLog | 3 | ||||
-rw-r--r-- | nuttx/net/recvfrom.c | 43 |
2 files changed, 28 insertions, 18 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 80944db66..77441dd21 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3993,3 +3993,6 @@ (gracefully). recv[from]() returned success and the closure was never detected. Hmmm.. I don't know why the network monitor did not catch this event. This is an important bug fix. + * net/recvfrom(): Fix a introduced with the last bugfix. If + the peer does an orderly closure of the socket, report 0 not + -ENOTCONN diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index ac8065f81..a1a6742c5 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -571,40 +571,47 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, * gracefully disconnected * _SF_CONNECTED==0 && _SF_CLOSED==0 - the socket was * rudely disconnected - * - * These flag settings are probably not necessary if - * CONFIG_NET_TCP_RECVDELAY == 0; in that case we know that - * pstate->rf_recvlen == 0 and we will always return -ENOTCONN. */ psock = pstate->rf_sock; if ((flags & UIP_CLOSE) != 0) { + /* Report that the connection was gracefully closed */ + psock->s_flags &= ~_SF_CONNECTED; psock->s_flags |= _SF_CLOSED; + + /* This case should always return success (zero)! The value of + * rf_recvlen, if zero, will indicate that the connection was + * gracefully closed. + */ + + pstate->rf_result = 0; } else { + /* Report that the connection was rudely lost */ + psock->s_flags &= ~(_SF_CONNECTED |_SF_CLOSED); - } - /* If no data has been received, then return ENOTCONN. - * Otherwise, let this return success. The failure will - * be reported the next time that recv[from]() is called. - */ + /* If no data has been received, then return ENOTCONN. + * Otherwise, let this return success. The failure will + * be reported the next time that recv[from]() is called. + */ #if CONFIG_NET_TCP_RECVDELAY > 0 - if (pstate->rf_recvlen > 0) - { - pstate->rf_result = 0; - } - else - { - pstate->rf_result = -ENOTCONN; - } + if (pstate->rf_recvlen > 0) + { + pstate->rf_result = 0; + } + else + { + pstate->rf_result = -ENOTCONN; + } #else - pstate->rf_result = -ENOTCONN; + pstate->rf_result = -ENOTCONN; #endif + } /* Wake up the waiting thread */ |