Browse code

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

Andrei Pelinescu-Onciul authored on 22/11/2011 11:55:39
Showing 1 changed files
... ...
@@ -2716,7 +2716,10 @@ static int tcpconn_1st_send(int fd, struct tcp_connection* c,
2716 2716
 	
2717 2717
 	n=_tcpconn_write_nb(fd, c, buf, len);
2718 2718
 	if (unlikely(n<(int)len)){
2719
-		if ((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK){
2719
+		/* on EAGAIN or ENOTCONN return success.
2720
+		   ENOTCONN appears on newer FreeBSD versions (non-blocking socket,
2721
+		   connect() & send immediately) */
2722
+		if ((n>=0) || errno==EAGAIN || errno==EWOULDBLOCK || errno==ENOTCONN){
2720 2723
 			DBG("pending write on new connection %p "
2721 2724
 				" (%d/%d bytes written)\n", c, n, len);
2722 2725
 			if (unlikely(n<0)) n=0;