X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_socket.c;h=9095d575c6a0caa633ab5bb9e5ffc64897ee7412;hp=efa0f559c1c69f7a8a04f2b17dbfb891f326ff09;hb=4fe7aff4d1b8605d4997b842481cc78bd062fe2a;hpb=5bba3124c8c23568def7a4804651a53f3a6b4fd2 diff --git a/src/net_socket.c b/src/net_socket.c index efa0f559..9095d575 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -41,6 +41,7 @@ int addressfamily = AF_UNSPEC; int maxtimeout = 900; int seconds_till_retry = 5; +bool blockingtcp = false; listen_socket_t listen_socket[MAXSOCKETS]; int listen_sockets; @@ -240,6 +241,16 @@ void finish_connecting(connection_t *c) ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname); +#ifdef O_NONBLOCK + if(blockingtcp) { + int flags = fcntl(c->socket, F_GETFL); + + if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) { + logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno)); + } + } +#endif + c->last_ping_time = now; send_id(c); @@ -425,6 +436,16 @@ bool handle_new_meta_connection(int sock) ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname); +#ifdef O_NONBLOCK + if(blockingtcp) { + int flags = fcntl(c->socket, F_GETFL); + + if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) { + logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno)); + } + } +#endif + connection_add(c); c->allow_request = ID;