Module: sip-router
Branch: master
Commit: 3d4a59421a284afbf8bdf8e87357f07d9cd554e0
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3d4a594…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Nov 22 12:55:39 2011 +0100
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
---
tcp_main.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/tcp_main.c b/tcp_main.c
index 0986207..e21821c 100644
--- a/tcp_main.c
+++ b/tcp_main.c
@@ -2716,7 +2716,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;