Coverage report for dbus/dbus-server.c.gcov
-: 0:Source:dbus-server.c
-: 0:Graph:.libs/dbus-server.gcno
-: 0:Data:.libs/dbus-server.gcda
-: 0:Runs:11822
-: 0:Programs:5
-: 1:/* -*- mode: C; c-file-style: "gnu" -*- */
-: 2:/* dbus-server.c DBusServer object
-: 3: *
-: 4: * Copyright (C) 2002, 2003, 2004, 2005 Red Hat Inc.
-: 5: *
-: 6: * Licensed under the Academic Free License version 2.1
-: 7: *
-: 8: * This program is free software; you can redistribute it and/or modify
-: 9: * it under the terms of the GNU General Public License as published by
-: 10: * the Free Software Foundation; either version 2 of the License, or
-: 11: * (at your option) any later version.
-: 12: *
-: 13: * This program is distributed in the hope that it will be useful,
-: 14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
-: 15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-: 16: * GNU General Public License for more details.
-: 17: *
-: 18: * You should have received a copy of the GNU General Public License
-: 19: * along with this program; if not, write to the Free Software
-: 20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-: 21: *
-: 22: */
-: 23:
-: 24:#include "dbus-server.h"
-: 25:#include "dbus-server-unix.h"
-: 26:#include "dbus-string.h"
-: 27:#ifdef DBUS_BUILD_TESTS
-: 28:#include "dbus-server-debug-pipe.h"
-: 29:#endif
-: 30:#include "dbus-address.h"
-: 31:#include "dbus-protocol.h"
-: 32:
-: 33:/**
-: 34: * @defgroup DBusServer DBusServer
-: 35: * @ingroup DBus
-: 36: * @brief Server that listens for new connections.
-: 37: *
-: 38: * Types and functions related to DBusServer.
-: 39: * A DBusServer represents a server that other applications
-: 40: * can connect to. Each connection from another application
-: 41: * is represented by a DBusConnection.
-: 42: *
-: 43: * @todo Thread safety hasn't been looked at for #DBusServer
-: 44: * @todo Need notification to apps of disconnection, may matter for some transports
-: 45: */
-: 46:
-: 47:/**
-: 48: * @defgroup DBusServerInternals DBusServer implementation details
-: 49: * @ingroup DBusInternals
-: 50: * @brief Implementation details of DBusServer
-: 51: *
-: 52: * @{
-: 53: */
-: 54:
-: 55:static void
-: 56:init_guid (DBusGUID *guid)
function init_guid called 15 returned 100% blocks executed 100%
15: 57:{
-: 58: long now;
-: 59: char *p;
-: 60: int ts_size;
-: 61:
15: 62: _dbus_get_current_time (&now, NULL);
call 0 returned 100%
-: 63:
15: 64: guid->as_uint32s[0] = now;
-: 65:
15: 66: ts_size = sizeof (guid->as_uint32s[0]);
15: 67: p = ((char*)guid->as_bytes) + ts_size;
-: 68:
15: 69: _dbus_generate_random_bytes_buffer (p,
call 0 returned 100%
-: 70: sizeof (guid->as_bytes) - ts_size);
15: 71:}
-: 72:
-: 73:/* this is a little fragile since it assumes the address doesn't
-: 74: * already have a guid, but it shouldn't
-: 75: */
-: 76:static char*
-: 77:copy_address_with_guid_appended (const DBusString *address,
-: 78: const DBusString *guid_hex)
function copy_address_with_guid_appended called 15 returned 100% blocks executed 82%
15: 79:{
-: 80: DBusString with_guid;
-: 81: char *retval;
-: 82:
15: 83: if (!_dbus_string_init (&with_guid))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 84: return NULL;
-: 85:
15: 86: if (!_dbus_string_copy (address, 0, &with_guid,
call 0 returned 100%
call 1 returned 100%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
call 4 returned 100%
branch 5 taken 100% (fallthrough)
branch 6 taken 0%
call 7 returned 100%
call 8 returned 100%
branch 9 taken 0% (fallthrough)
branch 10 taken 100%
-: 87: _dbus_string_get_length (&with_guid)) ||
-: 88: !_dbus_string_append (&with_guid, ",guid=") ||
-: 89: !_dbus_string_copy (guid_hex, 0,
-: 90: &with_guid, _dbus_string_get_length (&with_guid)))
-: 91: {
#####: 92: _dbus_string_free (&with_guid);
call 0 never executed
#####: 93: return NULL;
-: 94: }
-: 95:
15: 96: retval = NULL;
15: 97: _dbus_string_steal_data (&with_guid, &retval);
call 0 returned 100%
-: 98:
15: 99: _dbus_string_free (&with_guid);
call 0 returned 100%
-: 100:
15: 101: return retval; /* may be NULL if steal_data failed */
-: 102:}
-: 103:
-: 104:/**
-: 105: * Initializes the members of the DBusServer base class.
-: 106: * Chained up to by subclass constructors.
-: 107: *
-: 108: * @param server the server.
-: 109: * @param vtable the vtable for the subclass.
-: 110: * @param address the server's address
-: 111: * @returns #TRUE on success.
-: 112: */
-: 113:dbus_bool_t
-: 114:_dbus_server_init_base (DBusServer *server,
-: 115: const DBusServerVTable *vtable,
-: 116: const DBusString *address)
function _dbus_server_init_base called 15 returned 100% blocks executed 49%
15: 117:{
-: 118: DBusString guid_raw;
-: 119:
15: 120: server->vtable = vtable;
15: 121: server->refcount.value = 1;
-: 122:
15: 123: server->address = NULL;
15: 124: server->watches = NULL;
15: 125: server->timeouts = NULL;
-: 126:
15: 127: if (!_dbus_string_init (&server->guid_hex))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 128: return FALSE;
-: 129:
15: 130: init_guid (&server->guid);
call 0 returned 100%
-: 131:
15: 132: _dbus_string_init_const_len (&guid_raw, (signed char*) server->guid.as_bytes,
call 0 returned 100%
-: 133: sizeof (server->guid.as_bytes));
15: 134: if (!_dbus_string_hex_encode (&guid_raw, 0,
call 0 returned 100%
call 1 returned 100%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
-: 135: &server->guid_hex,
-: 136: _dbus_string_get_length (&server->guid_hex)))
#####: 137: goto failed;
-: 138:
15: 139: server->address = copy_address_with_guid_appended (address,
call 0 returned 100%
-: 140: &server->guid_hex);
15: 141: if (server->address == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 142: goto failed;
-: 143:
15: 144: server->mutex = _dbus_mutex_new ();
call 0 returned 100%
15: 145: if (server->mutex == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 146: goto failed;
-: 147:
15: 148: server->watches = _dbus_watch_list_new ();
call 0 returned 100%
15: 149: if (server->watches == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 150: goto failed;
-: 151:
15: 152: server->timeouts = _dbus_timeout_list_new ();
call 0 returned 100%
15: 153: if (server->timeouts == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 154: goto failed;
-: 155:
15: 156: _dbus_data_slot_list_init (&server->slot_list);
call 0 returned 100%
-: 157:
15: 158: _dbus_verbose ("Initialized server on address %s\n", server->address);
call 0 returned 100%
-: 159:
15: 160: return TRUE;
-: 161:
#####: 162: failed:
#####: 163: if (server->mutex)
branch 0 never executed
branch 1 never executed
-: 164: {
#####: 165: _dbus_mutex_free (server->mutex);
call 0 never executed
#####: 166: server->mutex = NULL;
-: 167: }
#####: 168: if (server->watches)
branch 0 never executed
branch 1 never executed
-: 169: {
#####: 170: _dbus_watch_list_free (server->watches);
call 0 never executed
#####: 171: server->watches = NULL;
-: 172: }
#####: 173: if (server->timeouts)
branch 0 never executed
branch 1 never executed
-: 174: {
#####: 175: _dbus_timeout_list_free (server->timeouts);
call 0 never executed
#####: 176: server->timeouts = NULL;
-: 177: }
#####: 178: if (server->address)
branch 0 never executed
branch 1 never executed
-: 179: {
#####: 180: dbus_free (server->address);
call 0 never executed
#####: 181: server->address = NULL;
-: 182: }
#####: 183: _dbus_string_free (&server->guid_hex);
call 0 never executed
-: 184:
#####: 185: return FALSE;
-: 186:}
-: 187:
-: 188:/**
-: 189: * Finalizes the members of the DBusServer base class.
-: 190: * Chained up to by subclass finalizers.
-: 191: *
-: 192: * @param server the server.
-: 193: */
-: 194:void
-: 195:_dbus_server_finalize_base (DBusServer *server)
function _dbus_server_finalize_base called 15 returned 100% blocks executed 100%
15: 196:{
-: 197: /* We don't have the lock, but nobody should be accessing
-: 198: * concurrently since they don't have a ref
-: 199: */
-: 200:#ifndef DBUS_DISABLE_CHECKS
15: 201: _dbus_assert (!server->have_server_lock);
call 0 returned 100%
-: 202:#endif
15: 203: _dbus_assert (server->disconnected);
call 0 returned 100%
-: 204:
-: 205: /* calls out to application code... */
15: 206: _dbus_data_slot_list_free (&server->slot_list);
call 0 returned 100%
-: 207:
15: 208: dbus_server_set_new_connection_function (server, NULL, NULL, NULL);
call 0 returned 100%
-: 209:
15: 210: _dbus_watch_list_free (server->watches);
call 0 returned 100%
15: 211: _dbus_timeout_list_free (server->timeouts);
call 0 returned 100%
-: 212:
15: 213: _dbus_mutex_free (server->mutex);
call 0 returned 100%
-: 214:
15: 215: dbus_free (server->address);
call 0 returned 100%
-: 216:
15: 217: dbus_free_string_array (server->auth_mechanisms);
call 0 returned 100%
-: 218:
15: 219: _dbus_string_free (&server->guid_hex);
call 0 returned 100%
15: 220:}
-: 221:
-: 222:
-: 223:typedef dbus_bool_t (* DBusWatchAddFunction) (DBusWatchList *list,
-: 224: DBusWatch *watch);
-: 225:typedef void (* DBusWatchRemoveFunction) (DBusWatchList *list,
-: 226: DBusWatch *watch);
-: 227:typedef void (* DBusWatchToggleFunction) (DBusWatchList *list,
-: 228: DBusWatch *watch,
-: 229: dbus_bool_t enabled);
-: 230:
-: 231:static dbus_bool_t
-: 232:protected_change_watch (DBusServer *server,
-: 233: DBusWatch *watch,
-: 234: DBusWatchAddFunction add_function,
-: 235: DBusWatchRemoveFunction remove_function,
-: 236: DBusWatchToggleFunction toggle_function,
-: 237: dbus_bool_t enabled)
function protected_change_watch called 26 returned 100% blocks executed 88%
26: 238:{
-: 239: DBusWatchList *watches;
-: 240: dbus_bool_t retval;
-: 241:
26: 242: HAVE_LOCK_CHECK (server);
call 0 returned 100%
-: 243:
-: 244: /* This isn't really safe or reasonable; a better pattern is the "do
-: 245: * everything, then drop lock and call out" one; but it has to be
-: 246: * propagated up through all callers
-: 247: */
-: 248:
26: 249: watches = server->watches;
26: 250: if (watches)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 251: {
26: 252: server->watches = NULL;
26: 253: _dbus_server_ref_unlocked (server);
call 0 returned 100%
26: 254: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 255:
26: 256: if (add_function)
branch 0 taken 50% (fallthrough)
branch 1 taken 50%
13: 257: retval = (* add_function) (watches, watch);
call 0 returned 100%
13: 258: else if (remove_function)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 259: {
13: 260: retval = TRUE;
13: 261: (* remove_function) (watches, watch);
call 0 returned 100%
-: 262: }
-: 263: else
-: 264: {
#####: 265: retval = TRUE;
#####: 266: (* toggle_function) (watches, watch, enabled);
call 0 never executed
-: 267: }
-: 268:
26: 269: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
26: 270: server->watches = watches;
26: 271: _dbus_server_unref_unlocked (server);
call 0 returned 100%
-: 272:
26: 273: return retval;
-: 274: }
-: 275: else
#####: 276: return FALSE;
-: 277:}
-: 278:
-: 279:/**
-: 280: * Adds a watch for this server, chaining out to application-provided
-: 281: * watch handlers.
-: 282: *
-: 283: * @param server the server.
-: 284: * @param watch the watch to add.
-: 285: */
-: 286:dbus_bool_t
-: 287:_dbus_server_add_watch (DBusServer *server,
-: 288: DBusWatch *watch)
function _dbus_server_add_watch called 13 returned 100% blocks executed 100%
13: 289:{
13: 290: HAVE_LOCK_CHECK (server);
call 0 returned 100%
13: 291: return protected_change_watch (server, watch,
call 0 returned 100%
-: 292: _dbus_watch_list_add_watch,
-: 293: NULL, NULL, FALSE);
-: 294:}
-: 295:
-: 296:/**
-: 297: * Removes a watch previously added with _dbus_server_remove_watch().
-: 298: *
-: 299: * @param server the server.
-: 300: * @param watch the watch to remove.
-: 301: */
-: 302:void
-: 303:_dbus_server_remove_watch (DBusServer *server,
-: 304: DBusWatch *watch)
function _dbus_server_remove_watch called 13 returned 100% blocks executed 100%
13: 305:{
13: 306: HAVE_LOCK_CHECK (server);
call 0 returned 100%
13: 307: protected_change_watch (server, watch,
call 0 returned 100%
-: 308: NULL,
-: 309: _dbus_watch_list_remove_watch,
-: 310: NULL, FALSE);
13: 311:}
-: 312:
-: 313:/**
-: 314: * Toggles a watch and notifies app via server's
-: 315: * DBusWatchToggledFunction if available. It's an error to call this
-: 316: * function on a watch that was not previously added.
-: 317: *
-: 318: * @param server the server.
-: 319: * @param watch the watch to toggle.
-: 320: * @param enabled whether to enable or disable
-: 321: */
-: 322:void
-: 323:_dbus_server_toggle_watch (DBusServer *server,
-: 324: DBusWatch *watch,
-: 325: dbus_bool_t enabled)
function _dbus_server_toggle_watch called 0 returned 0% blocks executed 0%
#####: 326:{
#####: 327: _dbus_assert (watch != NULL);
call 0 never executed
-: 328:
#####: 329: HAVE_LOCK_CHECK (server);
call 0 never executed
#####: 330: protected_change_watch (server, watch,
call 0 never executed
-: 331: NULL, NULL,
-: 332: _dbus_watch_list_toggle_watch,
-: 333: enabled);
#####: 334:}
-: 335:
-: 336:
-: 337:typedef dbus_bool_t (* DBusTimeoutAddFunction) (DBusTimeoutList *list,
-: 338: DBusTimeout *timeout);
-: 339:typedef void (* DBusTimeoutRemoveFunction) (DBusTimeoutList *list,
-: 340: DBusTimeout *timeout);
-: 341:typedef void (* DBusTimeoutToggleFunction) (DBusTimeoutList *list,
-: 342: DBusTimeout *timeout,
-: 343: dbus_bool_t enabled);
-: 344:
-: 345:
-: 346:static dbus_bool_t
-: 347:protected_change_timeout (DBusServer *server,
-: 348: DBusTimeout *timeout,
-: 349: DBusTimeoutAddFunction add_function,
-: 350: DBusTimeoutRemoveFunction remove_function,
-: 351: DBusTimeoutToggleFunction toggle_function,
-: 352: dbus_bool_t enabled)
function protected_change_timeout called 0 returned 0% blocks executed 0%
#####: 353:{
-: 354: DBusTimeoutList *timeouts;
-: 355: dbus_bool_t retval;
-: 356:
#####: 357: HAVE_LOCK_CHECK (server);
call 0 never executed
-: 358:
-: 359: /* This isn't really safe or reasonable; a better pattern is the "do everything, then
-: 360: * drop lock and call out" one; but it has to be propagated up through all callers
-: 361: */
-: 362:
#####: 363: timeouts = server->timeouts;
#####: 364: if (timeouts)
branch 0 never executed
branch 1 never executed
-: 365: {
#####: 366: server->timeouts = NULL;
#####: 367: _dbus_server_ref_unlocked (server);
call 0 never executed
#####: 368: SERVER_UNLOCK (server);
call 0 never executed
call 1 never executed
-: 369:
#####: 370: if (add_function)
branch 0 never executed
branch 1 never executed
#####: 371: retval = (* add_function) (timeouts, timeout);
call 0 never executed
#####: 372: else if (remove_function)
branch 0 never executed
branch 1 never executed
-: 373: {
#####: 374: retval = TRUE;
#####: 375: (* remove_function) (timeouts, timeout);
call 0 never executed
-: 376: }
-: 377: else
-: 378: {
#####: 379: retval = TRUE;
#####: 380: (* toggle_function) (timeouts, timeout, enabled);
call 0 never executed
-: 381: }
-: 382:
#####: 383: SERVER_LOCK (server);
call 0 never executed
call 1 never executed
#####: 384: server->timeouts = timeouts;
#####: 385: _dbus_server_unref_unlocked (server);
call 0 never executed
-: 386:
#####: 387: return retval;
-: 388: }
-: 389: else
#####: 390: return FALSE;
-: 391:}
-: 392:
-: 393:/**
-: 394: * Adds a timeout for this server, chaining out to
-: 395: * application-provided timeout handlers. The timeout should be
-: 396: * repeatedly handled with dbus_timeout_handle() at its given interval
-: 397: * until it is removed.
-: 398: *
-: 399: * @param server the server.
-: 400: * @param timeout the timeout to add.
-: 401: */
-: 402:dbus_bool_t
-: 403:_dbus_server_add_timeout (DBusServer *server,
-: 404: DBusTimeout *timeout)
function _dbus_server_add_timeout called 0 returned 0% blocks executed 0%
#####: 405:{
#####: 406: return protected_change_timeout (server, timeout,
call 0 never executed
-: 407: _dbus_timeout_list_add_timeout,
-: 408: NULL, NULL, FALSE);
-: 409:}
-: 410:
-: 411:/**
-: 412: * Removes a timeout previously added with _dbus_server_add_timeout().
-: 413: *
-: 414: * @param server the server.
-: 415: * @param timeout the timeout to remove.
-: 416: */
-: 417:void
-: 418:_dbus_server_remove_timeout (DBusServer *server,
-: 419: DBusTimeout *timeout)
function _dbus_server_remove_timeout called 0 returned 0% blocks executed 0%
#####: 420:{
#####: 421: protected_change_timeout (server, timeout,
call 0 never executed
-: 422: NULL,
-: 423: _dbus_timeout_list_remove_timeout,
-: 424: NULL, FALSE);
#####: 425:}
-: 426:
-: 427:/**
-: 428: * Toggles a timeout and notifies app via server's
-: 429: * DBusTimeoutToggledFunction if available. It's an error to call this
-: 430: * function on a timeout that was not previously added.
-: 431: *
-: 432: * @param server the server.
-: 433: * @param timeout the timeout to toggle.
-: 434: * @param enabled whether to enable or disable
-: 435: */
-: 436:void
-: 437:_dbus_server_toggle_timeout (DBusServer *server,
-: 438: DBusTimeout *timeout,
-: 439: dbus_bool_t enabled)
function _dbus_server_toggle_timeout called 0 returned 0% blocks executed 0%
#####: 440:{
#####: 441: protected_change_timeout (server, timeout,
call 0 never executed
-: 442: NULL, NULL,
-: 443: _dbus_timeout_list_toggle_timeout,
-: 444: enabled);
#####: 445:}
-: 446:
-: 447:
-: 448:/** @} */
-: 449:
-: 450:/**
-: 451: * @addtogroup DBusServer
-: 452: *
-: 453: * @{
-: 454: */
-: 455:
-: 456:
-: 457:/**
-: 458: * @typedef DBusServer
-: 459: *
-: 460: * An opaque object representing a server that listens for
-: 461: * connections from other applications. Each time a connection
-: 462: * is made, a new DBusConnection is created and made available
-: 463: * via an application-provided DBusNewConnectionFunction.
-: 464: * The DBusNewConnectionFunction is provided with
-: 465: * dbus_server_set_new_connection_function().
-: 466: *
-: 467: */
-: 468:
-: 469:/**
-: 470: * Listens for new connections on the given address.
-: 471: * Returns #NULL if listening fails for any reason.
-: 472: * Otherwise returns a new #DBusServer.
-: 473: * dbus_server_set_new_connection_function() and
-: 474: * dbus_server_set_watch_functions() should be called
-: 475: * immediately to render the server fully functional.
-: 476: *
-: 477: * @todo error messages on bad address could really be better.
-: 478: * DBusResultCode is a bit limiting here.
-: 479: *
-: 480: * @param address the address of this server.
-: 481: * @param error location to store rationale for failure.
-: 482: * @returns a new DBusServer, or #NULL on failure.
-: 483: *
-: 484: */
-: 485:DBusServer*
-: 486:dbus_server_listen (const char *address,
-: 487: DBusError *error)
function dbus_server_listen called 15 returned 100% blocks executed 69%
15: 488:{
-: 489: DBusServer *server;
-: 490: DBusAddressEntry **entries;
-: 491: int len, i;
-: 492: const char *address_problem_type;
-: 493: const char *address_problem_field;
-: 494: const char *address_problem_other;
-: 495:
15: 496: _dbus_return_val_if_fail (address != NULL, NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
15: 497: _dbus_return_val_if_error_is_set (error, NULL);
call 0 returned 100%
branch 1 taken 33% (fallthrough)
branch 2 taken 67%
call 3 returned 100%
branch 4 taken 0% (fallthrough)
branch 5 taken 100%
call 6 never executed
call 7 never executed
-: 498:
15: 499: if (!dbus_parse_address (address, &entries, &len, error))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
#####: 500: return NULL;
-: 501:
15: 502: server = NULL;
15: 503: address_problem_type = NULL;
15: 504: address_problem_field = NULL;
15: 505: address_problem_other = NULL;
-: 506:
15: 507: for (i = 0; i < len; i++)
branch 0 taken 100%
branch 1 taken 0% (fallthrough)
-: 508: {
-: 509: const char *method;
-: 510:
15: 511: method = dbus_address_entry_get_method (entries[i]);
call 0 returned 100%
-: 512:
15: 513: if (strcmp (method, "unix") == 0)
call 0 returned 100%
branch 1 taken 33% (fallthrough)
branch 2 taken 67%
-: 514: {
5: 515: const char *path = dbus_address_entry_get_value (entries[i], "path");
call 0 returned 100%
5: 516: const char *tmpdir = dbus_address_entry_get_value (entries[i], "tmpdir");
call 0 returned 100%
5: 517: const char *abstract = dbus_address_entry_get_value (entries[i], "abstract");
call 0 returned 100%
-: 518:
5: 519: if (path == NULL && tmpdir == NULL && abstract == NULL)
branch 0 taken 60% (fallthrough)
branch 1 taken 40%
branch 2 taken 0% (fallthrough)
branch 3 taken 100%
branch 4 never executed
branch 5 never executed
-: 520: {
#####: 521: address_problem_type = "unix";
#####: 522: address_problem_field = "path or tmpdir or abstract";
#####: 523: goto bad_address;
-: 524: }
-: 525:
5: 526: if ((path && tmpdir) ||
branch 0 taken 40% (fallthrough)
branch 1 taken 60%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
branch 4 taken 40% (fallthrough)
branch 5 taken 60%
branch 6 taken 100% (fallthrough)
branch 7 taken 0%
branch 8 taken 60% (fallthrough)
branch 9 taken 40%
branch 10 taken 0% (fallthrough)
branch 11 taken 100%
-: 527: (path && abstract) ||
-: 528: (tmpdir && abstract))
-: 529: {
#####: 530: address_problem_other = "cannot specify two of \"path\" and \"tmpdir\" and \"abstract\" at the same time";
#####: 531: goto bad_address;
-: 532: }
-: 533:
5: 534: if (tmpdir != NULL)
branch 0 taken 60% (fallthrough)
branch 1 taken 40%
-: 535: {
-: 536: DBusString full_path;
-: 537: DBusString filename;
-: 538:
3: 539: if (!_dbus_string_init (&full_path))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 540: {
#####: 541: dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call 0 never executed
#####: 542: goto out;
-: 543: }
-: 544:
3: 545: if (!_dbus_string_init (&filename))
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
-: 546: {
#####: 547: _dbus_string_free (&full_path);
call 0 never executed
#####: 548: dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call 0 never executed
#####: 549: goto out;
-: 550: }
-: 551:
3: 552: if (!_dbus_string_append (&filename,
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
call 3 returned 100%
branch 4 taken 100% (fallthrough)
branch 5 taken 0%
call 6 returned 100%
branch 7 taken 100% (fallthrough)
branch 8 taken 0%
call 9 returned 100%
branch 10 taken 0% (fallthrough)
branch 11 taken 100%
-: 553: "dbus-") ||
-: 554: !_dbus_generate_random_ascii (&filename, 10) ||
-: 555: !_dbus_string_append (&full_path, tmpdir) ||
-: 556: !_dbus_concat_dir_and_file (&full_path, &filename))
-: 557: {
#####: 558: _dbus_string_free (&full_path);
call 0 never executed
#####: 559: _dbus_string_free (&filename);
call 0 never executed
#####: 560: dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call 0 never executed
#####: 561: goto out;
-: 562: }
-: 563:
-: 564: /* FIXME - we will unconditionally unlink() the path if
-: 565: * we don't support abstract namespace. unlink() does
-: 566: * not follow symlinks, but would like independent
-: 567: * confirmation this is safe enough. See also
-: 568: * _dbus_listen_unix_socket() and comments therein.
-: 569: */
-: 570:
-: 571: /* Always use abstract namespace if possible with tmpdir */
-: 572:
3: 573: server =
call 0 returned 100%
call 1 returned 100%
-: 574: _dbus_server_new_for_domain_socket (_dbus_string_get_const_data (&full_path),
-: 575:#ifdef HAVE_ABSTRACT_SOCKETS
-: 576: TRUE,
-: 577:#else
-: 578: FALSE,
-: 579:#endif
-: 580: error);
-: 581:
3: 582: _dbus_string_free (&full_path);
call 0 returned 100%
3: 583: _dbus_string_free (&filename);
call 0 returned 100%
-: 584: }
-: 585: else
-: 586: {
2: 587: if (path)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
2: 588: server = _dbus_server_new_for_domain_socket (path, FALSE, error);
call 0 returned 100%
-: 589: else
#####: 590: server = _dbus_server_new_for_domain_socket (abstract, TRUE, error);
call 0 never executed
-: 591: }
-: 592: }
10: 593: else if (strcmp (method, "tcp") == 0)
call 0 returned 100%
branch 1 taken 80% (fallthrough)
branch 2 taken 20%
-: 594: {
8: 595: const char *host = dbus_address_entry_get_value (entries[i], "host");
call 0 returned 100%
8: 596: const char *port = dbus_address_entry_get_value (entries[i], "port");
call 0 returned 100%
-: 597: DBusString str;
-: 598: long lport;
-: 599: dbus_bool_t sresult;
-: 600:
8: 601: if (port == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 602: {
#####: 603: address_problem_type = "tcp";
#####: 604: address_problem_field = "port";
#####: 605: goto bad_address;
-: 606: }
-: 607:
8: 608: _dbus_string_init_const (&str, port);
call 0 returned 100%
8: 609: sresult = _dbus_string_parse_int (&str, 0, &lport, NULL);
call 0 returned 100%
8: 610: _dbus_string_free (&str);
call 0 returned 100%
-: 611:
8: 612: if (sresult == FALSE || lport <= 0 || lport > 65535)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
branch 4 taken 0% (fallthrough)
branch 5 taken 100%
-: 613: {
#####: 614: address_problem_other = "Port is not an integer between 0 and 65535";
#####: 615: goto bad_address;
-: 616: }
-: 617:
8: 618: server = _dbus_server_new_for_tcp_socket (host, lport, error);
call 0 returned 100%
-: 619:
8: 620: if (server)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
8: 621: break;
-: 622: }
-: 623:#ifdef DBUS_BUILD_TESTS
2: 624: else if (strcmp (method, "debug-pipe") == 0)
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
-: 625: {
2: 626: const char *name = dbus_address_entry_get_value (entries[i], "name");
call 0 returned 100%
-: 627:
2: 628: if (name == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 629: {
#####: 630: address_problem_type = "debug-pipe";
#####: 631: address_problem_field = "name";
#####: 632: goto bad_address;
-: 633: }
-: 634:
2: 635: server = _dbus_server_debug_pipe_new (name, error);
call 0 returned 100%
-: 636: }
-: 637:#endif
-: 638: else
-: 639: {
#####: 640: address_problem_other = "Unknown address type (examples of valid types are \"unix\" and \"tcp\")";
#####: 641: goto bad_address;
-: 642: }
-: 643:
7: 644: if (server)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
7: 645: break;
-: 646: }
-: 647:
15: 648: out:
-: 649:
15: 650: dbus_address_entries_free (entries);
call 0 returned 100%
15: 651: return server;
-: 652:
#####: 653: bad_address:
#####: 654: dbus_address_entries_free (entries);
call 0 never executed
#####: 655: if (address_problem_type != NULL)
branch 0 never executed
branch 1 never executed
#####: 656: dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
call 0 never executed
-: 657: "Server address of type %s was missing argument %s",
-: 658: address_problem_type, address_problem_field);
-: 659: else
#####: 660: dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
call 0 never executed
-: 661: "Could not parse server address: %s",
-: 662: address_problem_other);
-: 663:
#####: 664: return NULL;
-: 665:}
-: 666:
-: 667:/**
-: 668: * Increments the reference count of a DBusServer.
-: 669: *
-: 670: * @param server the server.
-: 671: * @returns the server
-: 672: */
-: 673:DBusServer *
-: 674:dbus_server_ref (DBusServer *server)
function dbus_server_ref called 5521 returned 100% blocks executed 65%
5521: 675:{
5521: 676: _dbus_return_val_if_fail (server != NULL, NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
5521: 677: _dbus_return_val_if_fail (server->refcount.value > 0, NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 678:
-: 679:#ifdef DBUS_HAVE_ATOMIC_INT
-: 680: _dbus_atomic_inc (&server->refcount);
-: 681:#else
5521: 682: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
5521: 683: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 684:
5521: 685: server->refcount.value += 1;
5521: 686: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 687:#endif
-: 688:
5521: 689: return server;
-: 690:}
-: 691:
-: 692:/**
-: 693: * Decrements the reference count of a DBusServer. Finalizes the
-: 694: * server if the reference count reaches zero.
-: 695: *
-: 696: * The server must be disconnected before the refcount reaches zero.
-: 697: *
-: 698: * @param server the server.
-: 699: */
-: 700:void
-: 701:dbus_server_unref (DBusServer *server)
function dbus_server_unref called 7932 returned 100% blocks executed 78%
7932: 702:{
-: 703: dbus_bool_t last_unref;
-: 704:
7932: 705: _dbus_return_if_fail (server != NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
7932: 706: _dbus_return_if_fail (server->refcount.value > 0);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 707:
-: 708:#ifdef DBUS_HAVE_ATOMIC_INT
-: 709: last_unref = (_dbus_atomic_dec (&server->refcount) == 1);
-: 710:#else
7932: 711: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 712:
7932: 713: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 714:
7932: 715: server->refcount.value -= 1;
7932: 716: last_unref = (server->refcount.value == 0);
-: 717:
7932: 718: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 719:#endif
-: 720:
7932: 721: if (last_unref)
branch 0 taken 1% (fallthrough)
branch 1 taken 99%
-: 722: {
-: 723: /* lock not held! */
15: 724: _dbus_assert (server->disconnected);
call 0 returned 100%
-: 725:
15: 726: _dbus_assert (server->vtable->finalize != NULL);
call 0 returned 100%
-: 727:
15: 728: (* server->vtable->finalize) (server);
call 0 returned 100%
-: 729: }
-: 730:}
-: 731:
-: 732:/**
-: 733: * Like dbus_server_ref() but does not acquire the lock (must already be held)
-: 734: *
-: 735: * @param server the server.
-: 736: */
-: 737:void
-: 738:_dbus_server_ref_unlocked (DBusServer *server)
function _dbus_server_ref_unlocked called 2422 returned 100% blocks executed 100%
2422: 739:{
2422: 740: _dbus_assert (server != NULL);
call 0 returned 100%
2422: 741: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 742:
2422: 743: HAVE_LOCK_CHECK (server);
call 0 returned 100%
-: 744:
-: 745:#ifdef DBUS_HAVE_ATOMIC_INT
-: 746: _dbus_atomic_inc (&server->refcount);
-: 747:#else
2422: 748: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 749:
2422: 750: server->refcount.value += 1;
-: 751:#endif
2422: 752:}
-: 753:
-: 754:/**
-: 755: * Like dbus_server_unref() but does not acquire the lock (must already be held)
-: 756: *
-: 757: * @param server the server.
-: 758: */
-: 759:void
-: 760:_dbus_server_unref_unlocked (DBusServer *server)
function _dbus_server_unref_unlocked called 26 returned 100% blocks executed 55%
26: 761:{
-: 762: dbus_bool_t last_unref;
-: 763:
26: 764: _dbus_assert (server != NULL);
call 0 returned 100%
26: 765: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 766:
26: 767: HAVE_LOCK_CHECK (server);
call 0 returned 100%
-: 768:
-: 769:#ifdef DBUS_HAVE_ATOMIC_INT
-: 770: last_unref = (_dbus_atomic_dec (&server->refcount) == 1);
-: 771:#else
26: 772: _dbus_assert (server->refcount.value > 0);
call 0 returned 100%
-: 773:
26: 774: server->refcount.value -= 1;
26: 775: last_unref = (server->refcount.value == 0);
-: 776:#endif
-: 777:
26: 778: if (last_unref)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
-: 779: {
#####: 780: _dbus_assert (server->disconnected);
call 0 never executed
-: 781:
#####: 782: SERVER_UNLOCK (server);
call 0 never executed
call 1 never executed
-: 783:
#####: 784: _dbus_assert (server->vtable->finalize != NULL);
call 0 never executed
-: 785:
#####: 786: (* server->vtable->finalize) (server);
call 0 never executed
-: 787: }
26: 788:}
-: 789:
-: 790:/**
-: 791: * Releases the server's address and stops listening for
-: 792: * new clients. If called more than once, only the first
-: 793: * call has an effect. Does not modify the server's
-: 794: * reference count.
-: 795: *
-: 796: * @param server the server.
-: 797: */
-: 798:void
-: 799:dbus_server_disconnect (DBusServer *server)
function dbus_server_disconnect called 15 returned 100% blocks executed 78%
15: 800:{
15: 801: _dbus_return_if_fail (server != NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
15: 802: _dbus_return_if_fail (server->refcount.value > 0);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 803:
15: 804: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
15: 805: _dbus_server_ref_unlocked (server);
call 0 returned 100%
-: 806:
15: 807: _dbus_assert (server->vtable->disconnect != NULL);
call 0 returned 100%
-: 808:
15: 809: if (!server->disconnected)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 810: {
-: 811: /* this has to be first so recursive calls to disconnect don't happen */
15: 812: server->disconnected = TRUE;
-: 813:
15: 814: (* server->vtable->disconnect) (server);
call 0 returned 100%
-: 815: }
-: 816:
15: 817: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
15: 818: dbus_server_unref (server);
call 0 returned 100%
-: 819:}
-: 820:
-: 821:/**
-: 822: * Returns #TRUE if the server is still listening for new connections.
-: 823: *
-: 824: * @param server the server.
-: 825: */
-: 826:dbus_bool_t
-: 827:dbus_server_get_is_connected (DBusServer *server)
function dbus_server_get_is_connected called 6 returned 100% blocks executed 73%
6: 828:{
-: 829: dbus_bool_t retval;
-: 830:
6: 831: _dbus_return_val_if_fail (server != NULL, FALSE);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 832:
6: 833: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
6: 834: retval = !server->disconnected;
6: 835: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 836:
6: 837: return retval;
-: 838:}
-: 839:
-: 840:/**
-: 841: * Returns the address of the server, as a newly-allocated
-: 842: * string which must be freed by the caller.
-: 843: *
-: 844: * @param server the server
-: 845: * @returns the address or #NULL if no memory
-: 846: */
-: 847:char*
-: 848:dbus_server_get_address (DBusServer *server)
function dbus_server_get_address called 5 returned 100% blocks executed 75%
5: 849:{
-: 850: char *retval;
-: 851:
5: 852: _dbus_return_val_if_fail (server != NULL, NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 853:
5: 854: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
5: 855: retval = _dbus_strdup (server->address);
call 0 returned 100%
5: 856: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 857:
5: 858: return retval;
-: 859:}
-: 860:
-: 861:/**
-: 862: * Sets a function to be used for handling new connections. The given
-: 863: * function is passed each new connection as the connection is
-: 864: * created. If the new connection function increments the connection's
-: 865: * reference count, the connection will stay alive. Otherwise, the
-: 866: * connection will be unreferenced and closed.
-: 867: *
-: 868: * @param server the server.
-: 869: * @param function a function to handle new connections.
-: 870: * @param data data to pass to the new connection handler.
-: 871: * @param free_data_function function to free the data.
-: 872: */
-: 873:void
-: 874:dbus_server_set_new_connection_function (DBusServer *server,
-: 875: DBusNewConnectionFunction function,
-: 876: void *data,
-: 877: DBusFreeFunction free_data_function)
function dbus_server_set_new_connection_function called 20 returned 100% blocks executed 73%
20: 878:{
-: 879: DBusFreeFunction old_free_function;
-: 880: void *old_data;
-: 881:
20: 882: _dbus_return_if_fail (server != NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 883:
20: 884: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
20: 885: old_free_function = server->new_connection_free_data_function;
20: 886: old_data = server->new_connection_data;
-: 887:
20: 888: server->new_connection_function = function;
20: 889: server->new_connection_data = data;
20: 890: server->new_connection_free_data_function = free_data_function;
20: 891: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 892:
20: 893: if (old_free_function != NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 894: (* old_free_function) (old_data);
call 0 never executed
-: 895:}
-: 896:
-: 897:/**
-: 898: * Sets the watch functions for the connection. These functions are
-: 899: * responsible for making the application's main loop aware of file
-: 900: * descriptors that need to be monitored for events.
-: 901: *
-: 902: * This function behaves exactly like dbus_connection_set_watch_functions();
-: 903: * see the documentation for that routine.
-: 904: *
-: 905: * @param server the server.
-: 906: * @param add_function function to begin monitoring a new descriptor.
-: 907: * @param remove_function function to stop monitoring a descriptor.
-: 908: * @param toggled_function function to notify when the watch is enabled/disabled
-: 909: * @param data data to pass to add_function and remove_function.
-: 910: * @param free_data_function function to be called to free the data.
-: 911: * @returns #FALSE on failure (no memory)
-: 912: */
-: 913:dbus_bool_t
-: 914:dbus_server_set_watch_functions (DBusServer *server,
-: 915: DBusAddWatchFunction add_function,
-: 916: DBusRemoveWatchFunction remove_function,
-: 917: DBusWatchToggledFunction toggled_function,
-: 918: void *data,
-: 919: DBusFreeFunction free_data_function)
function dbus_server_set_watch_functions called 10 returned 100% blocks executed 75%
10: 920:{
-: 921: dbus_bool_t result;
-: 922: DBusWatchList *watches;
-: 923:
10: 924: _dbus_return_val_if_fail (server != NULL, FALSE);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 925:
10: 926: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
10: 927: watches = server->watches;
10: 928: server->watches = NULL;
10: 929: if (watches)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 930: {
10: 931: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
10: 932: result = _dbus_watch_list_set_functions (watches,
call 0 returned 100%
-: 933: add_function,
-: 934: remove_function,
-: 935: toggled_function,
-: 936: data,
-: 937: free_data_function);
10: 938: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 939: }
-: 940: else
-: 941: {
#####: 942: _dbus_warn ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
call 0 never executed
#####: 943: result = FALSE;
-: 944: }
10: 945: server->watches = watches;
10: 946: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 947:
10: 948: return result;
-: 949:}
-: 950:
-: 951:/**
-: 952: * Sets the timeout functions for the connection. These functions are
-: 953: * responsible for making the application's main loop aware of timeouts.
-: 954: *
-: 955: * This function behaves exactly like dbus_connection_set_timeout_functions();
-: 956: * see the documentation for that routine.
-: 957: *
-: 958: * @param server the server.
-: 959: * @param add_function function to add a timeout.
-: 960: * @param remove_function function to remove a timeout.
-: 961: * @param toggled_function function to notify when the timeout is enabled/disabled
-: 962: * @param data data to pass to add_function and remove_function.
-: 963: * @param free_data_function function to be called to free the data.
-: 964: * @returns #FALSE on failure (no memory)
-: 965: */
-: 966:dbus_bool_t
-: 967:dbus_server_set_timeout_functions (DBusServer *server,
-: 968: DBusAddTimeoutFunction add_function,
-: 969: DBusRemoveTimeoutFunction remove_function,
-: 970: DBusTimeoutToggledFunction toggled_function,
-: 971: void *data,
-: 972: DBusFreeFunction free_data_function)
function dbus_server_set_timeout_functions called 10 returned 100% blocks executed 75%
10: 973:{
-: 974: dbus_bool_t result;
-: 975: DBusTimeoutList *timeouts;
-: 976:
10: 977: _dbus_return_val_if_fail (server != NULL, FALSE);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 978:
10: 979: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
10: 980: timeouts = server->timeouts;
10: 981: server->timeouts = NULL;
10: 982: if (timeouts)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 983: {
10: 984: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
10: 985: result = _dbus_timeout_list_set_functions (timeouts,
call 0 returned 100%
-: 986: add_function,
-: 987: remove_function,
-: 988: toggled_function,
-: 989: data,
-: 990: free_data_function);
10: 991: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 992: }
-: 993: else
-: 994: {
#####: 995: _dbus_warn ("Re-entrant call to %s\n", _DBUS_FUNCTION_NAME);
call 0 never executed
#####: 996: result = FALSE;
-: 997: }
10: 998: server->timeouts = timeouts;
10: 999: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1000:
10: 1001: return result;
-: 1002:}
-: 1003:
-: 1004:/**
-: 1005: * Sets the authentication mechanisms that this server offers
-: 1006: * to clients, as a list of SASL mechanisms. This function
-: 1007: * only affects connections created *after* it is called.
-: 1008: * Pass #NULL instead of an array to use all available mechanisms.
-: 1009: *
-: 1010: * @param server the server
-: 1011: * @param mechanisms #NULL-terminated array of mechanisms
-: 1012: * @returns #FALSE if no memory
-: 1013: */
-: 1014:dbus_bool_t
-: 1015:dbus_server_set_auth_mechanisms (DBusServer *server,
-: 1016: const char **mechanisms)
function dbus_server_set_auth_mechanisms called 5 returned 100% blocks executed 78%
5: 1017:{
-: 1018: char **copy;
-: 1019:
5: 1020: _dbus_return_val_if_fail (server != NULL, FALSE);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 1021:
5: 1022: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1023:
5: 1024: if (mechanisms != NULL)
branch 0 taken 40% (fallthrough)
branch 1 taken 60%
-: 1025: {
2: 1026: copy = _dbus_dup_string_array (mechanisms);
call 0 returned 100%
2: 1027: if (copy == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 1028: return FALSE;
-: 1029: }
-: 1030: else
3: 1031: copy = NULL;
-: 1032:
5: 1033: dbus_free_string_array (server->auth_mechanisms);
call 0 returned 100%
5: 1034: server->auth_mechanisms = copy;
-: 1035:
5: 1036: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1037:
5: 1038: return TRUE;
-: 1039:}
-: 1040:
-: 1041:
-: 1042:static DBusDataSlotAllocator slot_allocator;
-: 1043:_DBUS_DEFINE_GLOBAL_LOCK (server_slots);
-: 1044:
-: 1045:/**
-: 1046: * Allocates an integer ID to be used for storing application-specific
-: 1047: * data on any DBusServer. The allocated ID may then be used
-: 1048: * with dbus_server_set_data() and dbus_server_get_data().
-: 1049: * The slot must be initialized with -1. If a nonnegative
-: 1050: * slot is passed in, the refcount is incremented on that
-: 1051: * slot, rather than creating a new slot.
-: 1052: *
-: 1053: * The allocated slot is global, i.e. all DBusServer objects will have
-: 1054: * a slot with the given integer ID reserved.
-: 1055: *
-: 1056: * @param slot_p address of global variable storing the slot ID
-: 1057: * @returns #FALSE on no memory
-: 1058: */
-: 1059:dbus_bool_t
-: 1060:dbus_server_allocate_data_slot (dbus_int32_t *slot_p)
function dbus_server_allocate_data_slot called 12 returned 100% blocks executed 100%
12: 1061:{
12: 1062: return _dbus_data_slot_allocator_alloc (&slot_allocator,
call 0 returned 100%
-: 1063: _DBUS_LOCK_NAME (server_slots),
-: 1064: slot_p);
-: 1065:}
-: 1066:
-: 1067:/**
-: 1068: * Deallocates a global ID for server data slots.
-: 1069: * dbus_server_get_data() and dbus_server_set_data()
-: 1070: * may no longer be used with this slot.
-: 1071: * Existing data stored on existing DBusServer objects
-: 1072: * will be freed when the server is finalized,
-: 1073: * but may not be retrieved (and may only be replaced
-: 1074: * if someone else reallocates the slot).
-: 1075: *
-: 1076: * @param slot_p address of the slot to deallocate
-: 1077: */
-: 1078:void
-: 1079:dbus_server_free_data_slot (dbus_int32_t *slot_p)
function dbus_server_free_data_slot called 12 returned 100% blocks executed 67%
12: 1080:{
12: 1081: _dbus_return_if_fail (*slot_p >= 0);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 1082:
12: 1083: _dbus_data_slot_allocator_free (&slot_allocator, slot_p);
call 0 returned 100%
-: 1084:}
-: 1085:
-: 1086:/**
-: 1087: * Stores a pointer on a DBusServer, along
-: 1088: * with an optional function to be used for freeing
-: 1089: * the data when the data is set again, or when
-: 1090: * the server is finalized. The slot number
-: 1091: * must have been allocated with dbus_server_allocate_data_slot().
-: 1092: *
-: 1093: * @param server the server
-: 1094: * @param slot the slot number
-: 1095: * @param data the data to store
-: 1096: * @param free_data_func finalizer function for the data
-: 1097: * @returns #TRUE if there was enough memory to store the data
-: 1098: */
-: 1099:dbus_bool_t
-: 1100:dbus_server_set_data (DBusServer *server,
-: 1101: int slot,
-: 1102: void *data,
-: 1103: DBusFreeFunction free_data_func)
function dbus_server_set_data called 5 returned 100% blocks executed 73%
5: 1104:{
-: 1105: DBusFreeFunction old_free_func;
-: 1106: void *old_data;
-: 1107: dbus_bool_t retval;
-: 1108:
5: 1109: _dbus_return_val_if_fail (server != NULL, FALSE);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 1110:
5: 1111: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1112:
5: 1113: retval = _dbus_data_slot_list_set (&slot_allocator,
call 0 returned 100%
-: 1114: &server->slot_list,
-: 1115: slot, data, free_data_func,
-: 1116: &old_free_func, &old_data);
-: 1117:
-: 1118:
5: 1119: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1120:
5: 1121: if (retval)
branch 0 taken 100% (fallthrough)
branch 1 taken 0%
-: 1122: {
-: 1123: /* Do the actual free outside the server lock */
5: 1124: if (old_free_func)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 1125: (* old_free_func) (old_data);
call 0 never executed
-: 1126: }
-: 1127:
5: 1128: return retval;
-: 1129:}
-: 1130:
-: 1131:/**
-: 1132: * Retrieves data previously set with dbus_server_set_data().
-: 1133: * The slot must still be allocated (must not have been freed).
-: 1134: *
-: 1135: * @param server the server
-: 1136: * @param slot the slot to get data from
-: 1137: * @returns the data, or #NULL if not found
-: 1138: */
-: 1139:void*
-: 1140:dbus_server_get_data (DBusServer *server,
-: 1141: int slot)
function dbus_server_get_data called 6 returned 100% blocks executed 75%
6: 1142:{
-: 1143: void *res;
-: 1144:
6: 1145: _dbus_return_val_if_fail (server != NULL, NULL);
call 0 returned 100%
branch 1 taken 0% (fallthrough)
branch 2 taken 100%
call 3 never executed
call 4 never executed
-: 1146:
6: 1147: SERVER_LOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1148:
6: 1149: res = _dbus_data_slot_list_get (&slot_allocator,
call 0 returned 100%
-: 1150: &server->slot_list,
-: 1151: slot);
-: 1152:
6: 1153: SERVER_UNLOCK (server);
call 0 returned 100%
call 1 returned 100%
-: 1154:
6: 1155: return res;
-: 1156:}
-: 1157:
-: 1158:/** @} */
-: 1159:
-: 1160:#ifdef DBUS_BUILD_TESTS
-: 1161:#include "dbus-test.h"
-: 1162:
-: 1163:dbus_bool_t
-: 1164:_dbus_server_test (void)
function _dbus_server_test called 1 returned 100% blocks executed 86%
1: 1165:{
-: 1166: const char *valid_addresses[] = {
-: 1167: "tcp:port=1234",
-: 1168: "unix:path=./boogie",
-: 1169: "tcp:host=localhost,port=1234",
-: 1170: "tcp:host=localhost,port=1234;tcp:port=5678",
-: 1171: "tcp:port=1234;unix:path=./boogie",
1: 1172: };
-: 1173:
-: 1174: DBusServer *server;
-: 1175: int i;
-: 1176:
6: 1177: for (i = 0; i < _DBUS_N_ELEMENTS (valid_addresses); i++)
branch 0 taken 83%
branch 1 taken 17% (fallthrough)
-: 1178: {
5: 1179: server = dbus_server_listen (valid_addresses[i], NULL);
call 0 returned 100%
5: 1180: if (server == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 1181: _dbus_assert_not_reached ("Failed to listen for valid address.");
call 0 never executed
-: 1182:
5: 1183: dbus_server_disconnect (server);
call 0 returned 100%
5: 1184: dbus_server_unref (server);
call 0 returned 100%
-: 1185:
-: 1186: /* Try disconnecting before unreffing */
5: 1187: server = dbus_server_listen (valid_addresses[i], NULL);
call 0 returned 100%
5: 1188: if (server == NULL)
branch 0 taken 0% (fallthrough)
branch 1 taken 100%
#####: 1189: _dbus_assert_not_reached ("Failed to listen for valid address.");
call 0 never executed
-: 1190:
5: 1191: dbus_server_disconnect (server);
call 0 returned 100%
5: 1192: dbus_server_unref (server);
call 0 returned 100%
-: 1193: }
-: 1194:
1: 1195: return TRUE;
-: 1196:}
-: 1197:
-: 1198:#endif /* DBUS_BUILD_TESTS */