summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-27 16:23:16 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-27 19:38:12 +0000
commitc9aa00ce730f9741ab39ff704e46ec33dd4a11ea (patch)
tree89f75ccbe969263d6fe75f70ec5d0d489e0e2d4a
parent67d0bf6f3e3893d1b5c1450112d2e28ba4d79ec5 (diff)
_dbus_server_new_for_socket: Iterate over arrays as intended
Commit 0c03b505 was meant to clear all the fds indexed by j in [0, n_fds), which socket_disconnect() can't be allowed to close (because on failure the caller remains responsible for closing them); but instead it closed the one we failed to add to the main loop (fd i), repeatedly. Similarly, it was meant to invalidate all the watches indexed by j in [i, n_fds) (the one we failed to add to the main loop and the ones we didn't try to add to the main loop yet), which socket_disconnect() can't be allowed to see (because it would fail to remove them from the main loop and hit an assertion failure); but instead it invalidated fd i, repeatedly. These happen to be the same thing if you only have one fd, resulting in the test-case passing on an IPv4-only system, but failing on a system with both IPv4 and IPv6. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104 Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com>
-rw-r--r--dbus/dbus-server-socket.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c
index 64cfc90d7..2da756052 100644
--- a/dbus/dbus-server-socket.c
+++ b/dbus/dbus-server-socket.c
@@ -344,16 +344,16 @@ _dbus_server_new_for_socket (DBusSocket *fds,
* we return successfully, so don't let socket_disconnect()
* close them */
for (j = 0; j < n_fds; j++)
- _dbus_socket_invalidate (&socket_server->fds[i]);
+ _dbus_socket_invalidate (&socket_server->fds[j]);
/* socket_disconnect() will try to remove all the watches;
* make sure it doesn't see the ones that weren't even added
* yet */
for (j = i; j < n_fds; j++)
{
- _dbus_watch_invalidate (socket_server->watch[i]);
- _dbus_watch_unref (socket_server->watch[i]);
- socket_server->watch[i] = NULL;
+ _dbus_watch_invalidate (socket_server->watch[j]);
+ _dbus_watch_unref (socket_server->watch[j]);
+ socket_server->watch[j] = NULL;
}
_dbus_server_disconnect_unlocked (server);