Ignore error when setting SO_REUSEADDR
authorAlexander Larsson <alexl@redhat.com>
Mon, 18 May 2009 21:24:13 +0000 (23:24 +0200)
committerAlexander Larsson <alexl@redhat.com>
Mon, 18 May 2009 21:24:13 +0000 (23:24 +0200)
The main error would be "not supported" which could happen for e.g.
unix domain sockets, we don't really care, as this is mainly something
for TCP to help out a bit.

gio/gsocket.c

index a58ca03..6972d2a 100644 (file)
@@ -1342,15 +1342,10 @@ g_socket_bind (GSocket         *socket,
      It always allows the unix variant of SO_REUSEADDR anyway */
 #ifndef G_OS_WIN32
   value = (int) !!reuse_address;
-  if (setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
-                 (gpointer) &value, sizeof (value)) < 0)
-    {
-      int errsv = get_socket_errno ();
-      g_set_error (error,
-                  G_IO_ERROR, socket_io_error_from_errno (errsv),
-                  _("Error setting reuse_address: %s"), socket_strerror (errsv));
-      return FALSE;
-    }
+  /* Ignore errors here, the only likely error is "not supported", and
+     this is a "best effort" thing mainly */
+  setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
+             (gpointer) &value, sizeof (value));
 #endif
 
   if (!g_socket_address_to_native (address, addr, sizeof addr, error))