summaryrefslogtreecommitdiffstats
path: root/bus/config-parser.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/config-parser.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/config-parser.c')
-rw-r--r--bus/config-parser.c52
1 files changed, 13 insertions, 39 deletions
diff --git a/bus/config-parser.c b/bus/config-parser.c
index 8fb3b29e..2429cce5 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -285,47 +285,18 @@ do_load (const DBusString *full_path,
}
}
-static dbus_bool_t
-check_oom_loading (const DBusString *full_path,
- Validity validity)
+typedef struct
{
- int approx_mallocs;
-
- /* Run once to see about how many mallocs are involved */
-
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
-
- if (!do_load (full_path, validity, FALSE))
- return FALSE;
+ const DBusString *full_path;
+ Validity validity;
+} LoaderOomData;
- approx_mallocs = _DBUS_INT_MAX - _dbus_get_fail_alloc_counter ();
-
- _dbus_verbose ("=================\nabout %d mallocs total\n=================\n",
- approx_mallocs);
-
- approx_mallocs += 10; /* fudge factor */
-
- /* Now run failing each malloc */
-
- while (approx_mallocs >= 0)
- {
-
- _dbus_set_fail_alloc_counter (approx_mallocs);
-
- _dbus_verbose ("\n===\n(will fail malloc %d)\n===\n",
- approx_mallocs);
-
- if (!do_load (full_path, validity, TRUE))
- return FALSE;
-
- approx_mallocs -= 1;
- }
-
- _dbus_set_fail_alloc_counter (_DBUS_INT_MAX);
-
- _dbus_verbose ("=================\n all iterations passed\n=================\n");
+static dbus_bool_t
+check_loader_oom_func (void *data)
+{
+ LoaderOomData *d = data;
- return TRUE;
+ return do_load (d->full_path, d->validity, TRUE);
}
static dbus_bool_t
@@ -376,6 +347,7 @@ process_test_subdir (const DBusString *test_base_dir,
while (_dbus_directory_get_next_file (dir, &filename, &error))
{
DBusString full_path;
+ LoaderOomData d;
if (!_dbus_string_init (&full_path, _DBUS_INT_MAX))
_dbus_assert_not_reached ("couldn't init string");
@@ -407,7 +379,9 @@ process_test_subdir (const DBusString *test_base_dir,
(validity == INVALID ? "invalid" :
(validity == UNKNOWN ? "unknown" : "???")));
- if (!check_oom_loading (&full_path, validity))
+ d.full_path = &full_path;
+ d.validity = validity;
+ if (!_dbus_test_oom_handling ("config-loader", check_loader_oom_func, &d))
_dbus_assert_not_reached ("test failed");
_dbus_string_free (&full_path);