From 598b4b28793536198ffd145b895e2821334332da Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 19 Jan 2013 19:45:08 +0000 Subject: [PATCH] Minor tweak to last bugfix git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5540 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/net/recvfrom.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index 679b5e8ce6..ac8065f81b 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -563,12 +563,18 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, pstate->rf_cb->priv = NULL; pstate->rf_cb->event = NULL; - /* If the peer gracefully closed the connection, then return zero - * (end-of-file). Otherwise, report a not-connected error - * _SF_CONNECTED==0 && _SF_CLOSED==1 - the socket was - * gracefully disconnected - * _SF_CONNECTED==0 && _SF_CLOSED==0 - the socket was - * rudely disconnected + /* Check if the peer gracefully closed the connection. We need + * these flags in case we return zero (below) to remember the + * state of the connection. + * + * _SF_CONNECTED==0 && _SF_CLOSED==1 - the socket was + * 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; @@ -587,6 +593,7 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, * 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; @@ -595,6 +602,9 @@ static uint16_t recvfrom_tcpinterrupt(struct uip_driver_s *dev, void *conn, { pstate->rf_result = -ENOTCONN; } +#else + pstate->rf_result = -ENOTCONN; +#endif /* Wake up the waiting thread */