From f63a3c1f627641f83ebca12a78e2892cf9c0a05b Mon Sep 17 00:00:00 2001 From: goldsimon Date: Sun, 25 Nov 2007 14:33:23 +0000 Subject: [PATCH] Added an explaining comment for the line 'nsock->rcvevent += -1 - newconn->socket;' in lwip_accept --- src/api/sockets.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/sockets.c b/src/api/sockets.c index 5d9acece..0d89f0b5 100644 --- a/src/api/sockets.c +++ b/src/api/sockets.c @@ -296,11 +296,11 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) sock_set_errno(sock, 0); sys_sem_wait(socksem); - /* @todo: This piece of code effectively does nothing: newconn->socket is set to -1 on - correct program flow, nsock->rcvevent is 0 before and after this line. - Unless there's a specific reason for this code, it should be deleted! - - This code came in with rev. 1.8 of the file (committed by davidhaas, maybe he knows more) */ + /* See event_callback: If data comes in right away after an accept, even + * though the server task might not have created a new socket yet. + * In that case, newconn->socket is counted down (newconn->socket--), + * so nsock->rcvevent is >= 1 here! + */ nsock->rcvevent += -1 - newconn->socket; newconn->socket = newsock; sys_sem_signal(socksem);