]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Fix: Be sure that NONBLOCK is set
authorJaroslav Rohel <jrohel@redhat.com>
Tue, 11 Dec 2018 11:40:42 +0000 (12:40 +0100)
committerJaroslav Rohel <jrohel@redhat.com>
Tue, 11 Dec 2018 12:33:52 +0000 (13:33 +0100)
examples/solv/fastestmirror.c

index d2ebd97a20dff79d28dcc70008d4e16099a2e362..0ee4e73b798c9533d79edcc0487bc2a491cb6153 100644 (file)
@@ -68,7 +68,11 @@ findfastest(char **urls, int nurls)
          socks[i] = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
          if (socks[i] >= 0)
            {
-             fcntl(socks[i], F_SETFL, O_NONBLOCK);
+             if (fcntl(socks[i], F_SETFL, O_NONBLOCK) == -1)
+            {
+                     close(socks[i]);
+                     socks[i] = -1;
+            }
              if (connect(socks[i], result->ai_addr, result->ai_addrlen) == -1)
                {
                  if (errno != EINPROGRESS)