Accepting request 200593 from Base:System

Amend dbus-fall-back-to-old-run-directory.patch (bnc#802525). (forwarded request 200587 from hpjansson)

OBS-URL: https://build.opensuse.org/request/show/200593
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/dbus-1?expand=0&rev=106
This commit is contained in:
Stephan Kulow 2013-09-26 17:32:08 +00:00 committed by Git OBS Bridge
commit 42b296fd46
3 changed files with 88 additions and 2 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Sep 25 17:34:53 CEST 2013 - hpj@suse.com
- Amend dbus-fall-back-to-old-run-directory.patch to prevent a
new class of hangs while upgrading D-Bus along with other
services (bnc#802525).
-------------------------------------------------------------------
Sat Sep 7 20:17:40 UTC 2013 - hrvoje.senjan@gmail.com

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Sep 25 17:34:53 CEST 2013 - hpj@suse.com
- Amend dbus-fall-back-to-old-run-directory.patch to prevent a
new class of hangs while upgrading D-Bus along with other
services (bnc#802525).
-------------------------------------------------------------------
Sat Sep 7 20:17:40 UTC 2013 - hrvoje.senjan@gmail.com

View File

@ -1,5 +1,5 @@
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c
index fadc3a8..2c71cdb 100644
index 6f81c74..96416c6 100644
--- a/dbus/dbus-bus.c
+++ b/dbus/dbus-bus.c
@@ -421,6 +421,153 @@ _dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connec
@ -181,7 +181,7 @@ index fadc3a8..2c71cdb 100644
}
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index ee33b6c..b87c6f7 100644
index 66315b3..467379a 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -348,7 +348,7 @@ static void _dbus_connection_update_dispatch_status_and_unlock (DB
@ -272,3 +272,75 @@ index ee33b6c..b87c6f7 100644
HAVE_LOCK_CHECK (connection);
/* Unlocks and calls out to user code */
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index e9bd9ef..0d04006 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -773,6 +773,51 @@ _dbus_write_two (int fd,
* which is probably a good idea.
*/
+static int
+connect_with_timeout (const char *path,
+ int fd,
+ const struct sockaddr *addr,
+ socklen_t addrlen,
+ DBusError *error)
+{
+ struct pollfd poll_fd;
+
+ _DBUS_ASSERT_ERROR_IS_CLEAR (error);
+
+ if (!_dbus_set_fd_nonblocking (fd, error))
+ {
+ _dbus_close (fd, NULL);
+ return -1;
+ }
+
+ connect (fd, addr, addrlen);
+
+ poll_fd.fd = fd;
+ poll_fd.events = POLLOUT | POLLERR | POLLNVAL;
+
+ if (poll (&poll_fd, 1, 250) < 1)
+ {
+ dbus_set_error (error,
+ _dbus_error_from_errno (errno),
+ "Failed to connect to socket %s: %s",
+ path, _dbus_strerror (errno));
+ _dbus_close (fd, NULL);
+ return -1;
+ }
+
+ if (!(poll_fd.revents & POLLOUT))
+ {
+ dbus_set_error (error,
+ _dbus_error_from_errno (errno),
+ "Failed to connect to socket %s: %s",
+ path, _dbus_strerror (errno));
+ _dbus_close (fd, NULL);
+ return -1;
+ }
+
+ return 0;
+}
+
/**
* Creates a socket and connects it to the UNIX domain socket at the
* given path. The connection fd is returned, and is set up as
@@ -851,7 +896,14 @@ _dbus_connect_unix_socket (const char *path,
strncpy (addr.sun_path, path, path_len);
}
- if (connect (fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
+ if ((!strcmp (path, DBUS_SYSTEM_BUS_DEFAULT_ADDRESS) ||
+ (!strncmp (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "unix:path=", strlen ("unix:path=")) &&
+ !strcmp (path, DBUS_SYSTEM_BUS_DEFAULT_ADDRESS + strlen ("unix:path=")))) &&
+ connect_with_timeout (path, fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len, error) < 0)
+ {
+ return -1;
+ }
+ else if (connect (fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0)
{
dbus_set_error (error,
_dbus_error_from_errno (errno),