From 068ba98ca54170b084721df9f7f8ec8d897714f5 Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 21 Feb 2008 09:18:24 +0000 Subject: [PATCH] Aha, _that's_ why I've been periodically getting blocking-write problems using Unix PuTTY port forwarding. Sockets we create by connect() are immediately set into nonblocking mode by fcntl, but sockets we create by accept() were not. This trivial fix should help. git-svn-id: svn://svn.tartarus.org/sgt/putty@7864 cda61777-01e9-0310-a592-d414129be87e --- unix/uxnet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/unix/uxnet.c b/unix/uxnet.c index bfc4a8ed..bd40937a 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -1077,6 +1077,7 @@ static int net_select_result(int fd, int event) #endif socklen_t addrlen = sizeof(ss); int t; /* socket of connection */ + int fl; memset(&ss, 0, addrlen); t = accept(s->s, (struct sockaddr *)&ss, &addrlen); @@ -1084,6 +1085,10 @@ static int net_select_result(int fd, int event) break; } + fl = fcntl(t, F_GETFL); + if (fl != -1) + fcntl(t, F_SETFL, fl | O_NONBLOCK); + if (s->localhost_only && !sockaddr_is_loopback((struct sockaddr *)&ss)) { close(t); /* someone let nonlocal through?! */ -- 2.11.0