Commit 49646211 authored by Simon McVittie's avatar Simon McVittie

_dbus_server_init_base: raise a DBusError

This can currently only fail from OOM, but I'm about to make
it possible to fail from insufficient entropy.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=90414Reviewed-by: Ralf Habacker's avatarRalf Habacker <ralf.habacker@freenet.de>
[smcv: document @error]
Signed-off-by: default avatarSimon McVittie <simon.mcvittie@collabora.co.uk>
parent f180a839
......@@ -166,8 +166,9 @@ _dbus_server_debug_pipe_new (const char *server_name,
goto nomem_2;
if (!_dbus_server_init_base (&debug_server->base,
&debug_vtable, &address))
goto nomem_3;
&debug_vtable, &address,
error))
goto fail_3;
if (!_dbus_hash_table_insert_string (server_pipe_hash,
debug_server->name,
......@@ -183,7 +184,7 @@ _dbus_server_debug_pipe_new (const char *server_name,
nomem_4:
_dbus_server_finalize_base (&debug_server->base);
nomem_3:
fail_3:
dbus_free (debug_server->name);
nomem_2:
_dbus_string_free (&address);
......@@ -191,7 +192,8 @@ _dbus_server_debug_pipe_new (const char *server_name,
dbus_free (debug_server);
nomem_0:
pipe_hash_unref ();
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
if (error != NULL && !dbus_error_is_set (error))
_DBUS_SET_OOM (error);
return NULL;
}
......
......@@ -93,7 +93,8 @@ struct DBusServer
dbus_bool_t _dbus_server_init_base (DBusServer *server,
const DBusServerVTable *vtable,
const DBusString *address);
const DBusString *address,
DBusError *error);
void _dbus_server_finalize_base (DBusServer *server);
dbus_bool_t _dbus_server_add_watch (DBusServer *server,
DBusWatch *watch);
......
......@@ -324,7 +324,8 @@ _dbus_server_new_for_socket (DBusSocket *fds,
}
if (!_dbus_server_init_base (&socket_server->base,
&socket_vtable, address))
&socket_vtable, address,
error))
goto failed_2;
server = (DBusServer*)socket_server;
......
......@@ -105,12 +105,14 @@ copy_address_with_guid_appended (const DBusString *address,
* @param server the server.
* @param vtable the vtable for the subclass.
* @param address the server's address
* @param error location to store reason for failure
* @returns #TRUE on success.
*/
dbus_bool_t
_dbus_server_init_base (DBusServer *server,
const DBusServerVTable *vtable,
const DBusString *address)
const DBusString *address,
DBusError *error)
{
server->vtable = vtable;
......@@ -130,29 +132,32 @@ _dbus_server_init_base (DBusServer *server,
server->published_address = FALSE;
if (!_dbus_string_init (&server->guid_hex))
return FALSE;
{
_DBUS_SET_OOM (error);
return FALSE;
}
_dbus_generate_uuid (&server->guid);
if (!_dbus_uuid_encode (&server->guid, &server->guid_hex))
goto failed;
goto oom;
server->address = copy_address_with_guid_appended (address,
&server->guid_hex);
if (server->address == NULL)
goto failed;
goto oom;
_dbus_rmutex_new_at_location (&server->mutex);
if (server->mutex == NULL)
goto failed;
goto oom;
server->watches = _dbus_watch_list_new ();
if (server->watches == NULL)
goto failed;
goto oom;
server->timeouts = _dbus_timeout_list_new ();
if (server->timeouts == NULL)
goto failed;
goto oom;
_dbus_data_slot_list_init (&server->slot_list);
......@@ -160,7 +165,8 @@ _dbus_server_init_base (DBusServer *server,
return TRUE;
failed:
oom:
_DBUS_SET_OOM (error);
_dbus_rmutex_free_at_location (&server->mutex);
server->mutex = NULL;
if (server->watches)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment