]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: Check and message setsockopt()
authorJohn Ferlan <jferlan@redhat.com>
Tue, 15 Jan 2013 18:12:56 +0000 (13:12 -0500)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 16 Jan 2013 09:43:13 +0000 (10:43 +0100)
Check status when attempting to set SO_REUSEADDR flag on outgoing connection
On failure, VIR_WARN(), but continue to connect. This code path is on the
sender side where the setting is just a hint and would only take effect if
the sender is overflowed with TCP connections.  Inability to set doesn't mean
failure to establish a connection.

src/rpc/virnetsocket.c

index 1708d1cd8444a3955552bd90b0f7886f6f4c618a..1b30985b442e28aaea7dc89164f206171bd40056 100644 (file)
@@ -473,7 +473,9 @@ int virNetSocketNewConnectTCP(const char *nodename,
             goto error;
         }
 
-        setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
+        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0) {
+            VIR_WARN("Unable to enable port reuse");
+        }
 
         if (connect(fd, runp->ai_addr, runp->ai_addrlen) >= 0)
             break;