Browse Source

tcp: fix for ENOTCONN on newer FreeBSDs

Newer FreeBSDs return ENOTCONN instead of EAGAIN/EWOULDBLOCK when
trying to send on a non-blocking socket which is not yet fully
connected (the connect is still pending).

Reported-by: Dmitry Petrakoff  dimon dprs-consulting com
(cherry picked from commit 3d4a59421a284afbf8bdf8e87357f07d9cd554e0)
Andrei Pelinescu-Onciul 14 years ago
parent
commit
ddcee852b7
1 changed files with 4 additions and 1 deletions
  1. 4 1
      tcp_main.c

+ 4 - 1
tcp_main.c

@@ -2693,7 +2693,10 @@ static int tcpconn_1st_send(int fd, struct tcp_connection* c,
 	
 	n=_tcpconn_write_nb(fd, c, buf, len);
 	if (unlikely(n<(int)len)){
-		if ((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK){
+		/* on EAGAIN or ENOTCONN return success.
+		   ENOTCONN appears on newer FreeBSD versions (non-blocking socket,
+		   connect() & send immediately) */
+		if ((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK || errno==ENOTCONN){
 			DBG("pending write on new connection %p "
 				" (%d/%d bytes written)\n", c, n, len);
 			if (unlikely(n<0)) n=0;