mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-01 21:33:09 +02:00
Ignore error when setting SO_REUSEADDR
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.
This commit is contained in:
parent
f24c7fa9cb
commit
3756ddb0ee
@ -1342,15 +1342,10 @@ g_socket_bind (GSocket *socket,
|
|||||||
It always allows the unix variant of SO_REUSEADDR anyway */
|
It always allows the unix variant of SO_REUSEADDR anyway */
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
value = (int) !!reuse_address;
|
value = (int) !!reuse_address;
|
||||||
if (setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
|
/* Ignore errors here, the only likely error is "not supported", and
|
||||||
(gpointer) &value, sizeof (value)) < 0)
|
this is a "best effort" thing mainly */
|
||||||
{
|
setsockopt (socket->priv->fd, SOL_SOCKET, SO_REUSEADDR,
|
||||||
int errsv = get_socket_errno ();
|
(gpointer) &value, sizeof (value));
|
||||||
g_set_error (error,
|
|
||||||
G_IO_ERROR, socket_io_error_from_errno (errsv),
|
|
||||||
_("Error setting reuse_address: %s"), socket_strerror (errsv));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!g_socket_address_to_native (address, addr, sizeof addr, error))
|
if (!g_socket_address_to_native (address, addr, sizeof addr, error))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user