… | |
… | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
15 | GNU General Public License for more details. |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with gvpe; if not, write to the Free Software |
18 | along with gvpe; if not, write to the Free Software |
19 | Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
20 | */ |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #if ENABLE_TCP |
24 | #if ENABLE_TCP |
… | |
… | |
129 | |
129 | |
130 | int fd = accept (w.fd, (sockaddr *)&sa, &sa_len); |
130 | int fd = accept (w.fd, (sockaddr *)&sa, &sa_len); |
131 | |
131 | |
132 | if (fd >= 0) |
132 | if (fd >= 0) |
133 | { |
133 | { |
|
|
134 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
135 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
136 | |
134 | sockinfo si(sa, PROT_TCPv4); |
137 | sockinfo si(sa, PROT_TCPv4); |
135 | |
138 | |
136 | slog (L_DEBUG, _("%s: accepted tcp connection"), (const char *)si);//D |
139 | slog (L_DEBUG, _("%s: accepted tcp connection"), (const char *)si);//D |
137 | |
|
|
138 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
139 | |
140 | |
140 | tcp_connection *i = new tcp_connection (fd, si, *this); |
141 | tcp_connection *i = new tcp_connection (fd, si, *this); |
141 | tcp_si.insert (*i); |
142 | tcp_si.insert (*i); |
142 | } |
143 | } |
143 | } |
144 | } |
… | |
… | |
388 | fcntl (fd, F_SETFL, O_NONBLOCK); |
389 | fcntl (fd, F_SETFL, O_NONBLOCK); |
389 | |
390 | |
390 | if (connect (fd, csi->sav4 (), csi->salenv4 ()) >= 0 |
391 | if (connect (fd, csi->sav4 (), csi->salenv4 ()) >= 0 |
391 | || errno == EINPROGRESS) |
392 | || errno == EINPROGRESS) |
392 | { |
393 | { |
|
|
394 | fcntl (fd, F_SETFL, O_NONBLOCK); |
|
|
395 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
|
|
396 | |
393 | state = CONNECTING; |
397 | state = CONNECTING; |
394 | start (fd, EVENT_WRITE); |
398 | start (fd, EVENT_WRITE); |
395 | } |
399 | } |
396 | else |
400 | else |
397 | close (fd); |
401 | close (fd); |