summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2011-11-02 15:31:09 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2011-11-02 15:31:09 +0000
commita2c623b881f605619f3f4965aff123689cacf9bf (patch)
treee3907beccb42233405d1563516224fbf19db8e55
parent2214ad00c31abca64dda48c0724286b6b2c4da9c (diff)
parenta36d4918a6f646e085fd91c7cdb41b093feef7ac (diff)
Merge branch 'dbus-1.4'
-rw-r--r--dbus/dbus-sysdeps-unix.c3
-rw-r--r--test/Makefile.am1
-rw-r--r--test/corrupt.c60
3 files changed, 40 insertions, 24 deletions
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 00283b37..e99f67ad 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -1324,13 +1324,14 @@ _dbus_listen_tcp_socket (const char *host,
hints.ai_flags = AI_ADDRCONFIG | AI_PASSIVE;
redo_lookup_with_port:
+ ai = NULL;
if ((res = getaddrinfo(host, port, &hints, &ai)) != 0 || !ai)
{
dbus_set_error (error,
_dbus_error_from_errno (errno),
"Failed to lookup host/port: \"%s:%s\": %s (%d)",
host ? host : "*", port, gai_strerror(res), res);
- return -1;
+ goto failed;
}
tmp = ai;
diff --git a/test/Makefile.am b/test/Makefile.am
index d69e7835..2eca473e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -113,6 +113,7 @@ installable_tests = \
installcheck_tests =
installcheck_environment = \
DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \
+ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \
DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir)
TESTS_ENVIRONMENT = \
diff --git a/test/corrupt.c b/test/corrupt.c
index ef9951af..02495901 100644
--- a/test/corrupt.c
+++ b/test/corrupt.c
@@ -160,6 +160,38 @@ test_message (Fixture *f,
dbus_message_unref (outgoing);
}
+static void
+send_n_bytes (GSocket *socket,
+ const gchar *blob,
+ gssize blob_len)
+{
+ gssize len, total_sent;
+ GError *gerror = NULL;
+
+ total_sent = 0;
+
+ while (total_sent < blob_len)
+ {
+ len = g_socket_send (socket,
+ blob + total_sent,
+ blob_len - total_sent,
+ NULL, &gerror);
+
+ /* this is NULL-safe: a NULL error does not match */
+ if (g_error_matches (gerror, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
+ {
+ /* we could wait for G_IO_OUT, but life's too short; just sleep */
+ g_clear_error (&gerror);
+ g_usleep (G_USEC_PER_SEC / 10);
+ continue;
+ }
+
+ g_assert_no_error (gerror);
+ g_assert (len >= 0);
+ total_sent += len;
+ }
+}
+
/* Enough bytes for it to be obvious that this connection is broken */
#define CORRUPT_LEN 1024
@@ -174,7 +206,6 @@ test_corrupt (Fixture *f,
GSocket *socket;
GError *gerror = NULL;
int fd;
- gssize len, total_sent;
DBusMessage *incoming;
test_message (f, addr);
@@ -191,17 +222,7 @@ test_corrupt (Fixture *f,
g_assert_no_error (gerror);
g_assert (socket != NULL);
- total_sent = 0;
-
- while (total_sent < CORRUPT_LEN)
- {
- len = g_socket_send_with_blocking (socket,
- not_a_dbus_message + total_sent, CORRUPT_LEN - total_sent,
- TRUE, NULL, &gerror);
- g_assert_no_error (gerror);
- g_assert (len >= 0);
- total_sent += len;
- }
+ send_n_bytes (socket, not_a_dbus_message, CORRUPT_LEN);
/* Now spin on the client connection: the server just sent it complete
* rubbish, so it should disconnect */
@@ -225,6 +246,7 @@ test_corrupt (Fixture *f,
"/org/freedesktop/DBus/Local");
dbus_message_unref (incoming);
+ g_object_unref (socket);
}
static void
@@ -237,7 +259,7 @@ test_byte_order (Fixture *f,
char *blob;
const gchar *arg = not_a_dbus_message;
const gchar * const *args = &arg;
- int blob_len, len, total_sent;
+ int blob_len;
DBusMessage *message;
dbus_bool_t mem;
@@ -277,16 +299,7 @@ test_byte_order (Fixture *f,
g_assert_no_error (gerror);
g_assert (socket != NULL);
- total_sent = 0;
-
- while (total_sent < blob_len)
- {
- len = g_socket_send_with_blocking (socket, blob + total_sent,
- blob_len - total_sent, TRUE, NULL, &gerror);
- g_assert_no_error (gerror);
- g_assert (len >= 0);
- total_sent += len;
- }
+ send_n_bytes (socket, blob, blob_len);
dbus_free (blob);
@@ -312,6 +325,7 @@ test_byte_order (Fixture *f,
"/org/freedesktop/DBus/Local");
dbus_message_unref (message);
+ g_object_unref (socket);
}
static void