]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
fixed #27 and #35 where the fix was tested a long time ago.
authorRogier Wolff <R.E.Wolff@BitWizard.nl>
Fri, 19 Aug 2016 09:20:22 +0000 (11:20 +0200)
committerRogier Wolff <R.E.Wolff@BitWizard.nl>
Fri, 19 Aug 2016 09:20:22 +0000 (11:20 +0200)
net.c

diff --git a/net.c b/net.c
index ab1a160c560f521c57e0484cbd265c2a1fc59924..c591acc55e3e2ad042cec335806c5fd6aed36058 100644 (file)
--- 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))) {