From: Rogier Wolff Date: Fri, 19 Aug 2016 09:20:22 +0000 (+0200) Subject: fixed #27 and #35 where the fix was tested a long time ago. X-Git-Tag: v0.88~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b7e2bf25f502beea83bf1c903287c72cd0a2d6a;p=thirdparty%2Fmtr.git fixed #27 and #35 where the fix was tested a long time ago. --- diff --git a/net.c b/net.c index ab1a160..c591acc 100644 --- a/net.c +++ b/net.c @@ -315,8 +315,8 @@ int new_sequence(int index) void net_send_tcp(int index) { int ttl, s; - int opt = 1; int port; + int flags; struct sockaddr_storage local; struct sockaddr_storage remote; struct sockaddr_in *local4 = (struct sockaddr_in *) &local; @@ -370,13 +370,21 @@ void net_send_tcp(int index) exit(EXIT_FAILURE); } - opt = 1; - if (ioctl(s, FIONBIO, &opt)) { + // opt = 1; + flags = fcntl(s, F_GETFL, 0); + if (flags < 0) { display_clear(); perror("ioctl FIONBIO"); exit(EXIT_FAILURE); } + if (fcntl (s, F_SETFL, flags | O_NONBLOCK) < 0) { + display_clear(); + perror("ioctl FIONBIO"); + exit(EXIT_FAILURE); + } + + switch (af) { case AF_INET: if (setsockopt(s, IPPROTO_IP, IP_TTL, &ttl, sizeof (ttl))) {