Commit 9c3d566e authored by Havoc Pennington's avatar Havoc Pennington

2005-01-15 Havoc Pennington <hp@redhat.com>

	* Land the new message args API and type system.

	This patch is huge, but the public API change is not
	really large. The set of D-BUS types has changed somewhat,
	and the arg "getters" are more geared toward language bindings;
	they don't make a copy, etc.

	There are also some known issues. See these emails for details
	on this huge patch:
	http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
        http://lists.freedesktop.org/archives/dbus/2005-January/001922.html

	* dbus/dbus-marshal-*: all the new stuff

	* dbus/dbus-message.c: basically rewritten

	* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
	freed blocks to be all non-nul bytes so using freed memory is less
	likely to work right

	* dbus/dbus-internals.c (_dbus_test_oom_handling): add
	DBUS_FAIL_MALLOC=N environment variable, so you can do
	DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
	DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
	thorough.

	* qt/message.cpp: port to the new message args API
	(operator<<): use str.utf8() rather than str.unicode()
	(pretty sure this is right from the Qt docs?)

	* glib/dbus-gvalue.c: port to the new message args API

	* bus/dispatch.c, bus/driver.c: port to the new message args API

	* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
	"locked" flag to TRUE and align_offset to 0; I guess we never
	looked at these anyhow, but seems cleaner.

	* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
	move allocation padding macro to this header; use it to implement
	(_DBUS_STRING_STATIC): ability to declare a static string.

	* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
	change to return TRUE if the interface is not set.

	* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
	to dbus-marshal-validate.[hc]

	* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
	dbus-internals.c

	* dbus/Makefile.am: cut over from dbus-marshal.[hc]
	to dbus-marshal-*.[hc]

	* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
	function here from dbus-marshal.c
parent 6ec04e91
2005-01-15 Havoc Pennington <hp@redhat.com>
* Land the new message args API and type system.
This patch is huge, but the public API change is not
really large. The set of D-BUS types has changed somewhat,
and the arg "getters" are more geared toward language bindings;
they don't make a copy, etc.
There are also some known issues. See these emails for details
on this huge patch:
http://lists.freedesktop.org/archives/dbus/2004-December/001836.html
http://lists.freedesktop.org/archives/dbus/2005-January/001922.html
* dbus/dbus-marshal-*: all the new stuff
* dbus/dbus-message.c: basically rewritten
* dbus/dbus-memory.c (check_guards): with "guards" enabled, init
freed blocks to be all non-nul bytes so using freed memory is less
likely to work right
* dbus/dbus-internals.c (_dbus_test_oom_handling): add
DBUS_FAIL_MALLOC=N environment variable, so you can do
DBUS_FAIL_MALLOC=0 to skip the out-of-memory checking, or
DBUS_FAIL_MALLOC=10 to make it really, really, really slow and
thorough.
* qt/message.cpp: port to the new message args API
(operator<<): use str.utf8() rather than str.unicode()
(pretty sure this is right from the Qt docs?)
* glib/dbus-gvalue.c: port to the new message args API
* bus/dispatch.c, bus/driver.c: port to the new message args API
* dbus/dbus-string.c (_dbus_string_init_const_len): initialize the
"locked" flag to TRUE and align_offset to 0; I guess we never
looked at these anyhow, but seems cleaner.
* dbus/dbus-string.h (_DBUS_STRING_ALLOCATION_PADDING):
move allocation padding macro to this header; use it to implement
(_DBUS_STRING_STATIC): ability to declare a static string.
* dbus/dbus-message.c (_dbus_message_has_type_interface_member):
change to return TRUE if the interface is not set.
* dbus/dbus-string.[hc]: move the D-BUS specific validation stuff
to dbus-marshal-validate.[hc]
* dbus/dbus-marshal-basic.c (_dbus_type_to_string): move here from
dbus-internals.c
* dbus/Makefile.am: cut over from dbus-marshal.[hc]
to dbus-marshal-*.[hc]
* dbus/dbus-object-tree.c (_dbus_decompose_path): move this
function here from dbus-marshal.c
2005-01-12 Joe Shaw <joeshaw@novell.com> 2005-01-12 Joe Shaw <joeshaw@novell.com>
* NEWS: Update for 0.23. * NEWS: Update for 0.23.
......
...@@ -127,6 +127,17 @@ dbus_realloc to fail if the number of bytes to be allocated is greater ...@@ -127,6 +127,17 @@ dbus_realloc to fail if the number of bytes to be allocated is greater
than the specified number. This only works if D-BUS has been compiled with than the specified number. This only works if D-BUS has been compiled with
--enable-tests. --enable-tests.
DBUS_TEST_MALLOC_FAILURES=n
Many of the D-BUS tests will run over and over, once for each malloc
involved in the test. Each run will fail a different malloc, plus some
number of mallocs following that malloc (because a fair number of bugs
only happen if two or more mallocs fail in a row, e.g. error recovery
that itself involves malloc). This env variable sets the number of
mallocs to fail.
Here's why you care: If set to 0, then the malloc checking is skipped,
which makes the test suite a heck of a lot faster. Just run with this
env variable unset before you commit.
Tests Tests
=== ===
......
...@@ -93,6 +93,7 @@ typedef struct ...@@ -93,6 +93,7 @@ typedef struct
unsigned int timeout_added : 1; unsigned int timeout_added : 1;
} BusPendingActivation; } BusPendingActivation;
#if 0
static BusServiceDirectory * static BusServiceDirectory *
bus_service_directory_ref (BusServiceDirectory *dir) bus_service_directory_ref (BusServiceDirectory *dir)
{ {
...@@ -102,6 +103,7 @@ bus_service_directory_ref (BusServiceDirectory *dir) ...@@ -102,6 +103,7 @@ bus_service_directory_ref (BusServiceDirectory *dir)
return dir; return dir;
} }
#endif
static void static void
bus_service_directory_unref (BusServiceDirectory *dir) bus_service_directory_unref (BusServiceDirectory *dir)
...@@ -909,15 +911,19 @@ bus_activation_service_created (BusActivation *activation, ...@@ -909,15 +911,19 @@ bus_activation_service_created (BusActivation *activation,
/* Only send activation replies to regular activation requests. */ /* Only send activation replies to regular activation requests. */
if (!entry->auto_activation) if (!entry->auto_activation)
{ {
dbus_uint32_t result;
message = dbus_message_new_method_return (entry->activation_message); message = dbus_message_new_method_return (entry->activation_message);
if (!message) if (!message)
{ {
BUS_SET_OOM (error); BUS_SET_OOM (error);
goto error; goto error;
} }
result = DBUS_ACTIVATION_REPLY_ACTIVATED;
if (!dbus_message_append_args (message, if (!dbus_message_append_args (message,
DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ACTIVATED, DBUS_TYPE_UINT32, &result,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (message); dbus_message_unref (message);
...@@ -1328,6 +1334,8 @@ bus_activation_activate_service (BusActivation *activation, ...@@ -1328,6 +1334,8 @@ bus_activation_activate_service (BusActivation *activation,
_dbus_string_init_const (&service_str, service_name); _dbus_string_init_const (&service_str, service_name);
if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL) if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL)
{ {
dbus_uint32_t result;
_dbus_verbose ("Service \"%s\" is already active\n", service_name); _dbus_verbose ("Service \"%s\" is already active\n", service_name);
message = dbus_message_new_method_return (activation_message); message = dbus_message_new_method_return (activation_message);
...@@ -1339,8 +1347,10 @@ bus_activation_activate_service (BusActivation *activation, ...@@ -1339,8 +1347,10 @@ bus_activation_activate_service (BusActivation *activation,
return FALSE; return FALSE;
} }
result = DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE;
if (!dbus_message_append_args (message, if (!dbus_message_append_args (message,
DBUS_TYPE_UINT32, DBUS_ACTIVATION_REPLY_ALREADY_ACTIVE, DBUS_TYPE_UINT32, &result,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
_dbus_verbose ("No memory to set args of reply to activate message\n"); _dbus_verbose ("No memory to set args of reply to activate message\n");
......
...@@ -1398,6 +1398,7 @@ bus_pending_reply_send_no_reply (BusConnections *connections, ...@@ -1398,6 +1398,7 @@ bus_pending_reply_send_no_reply (BusConnections *connections,
DBusMessage *message; DBusMessage *message;
DBusMessageIter iter; DBusMessageIter iter;
dbus_bool_t retval; dbus_bool_t retval;
const char *errmsg;
retval = FALSE; retval = FALSE;
...@@ -1414,9 +1415,10 @@ bus_pending_reply_send_no_reply (BusConnections *connections, ...@@ -1414,9 +1415,10 @@ bus_pending_reply_send_no_reply (BusConnections *connections,
if (!dbus_message_set_error_name (message, if (!dbus_message_set_error_name (message,
DBUS_ERROR_NO_REPLY)) DBUS_ERROR_NO_REPLY))
goto out; goto out;
errmsg = "Message did not receive a reply (timeout by message bus)";
dbus_message_append_iter_init (message, &iter); dbus_message_append_iter_init (message, &iter);
if (!dbus_message_iter_append_string (&iter, "Message did not receive a reply (timeout by message bus)")) if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errmsg))
goto out; goto out;
if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply, if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply,
......
This diff is collapsed.
This diff is collapsed.
...@@ -156,13 +156,18 @@ bus_registry_ensure (BusRegistry *registry, ...@@ -156,13 +156,18 @@ bus_registry_ensure (BusRegistry *registry,
service->registry = registry; service->registry = registry;
service->refcount = 1; service->refcount = 1;
_dbus_verbose ("copying string %p '%s' to service->name\n",
service_name, _dbus_string_get_const_data (service_name));
if (!_dbus_string_copy_data (service_name, &service->name)) if (!_dbus_string_copy_data (service_name, &service->name))
{ {
_dbus_mem_pool_dealloc (registry->service_pool, service); _dbus_mem_pool_dealloc (registry->service_pool, service);
BUS_SET_OOM (error); BUS_SET_OOM (error);
return NULL; return NULL;
} }
_dbus_verbose ("copied string %p '%s' to '%s'\n",
service_name, _dbus_string_get_const_data (service_name),
service->name);
if (!bus_driver_send_service_owner_changed (service->name, if (!bus_driver_send_service_owner_changed (service->name,
NULL, NULL,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "signals.h" #include "signals.h"
#include "services.h" #include "services.h"
#include "utils.h" #include "utils.h"
#include <dbus/dbus-marshal-validate.h>
struct BusMatchRule struct BusMatchRule
{ {
...@@ -656,7 +657,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ...@@ -656,7 +657,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed; goto failed;
} }
if (!_dbus_string_validate_service (&tmp_str, 0, len)) if (!_dbus_validate_service (&tmp_str, 0, len))
{ {
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Sender service name '%s' is invalid\n", value); "Sender service name '%s' is invalid\n", value);
...@@ -678,7 +679,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ...@@ -678,7 +679,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed; goto failed;
} }
if (!_dbus_string_validate_interface (&tmp_str, 0, len)) if (!_dbus_validate_interface (&tmp_str, 0, len))
{ {
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Interface name '%s' is invalid\n", value); "Interface name '%s' is invalid\n", value);
...@@ -700,7 +701,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ...@@ -700,7 +701,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed; goto failed;
} }
if (!_dbus_string_validate_member (&tmp_str, 0, len)) if (!_dbus_validate_member (&tmp_str, 0, len))
{ {
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Member name '%s' is invalid\n", value); "Member name '%s' is invalid\n", value);
...@@ -722,7 +723,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ...@@ -722,7 +723,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed; goto failed;
} }
if (!_dbus_string_validate_path (&tmp_str, 0, len)) if (!_dbus_validate_path (&tmp_str, 0, len))
{ {
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Path '%s' is invalid\n", value); "Path '%s' is invalid\n", value);
...@@ -744,7 +745,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to, ...@@ -744,7 +745,7 @@ bus_match_rule_parse (DBusConnection *matches_go_to,
goto failed; goto failed;
} }
if (!_dbus_string_validate_service (&tmp_str, 0, len)) if (!_dbus_validate_service (&tmp_str, 0, len))
{ {
dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID, dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,
"Destination service name '%s' is invalid\n", value); "Destination service name '%s' is invalid\n", value);
......
...@@ -12,3 +12,5 @@ dbus-test ...@@ -12,3 +12,5 @@ dbus-test
dbus-arch-deps.h dbus-arch-deps.h
.dbus-keyrings .dbus-keyrings
dbus-glib-error-enum.h dbus-glib-error-enum.h
*.gcno
*.gcda
...@@ -54,6 +54,12 @@ DBUS_LIB_SOURCES= \ ...@@ -54,6 +54,12 @@ DBUS_LIB_SOURCES= \
dbus-errors.c \ dbus-errors.c \
dbus-keyring.c \ dbus-keyring.c \
dbus-keyring.h \ dbus-keyring.h \
dbus-marshal-header.c \
dbus-marshal-header.h \
dbus-marshal-recursive.c \
dbus-marshal-recursive.h \
dbus-marshal-validate.c \
dbus-marshal-validate.h \
dbus-message.c \ dbus-message.c \
dbus-message-internal.h \ dbus-message-internal.h \
dbus-object-tree.c \ dbus-object-tree.c \
...@@ -98,13 +104,11 @@ DBUS_SHARED_SOURCES= \ ...@@ -98,13 +104,11 @@ DBUS_SHARED_SOURCES= \
dbus-internals.h \ dbus-internals.h \
dbus-list.c \ dbus-list.c \
dbus-list.h \ dbus-list.h \
dbus-marshal.c \ dbus-marshal-basic.c \
dbus-marshal.h \ dbus-marshal-basic.h \
dbus-memory.c \ dbus-memory.c \
dbus-mempool.c \ dbus-mempool.c \
dbus-mempool.h \ dbus-mempool.h \
dbus-message-builder.c \
dbus-message-builder.h \
dbus-spawn.c \ dbus-spawn.c \
dbus-spawn.h \ dbus-spawn.h \
dbus-string.c \ dbus-string.c \
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#include "dbus-string.h" #include "dbus-string.h"
#include "dbus-hash.h" #include "dbus-hash.h"
#include "dbus-internals.h" #include "dbus-internals.h"
#include "dbus-marshal.h"
#include "dbus-userdb.h" #include "dbus-userdb.h"
/** /**
......
...@@ -479,8 +479,13 @@ dbus_bus_register (DBusConnection *connection, ...@@ -479,8 +479,13 @@ dbus_bus_register (DBusConnection *connection,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
goto out; goto out;
bd->base_service = name; bd->base_service = _dbus_strdup (name);
if (bd->base_service == NULL)
{
_DBUS_SET_OOM (error);
goto out;
}
retval = TRUE; retval = TRUE;
out: out:
...@@ -578,7 +583,7 @@ dbus_bus_get_unix_user (DBusConnection *connection, ...@@ -578,7 +583,7 @@ dbus_bus_get_unix_user (DBusConnection *connection,
} }
if (!dbus_message_append_args (message, if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service, DBUS_TYPE_STRING, &service,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (message); dbus_message_unref (message);
...@@ -659,8 +664,8 @@ dbus_bus_acquire_service (DBusConnection *connection, ...@@ -659,8 +664,8 @@ dbus_bus_acquire_service (DBusConnection *connection,
} }
if (!dbus_message_append_args (message, if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name, DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_UINT32, flags, DBUS_TYPE_UINT32, &flags,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (message); dbus_message_unref (message);
...@@ -731,7 +736,7 @@ dbus_bus_service_exists (DBusConnection *connection, ...@@ -731,7 +736,7 @@ dbus_bus_service_exists (DBusConnection *connection,
} }
if (!dbus_message_append_args (message, if (!dbus_message_append_args (message,
DBUS_TYPE_STRING, service_name, DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (message); dbus_message_unref (message);
...@@ -791,8 +796,8 @@ dbus_bus_activate_service (DBusConnection *connection, ...@@ -791,8 +796,8 @@ dbus_bus_activate_service (DBusConnection *connection,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"ActivateService"); "ActivateService");
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, service_name, if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &service_name,
DBUS_TYPE_UINT32, flags, DBUS_TYPE_INVALID)) DBUS_TYPE_UINT32, &flags, DBUS_TYPE_INVALID))
{ {
dbus_message_unref (msg); dbus_message_unref (msg);
_DBUS_SET_OOM (error); _DBUS_SET_OOM (error);
...@@ -895,7 +900,7 @@ dbus_bus_add_match (DBusConnection *connection, ...@@ -895,7 +900,7 @@ dbus_bus_add_match (DBusConnection *connection,
return; return;
} }
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, rule, if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (msg); dbus_message_unref (msg);
...@@ -933,7 +938,7 @@ dbus_bus_remove_match (DBusConnection *connection, ...@@ -933,7 +938,7 @@ dbus_bus_remove_match (DBusConnection *connection,
DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS, DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS,
"RemoveMatch"); "RemoveMatch");
if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, rule, if (!dbus_message_append_args (msg, DBUS_TYPE_STRING, &rule,
DBUS_TYPE_INVALID)) DBUS_TYPE_INVALID))
{ {
dbus_message_unref (msg); dbus_message_unref (msg);
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "dbus-string.h" #include "dbus-string.h"
#include "dbus-pending-call.h" #include "dbus-pending-call.h"
#include "dbus-object-tree.h" #include "dbus-object-tree.h"
#include "dbus-marshal.h"
#if 0 #if 0
#define CONNECTION_LOCK(connection) do { \ #define CONNECTION_LOCK(connection) do { \
...@@ -1562,15 +1561,6 @@ _dbus_connection_send_preallocated_unlocked (DBusConnection *connection, ...@@ -1562,15 +1561,6 @@ _dbus_connection_send_preallocated_unlocked (DBusConnection *connection,
connection->n_outgoing += 1; connection->n_outgoing += 1;
sig = dbus_message_get_signature (message); sig = dbus_message_get_signature (message);
#ifndef DBUS_DISABLE_ASSERT
{
DBusString foo;
_dbus_verbose (" validating signature '%s'\n", sig);
_dbus_string_init_const (&foo, sig);
_dbus_assert (_dbus_string_validate_signature (&foo, 0,
_dbus_string_get_length (&foo)));
}
#endif
_dbus_verbose ("Message %p (%d %s %s '%s') added to outgoing queue %p, %d pending to send\n", _dbus_verbose ("Message %p (%d %s %s '%s') added to outgoing queue %p, %d pending to send\n",
message, message,
......
...@@ -354,42 +354,6 @@ _dbus_string_array_contains (const char **array, ...@@ -354,42 +354,6 @@ _dbus_string_array_contains (const char **array,
return FALSE; return FALSE;
} }
/**
* Returns a string describing the given type.
*
* @param type the type to describe
* @returns a constant string describing the type
*/
const char *
_dbus_type_to_string (int type)
{
switch (type)
{
case DBUS_TYPE_INVALID:
return "invalid";
case DBUS_TYPE_NIL:
return "nil";
case DBUS_TYPE_BOOLEAN:
return "boolean";
case DBUS_TYPE_INT32:
return "int32";
case DBUS_TYPE_UINT32:
return "uint32";
case DBUS_TYPE_DOUBLE:
return "double";
case DBUS_TYPE_STRING:
return "string";
case DBUS_TYPE_CUSTOM:
return "custom";
case DBUS_TYPE_ARRAY:
return "array";
case DBUS_TYPE_DICT:
return "dict";
default:
return "unknown";
}
}
/** /**
* Returns a string describing the given name. * Returns a string describing the given name.
* *
...@@ -525,6 +489,9 @@ _dbus_test_oom_handling (const char *description, ...@@ -525,6 +489,9 @@ _dbus_test_oom_handling (const char *description,
void *data) void *data)
{ {
int approx_mallocs; int approx_mallocs;
const char *setting;
int max_failures_to_try;
int i;
/* Run once to see about how many mallocs are involved */ /* Run once to see about how many mallocs are involved */
...@@ -540,21 +507,30 @@ _dbus_test_oom_handling (const char *description, ...@@ -540,21 +507,30 @@ _dbus_test_oom_handling (const char *description,
_dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n", _dbus_verbose ("\n=================\n%s: about %d mallocs total\n=================\n",
description, approx_mallocs); description, approx_mallocs);
_dbus_set_fail_alloc_failures (1); setting = _dbus_getenv ("DBUS_TEST_MALLOC_FAILURES");
if (!run_failing_each_malloc (approx_mallocs, description, func, data)) if (setting != NULL)
return FALSE; {
DBusString str;
_dbus_set_fail_alloc_failures (2); long v;
if (!run_failing_each_malloc (approx_mallocs, description, func, data)) _dbus_string_init_const (&str, setting);
return FALSE; v = 4;
if (!_dbus_string_parse_int (&str, 0, &v, NULL))
_dbus_set_fail_alloc_failures (3); _dbus_warn ("couldn't parse '%s' as integer\n", setting);
if (!run_failing_each_malloc (approx_mallocs, description, func, data)) max_failures_to_try = v;
return FALSE; }
else
{
max_failures_to_try = 4;
}
_dbus_set_fail_alloc_failures (4); i = setting ? max_failures_to_try - 1 : 1;
if (!run_failing_each_malloc (approx_mallocs, description, func, data)) while (i < max_failures_to_try)
return FALSE; {
_dbus_set_fail_alloc_failures (i);
if (!run_failing_each_malloc (approx_mallocs, description, func, data))
return FALSE;
++i;
}
_dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n", _dbus_verbose ("\n=================\n%s: all iterations passed\n=================\n",
description); description);
......
...@@ -170,6 +170,7 @@ extern const char _dbus_return_if_fail_warning_format[]; ...@@ -170,6 +170,7 @@ extern const char _dbus_return_if_fail_warning_format[];
#define _DBUS_ALIGN_ADDRESS(this, boundary) \ #define _DBUS_ALIGN_ADDRESS(this, boundary) \
((void*)_DBUS_ALIGN_VALUE(this, boundary)) ((void*)_DBUS_ALIGN_VALUE(this, boundary))
char* _dbus_strdup (const char *str); char* _dbus_strdup (const char *str);
void* _dbus_memdup (const void *mem, void* _dbus_memdup (const void *mem,
size_t n_bytes); size_t n_bytes);
...@@ -207,13 +208,12 @@ dbus_bool_t _dbus_set_fd_nonblocking (int fd, ...@@ -207,13 +208,12 @@ dbus_bool_t _dbus_set_fd_nonblocking (int fd,
DBusError *error); DBusError *error);
void _dbus_verbose_bytes (const unsigned char *data, void _dbus_verbose_bytes (const unsigned char *data,
int len); int len,
int offset);
void _dbus_verbose_bytes_of_string (const DBusString *str, void _dbus_verbose_bytes_of_string (const DBusString *str,
int start, int start,
int len); int len);
const char* _dbus_type_to_string (int type);
const char* _dbus_header_field_to_string (int header_field); const char* _dbus_header_field_to_string (int header_field);
extern const char _dbus_no_memory_message[]; extern const char _dbus_no_memory_message[];
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#define MAINLOOP_SPEW 0 #define MAINLOOP_SPEW 0
#ifdef MAINLOOP_SPEW #if MAINLOOP_SPEW
#ifdef DBUS_ENABLE_VERBOSE_MODE #ifdef DBUS_ENABLE_VERBOSE_MODE
static const char* static const char*
watch_flags_to_string (int flags) watch_flags_to_string (int flags)
......
This diff is collapsed.
...@@ -35,120 +35,6 @@ ...@@ -35,120 +35,6 @@
#error "config.h not included here" #error "config.h not included here"
#endif #endif
/****************************************************** Remove later */
#undef DBUS_TYPE_INVALID