summaryrefslogtreecommitdiffstats
path: root/bus/dispatch.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-28 05:42:19 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-28 05:42:19 +0000
commitbf99381351b802fb3348a24037898222aae631e2 (patch)
treeaae0a9583e4d6aa559849e4326a3c9b2a7175015 /bus/dispatch.c
parent574c258bc9304d51bf0cdd131a6473e6fc5b477f (diff)
2003-03-28 Havoc Pennington <hp@pobox.com>
* bus/test.c (bus_test_flush_bus): remove the sleep from here, I think it may have just been superstition. Not sure. * dbus/dbus-string.c (_dbus_string_base64_decode): catch some OOM failures that were not being handled. * dbus/dbus-auth.c (process_auth): fix a memleak in OOM handling * dbus/dbus-memory.c: add ability to set number of mallocs in a row that will fail on out-of-memory. * dbus/dbus-internals.c (_dbus_test_oom_handling): convenience function for testing out-of-memory handling. * bus/config-loader-expat.c (memsuite): don't wrap the dbus allocation functions, they do map exactly to the expat ones.
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r--bus/dispatch.c61
1 files changed, 27 insertions, 34 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 7db4ac29..2b1dc782 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -916,49 +916,42 @@ check_hello_connection (BusContext *context)
return TRUE;
}
-static void
-check1_try_iterations (BusContext *context,
- const char *description,
- Check1Func func)
+typedef struct
{
- int approx_mallocs;
-
- /* Run once to see about how many mallocs are involved */
-
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
-
- if (! (*func) (context))
- _dbus_assert_not_reached ("test failed");
+ Check1Func func;
+ BusContext *context;
+} Check1Data;
- approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
+static dbus_bool_t
+check_oom_check1_func (void *data)
+{
+ Check1Data *d = data;
- _dbus_verbose ("=================\n%s: about %d mallocs total\n=================\n",
- description, approx_mallocs);
-
- approx_mallocs += 10; /* fudge factor */
-
- /* Now run failing each malloc */
+ if (! (* d->func) (d->context))
+ return FALSE;
- while (approx_mallocs >= 0)
+ if (!check_no_leftovers (d->context))
{
- _dbus_set_fail_alloc_counter (approx_mallocs);
-
- _dbus_verbose ("\n===\n %s: (will fail malloc %d)\n===\n",
- description, approx_mallocs);
+ _dbus_warn ("Messages were left over, should be covered by test suite");
+ return FALSE;
+ }
- if (! (*func) (context))
- _dbus_assert_not_reached ("test failed");
+ return TRUE;
+}
- if (!check_no_leftovers (context))
- _dbus_assert_not_reached ("Messages were left over, should be covered by test suite");
-
- approx_mallocs -= 1;
- }
+static void
+check1_try_iterations (BusContext *context,
+ const char *description,
+ Check1Func func)
+{
+ Check1Data d;
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
+ d.func = func;
+ d.context = context;
- _dbus_verbose ("=================\n%s: all iterations passed\n=================\n",
- description);
+ if (!_dbus_test_oom_handling (description, check_oom_check1_func,
+ &d))
+ _dbus_assert_not_reached ("test failed");
}
dbus_bool_t