[PATCH] tcp: fix for ENOTCONN on newer FreeBSDs
Andrei Pelinescu-Onciul
andrei at iptel.org
Tue Nov 22 12:55:39 CET 2011
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
---
tcp_main.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 5aa8638..b1635ff 100644
--- a/tcp_main.c
+++ b/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;
--
1.7.2.1
--eJnRUKwClWJh1Khz--
More information about the sr-users
mailing list