Coverage report for bus/connection.c.gcov

        -:    0:Source:connection.c
        -:    0:Graph:connection.gcno
        -:    0:Data:connection.gcda
        -:    0:Runs:10119
        -:    0:Programs:2
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* connection.c  Client connections
        -:    3: *
        -:    4: * Copyright (C) 2003  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:#include "connection.h"
        -:   24:#include "dispatch.h"
        -:   25:#include "policy.h"
        -:   26:#include "services.h"
        -:   27:#include "utils.h"
        -:   28:#include "signals.h"
        -:   29:#include "expirelist.h"
        -:   30:#include "selinux.h"
        -:   31:#include <dbus/dbus-list.h>
        -:   32:#include <dbus/dbus-hash.h>
        -:   33:#include <dbus/dbus-timeout.h>
        -:   34:
        -:   35:static void bus_connection_remove_transactions (DBusConnection *connection);
        -:   36:
        -:   37:typedef struct
        -:   38:{
        -:   39:  BusExpireItem expire_item;
        -:   40:
        -:   41:  DBusConnection *will_get_reply;
        -:   42:  DBusConnection *will_send_reply;
        -:   43:
        -:   44:  dbus_uint32_t reply_serial;
        -:   45:  
        -:   46:} BusPendingReply;
        -:   47:
        -:   48:struct BusConnections
        -:   49:{
        -:   50:  int refcount;
        -:   51:  DBusList *completed;  /**< List of all completed connections */
        -:   52:  int n_completed;      /**< Length of completed list */
        -:   53:  DBusList *incomplete; /**< List of all not-yet-active connections */
        -:   54:  int n_incomplete;     /**< Length of incomplete list */
        -:   55:  BusContext *context;
        -:   56:  DBusHashTable *completed_by_user; /**< Number of completed connections for each UID */
        -:   57:  DBusTimeout *expire_timeout; /**< Timeout for expiring incomplete connections. */
        -:   58:  int stamp;                   /**< Incrementing number */
        -:   59:  BusExpireList *pending_replies; /**< List of pending replies */
        -:   60:};
        -:   61:
        -:   62:static dbus_int32_t connection_data_slot = -1;
        -:   63:
        -:   64:typedef struct
        -:   65:{
        -:   66:  BusConnections *connections;
        -:   67:  DBusList *link_in_connection_list;
        -:   68:  DBusConnection *connection;
        -:   69:  DBusList *services_owned;
        -:   70:  int n_services_owned;
        -:   71:  DBusList *match_rules;
        -:   72:  int n_match_rules;
        -:   73:  char *name;
        -:   74:  DBusList *transaction_messages; /**< Stuff we need to send as part of a transaction */
        -:   75:  DBusMessage *oom_message;
        -:   76:  DBusPreallocatedSend *oom_preallocated;
        -:   77:  BusClientPolicy *policy;
        -:   78:
        -:   79:  BusSELinuxID *selinux_id;
        -:   80:
        -:   81:  long connection_tv_sec;  /**< Time when we connected (seconds component) */
        -:   82:  long connection_tv_usec; /**< Time when we connected (microsec component) */
        -:   83:  int stamp;               /**< connections->stamp last time we were traversed */
        -:   84:} BusConnectionData;
        -:   85:
        -:   86:static dbus_bool_t bus_pending_reply_expired (BusExpireList *list,
        -:   87:                                              DBusList      *link,
        -:   88:                                              void          *data);
        -:   89:
        -:   90:static void bus_connection_drop_pending_replies (BusConnections  *connections,
        -:   91:                                                 DBusConnection  *connection);
        -:   92:
        -:   93:static dbus_bool_t expire_incomplete_timeout (void *data);
        -:   94:
        -:   95:#define BUS_CONNECTION_DATA(connection) (dbus_connection_get_data ((connection), connection_data_slot))
        -:   96:
        -:   97:static DBusLoop*
        -:   98:connection_get_loop (DBusConnection *connection)
function connection_get_loop called 31450 returned 100% blocks executed 100%
    31450:   99:{
        -:  100:  BusConnectionData *d;
        -:  101:
    31450:  102:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  103:
    31450:  104:  return bus_context_get_loop (d->connections->context);
call    0 returned 100%
        -:  105:}
        -:  106:
        -:  107:
        -:  108:static int
        -:  109:get_connections_for_uid (BusConnections *connections,
        -:  110:                         dbus_uid_t      uid)
function get_connections_for_uid called 18376 returned 100% blocks executed 100%
    18376:  111:{
        -:  112:  void *val;
        -:  113:  int current_count;
        -:  114:
        -:  115:  /* val is NULL is 0 when it isn't in the hash yet */
        -:  116:  
    18376:  117:  val = _dbus_hash_table_lookup_ulong (connections->completed_by_user,
call    0 returned 100%
        -:  118:                                       uid);
        -:  119:
    18376:  120:  current_count = _DBUS_POINTER_TO_INT (val);
        -:  121:
    18376:  122:  return current_count;
        -:  123:}
        -:  124:
        -:  125:static dbus_bool_t
        -:  126:adjust_connections_for_uid (BusConnections *connections,
        -:  127:                            dbus_uid_t      uid,
        -:  128:                            int             adjustment)
function adjust_connections_for_uid called 12192 returned 100% blocks executed 94%
    12192:  129:{
        -:  130:  int current_count;
        -:  131:
    12192:  132:  current_count = get_connections_for_uid (connections, uid);
call    0 returned 100%
        -:  133:
    12192:  134:  _dbus_verbose ("Adjusting connection count for UID " DBUS_UID_FORMAT
call    0 returned 100%
        -:  135:                 ": was %d adjustment %d making %d\n",
        -:  136:                 uid, current_count, adjustment, current_count + adjustment);
        -:  137:  
    12192:  138:  _dbus_assert (current_count >= 0);
call    0 returned 100%
        -:  139:  
    12192:  140:  current_count += adjustment;
        -:  141:
    12192:  142:  _dbus_assert (current_count >= 0);
call    0 returned 100%
        -:  143:
    12192:  144:  if (current_count == 0)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  145:    {
        3:  146:      _dbus_hash_table_remove_ulong (connections->completed_by_user, uid);
call    0 returned 100%
        3:  147:      return TRUE;
        -:  148:    }
        -:  149:  else
        -:  150:    {
        -:  151:      dbus_bool_t retval;
        -:  152:      
    12189:  153:      retval = _dbus_hash_table_insert_ulong (connections->completed_by_user,
call    0 returned 100%
        -:  154:                                              uid, _DBUS_INT_TO_POINTER (current_count));
        -:  155:
        -:  156:      /* only positive adjustment can fail as otherwise
        -:  157:       * a hash entry should already exist
        -:  158:       */
    12189:  159:      _dbus_assert (adjustment > 0 ||
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
branch  4 taken 100% (fallthrough)
branch  5 taken 0%
call    6 returned 100%
        -:  160:                    (adjustment <= 0 && retval));
        -:  161:
    12189:  162:      return retval;
        -:  163:    }
        -:  164:}
        -:  165:
        -:  166:void
        -:  167:bus_connection_disconnected (DBusConnection *connection)
function bus_connection_disconnected called 7811 returned 100% blocks executed 91%
     7811:  168:{
        -:  169:  BusConnectionData *d;
        -:  170:  BusService *service;
        -:  171:  BusMatchmaker *matchmaker;
        -:  172:  
     7811:  173:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     7811:  174:  _dbus_assert (d != NULL);
call    0 returned 100%
        -:  175:
     7811:  176:  _dbus_verbose ("%s disconnected, dropping all service ownership and releasing\n",
branch  0 taken 78% (fallthrough)
branch  1 taken 22%
call    2 returned 100%
        -:  177:                 d->name ? d->name : "(inactive)");
        -:  178:
        -:  179:  /* Delete our match rules */
     7811:  180:  if (d->n_match_rules > 0)
branch  0 taken 42% (fallthrough)
branch  1 taken 58%
        -:  181:    {
     3256:  182:      matchmaker = bus_context_get_matchmaker (d->connections->context);
call    0 returned 100%
     3256:  183:      bus_matchmaker_disconnected (matchmaker, connection);
call    0 returned 100%
        -:  184:    }
        -:  185:  
        -:  186:  /* Drop any service ownership. FIXME Unfortunately, this requires
        -:  187:   * memory allocation and there doesn't seem to be a good way to
        -:  188:   * handle it other than sleeping; we can't "fail" the operation of
        -:  189:   * disconnecting a client, and preallocating a broadcast "service is
        -:  190:   * now gone" message for every client-service pair seems kind of
        -:  191:   * involved. Probably we need to do that though.
        -:  192:   */
    22463:  193:  while ((service = _dbus_list_get_last (&d->services_owned)))
call    0 returned 100%
branch  1 taken 47%
branch  2 taken 53% (fallthrough)
        -:  194:    {
        -:  195:      BusTransaction *transaction;
        -:  196:      DBusError error;
        -:  197:
     7335:  198:    retry:
        -:  199:      
     7335:  200:      dbus_error_init (&error);
call    0 returned 100%
        -:  201:        
    15129:  202:      while ((transaction = bus_transaction_new (d->connections->context)) == NULL)
call    0 returned 100%
branch  1 taken 6%
branch  2 taken 94% (fallthrough)
      459:  203:        _dbus_wait_for_memory ();
call    0 returned 100%
        -:  204:        
     7335:  205:      if (!bus_service_remove_owner (service, connection,
call    0 returned 100%
branch  1 taken 7% (fallthrough)
branch  2 taken 93%
        -:  206:                                     transaction, &error))
        -:  207:        {
      494:  208:          _DBUS_ASSERT_ERROR_IS_SET (&error);
call    0 returned 100%
call    1 returned 100%
        -:  209:          
      494:  210:          if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -:  211:            {
      494:  212:              dbus_error_free (&error);
call    0 returned 100%
      494:  213:              bus_transaction_cancel_and_free (transaction);
call    0 returned 100%
      494:  214:              _dbus_wait_for_memory ();
call    0 returned 100%
      494:  215:              goto retry;
        -:  216:            }
        -:  217:          else
        -:  218:            {
    #####:  219:              _dbus_verbose ("Failed to remove service owner: %s %s\n",
call    0 never executed
        -:  220:                             error.name, error.message);
    #####:  221:              _dbus_assert_not_reached ("Removing service owner failed for non-memory-related reason");
call    0 never executed
        -:  222:            }
        -:  223:        }
        -:  224:        
     6841:  225:      bus_transaction_execute_and_free (transaction);
call    0 returned 100%
        -:  226:    }
        -:  227:
     7811:  228:  bus_dispatch_remove_connection (connection);
call    0 returned 100%
        -:  229:  
        -:  230:  /* no more watching */
     7811:  231:  if (!dbus_connection_set_watch_functions (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  232:                                            NULL, NULL, NULL,
        -:  233:                                            connection,
        -:  234:                                            NULL))
    #####:  235:    _dbus_assert_not_reached ("setting watch functions to NULL failed");
call    0 never executed
        -:  236:
     7811:  237:  if (!dbus_connection_set_timeout_functions (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  238:                                              NULL, NULL, NULL,
        -:  239:                                              connection,
        -:  240:                                              NULL))
    #####:  241:    _dbus_assert_not_reached ("setting timeout functions to NULL failed");
call    0 never executed
        -:  242:  
     7811:  243:  dbus_connection_set_unix_user_function (connection,
call    0 returned 100%
        -:  244:                                          NULL, NULL, NULL);
        -:  245:
     7811:  246:  dbus_connection_set_dispatch_status_function (connection,
call    0 returned 100%
        -:  247:                                                NULL, NULL, NULL);
        -:  248:  
     7811:  249:  bus_connection_remove_transactions (connection);
call    0 returned 100%
        -:  250:
     7811:  251:  if (d->link_in_connection_list != NULL)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  252:    {
     7811:  253:      if (d->name != NULL)
branch  0 taken 78% (fallthrough)
branch  1 taken 22%
        -:  254:        {
        -:  255:          unsigned long uid;
        -:  256:          
     6096:  257:          _dbus_list_remove_link (&d->connections->completed, d->link_in_connection_list);
call    0 returned 100%
     6096:  258:          d->link_in_connection_list = NULL;
     6096:  259:          d->connections->n_completed -= 1;
        -:  260:
     6096:  261:          if (dbus_connection_get_unix_user (connection, &uid))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -:  262:            {
     6096:  263:              if (!adjust_connections_for_uid (d->connections,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  264:                                               uid, -1))
    #####:  265:                _dbus_assert_not_reached ("adjusting downward should never fail");
call    0 never executed
        -:  266:            }
        -:  267:        }
        -:  268:      else
        -:  269:        {
     1715:  270:          _dbus_list_remove_link (&d->connections->incomplete, d->link_in_connection_list);
call    0 returned 100%
     1715:  271:          d->link_in_connection_list = NULL;
     1715:  272:          d->connections->n_incomplete -= 1;
        -:  273:        }
        -:  274:      
     7811:  275:      _dbus_assert (d->connections->n_incomplete >= 0);
call    0 returned 100%
     7811:  276:      _dbus_assert (d->connections->n_completed >= 0);
call    0 returned 100%
        -:  277:    }
        -:  278:
     7811:  279:  bus_connection_drop_pending_replies (d->connections, connection);
call    0 returned 100%
        -:  280:  
        -:  281:  /* frees "d" as side effect */
     7811:  282:  dbus_connection_set_data (connection,
call    0 returned 100%
        -:  283:                            connection_data_slot,
        -:  284:                            NULL, NULL);
        -:  285:  
     7811:  286:  dbus_connection_unref (connection);
call    0 returned 100%
     7811:  287:}
        -:  288:
        -:  289:static dbus_bool_t
        -:  290:connection_watch_callback (DBusWatch     *watch,
        -:  291:                           unsigned int   condition,
        -:  292:                           void          *data)
function connection_watch_callback called 59196 returned 100% blocks executed 100%
    59196:  293:{
        -:  294: /* FIXME this can be done in dbus-mainloop.c
        -:  295:  * if the code in activation.c for the babysitter
        -:  296:  * watch handler is fixed.
        -:  297:  */
        -:  298:  
        -:  299:#if 0
        -:  300:  _dbus_verbose ("Calling handle_watch\n");
        -:  301:#endif
    59196:  302:  return dbus_watch_handle (watch, condition);
call    0 returned 100%
        -:  303:}
        -:  304:
        -:  305:static dbus_bool_t
        -:  306:add_connection_watch (DBusWatch      *watch,
        -:  307:                      void           *data)
function add_connection_watch called 15746 returned 100% blocks executed 100%
    15746:  308:{
    15746:  309:  DBusConnection *connection = data;
        -:  310:
    15746:  311:  return _dbus_loop_add_watch (connection_get_loop (connection),
call    0 returned 100%
call    1 returned 100%
        -:  312:                               watch, connection_watch_callback, connection,
        -:  313:                               NULL);
        -:  314:}
        -:  315:
        -:  316:static void
        -:  317:remove_connection_watch (DBusWatch      *watch,
        -:  318:                         void           *data)
function remove_connection_watch called 15704 returned 100% blocks executed 100%
    15704:  319:{
    15704:  320:  DBusConnection *connection = data;
        -:  321:  
    15704:  322:  _dbus_loop_remove_watch (connection_get_loop (connection),
call    0 returned 100%
call    1 returned 100%
        -:  323:                           watch, connection_watch_callback, connection);
    15704:  324:}
        -:  325:
        -:  326:static void
        -:  327:connection_timeout_callback (DBusTimeout   *timeout,
        -:  328:                             void          *data)
function connection_timeout_callback called 0 returned 0% blocks executed 0%
    #####:  329:{
        -:  330:  /* DBusConnection *connection = data; */
        -:  331:
        -:  332:  /* can return FALSE on OOM but we just let it fire again later */
    #####:  333:  dbus_timeout_handle (timeout);
call    0 never executed
    #####:  334:}
        -:  335:
        -:  336:static dbus_bool_t
        -:  337:add_connection_timeout (DBusTimeout    *timeout,
        -:  338:                        void           *data)
function add_connection_timeout called 0 returned 0% blocks executed 0%
    #####:  339:{
    #####:  340:  DBusConnection *connection = data;
        -:  341:  
    #####:  342:  return _dbus_loop_add_timeout (connection_get_loop (connection),
call    0 never executed
call    1 never executed
        -:  343:                                 timeout, connection_timeout_callback, connection, NULL);
        -:  344:}
        -:  345:
        -:  346:static void
        -:  347:remove_connection_timeout (DBusTimeout    *timeout,
        -:  348:                           void           *data)
function remove_connection_timeout called 0 returned 0% blocks executed 0%
    #####:  349:{
    #####:  350:  DBusConnection *connection = data;
        -:  351:  
    #####:  352:  _dbus_loop_remove_timeout (connection_get_loop (connection),
call    0 never executed
call    1 never executed
        -:  353:                             timeout, connection_timeout_callback, connection);
    #####:  354:}
        -:  355:
        -:  356:static void
        -:  357:dispatch_status_function (DBusConnection    *connection,
        -:  358:                          DBusDispatchStatus new_status,
        -:  359:                          void              *data)
function dispatch_status_function called 44512 returned 100% blocks executed 100%
    44512:  360:{
    44512:  361:  DBusLoop *loop = data;
        -:  362:  
    44512:  363:  if (new_status != DBUS_DISPATCH_COMPLETE)
branch  0 taken 59% (fallthrough)
branch  1 taken 41%
        -:  364:    {
    53392:  365:      while (!_dbus_loop_queue_dispatch (loop, connection))
call    0 returned 100%
branch  1 taken 4%
branch  2 taken 96% (fallthrough)
     1028:  366:        _dbus_wait_for_memory ();
call    0 returned 100%
        -:  367:    }
    44512:  368:}
        -:  369:
        -:  370:static dbus_bool_t
        -:  371:allow_user_function (DBusConnection *connection,
        -:  372:                     unsigned long   uid,
        -:  373:                     void           *data)
function allow_user_function called 6210 returned 100% blocks executed 100%
     6210:  374:{
        -:  375:  BusConnectionData *d;
        -:  376:    
     6210:  377:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  378:
     6210:  379:  _dbus_assert (d != NULL);
call    0 returned 100%
        -:  380:  
     6210:  381:  return bus_context_allow_user (d->connections->context, uid);
call    0 returned 100%
        -:  382:}
        -:  383:
        -:  384:static void
        -:  385:free_connection_data (void *data)
function free_connection_data called 7884 returned 100% blocks executed 100%
     7884:  386:{
     7884:  387:  BusConnectionData *d = data;
        -:  388:
        -:  389:  /* services_owned should be NULL since we should be disconnected */
     7884:  390:  _dbus_assert (d->services_owned == NULL);
call    0 returned 100%
     7884:  391:  _dbus_assert (d->n_services_owned == 0);
call    0 returned 100%
        -:  392:  /* similarly */
     7884:  393:  _dbus_assert (d->transaction_messages == NULL);
call    0 returned 100%
        -:  394:
     7884:  395:  if (d->oom_preallocated)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
     7811:  396:    dbus_connection_free_preallocated_send (d->connection, d->oom_preallocated);
call    0 returned 100%
        -:  397:
     7884:  398:  if (d->oom_message)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
     7811:  399:    dbus_message_unref (d->oom_message);
call    0 returned 100%
        -:  400:
     7884:  401:  if (d->policy)
branch  0 taken 77% (fallthrough)
branch  1 taken 23%
     6096:  402:    bus_client_policy_unref (d->policy);
call    0 returned 100%
        -:  403:
     7884:  404:  if (d->selinux_id)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        1:  405:    bus_selinux_id_unref (d->selinux_id);
call    0 returned 100%
        -:  406:  
     7884:  407:  dbus_free (d->name);
call    0 returned 100%
        -:  408:  
     7884:  409:  dbus_free (d);
call    0 returned 100%
     7884:  410:}
        -:  411:
        -:  412:static void
        -:  413:call_timeout_callback (DBusTimeout   *timeout,
        -:  414:                       void          *data)
function call_timeout_callback called 3 returned 100% blocks executed 100%
        3:  415:{
        -:  416:  /* can return FALSE on OOM but we just let it fire again later */
        3:  417:  dbus_timeout_handle (timeout);
call    0 returned 100%
        3:  418:}
        -:  419:
        -:  420:BusConnections*
        -:  421:bus_connections_new (BusContext *context)
function bus_connections_new called 3 returned 100% blocks executed 60%
        3:  422:{
        -:  423:  BusConnections *connections;
        -:  424:
        3:  425:  if (!dbus_connection_allocate_data_slot (&connection_data_slot))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  426:    goto failed_0;
        -:  427:
        3:  428:  connections = dbus_new0 (BusConnections, 1);
call    0 returned 100%
        3:  429:  if (connections == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  430:    goto failed_1;
        -:  431:
        3:  432:  connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_ULONG,
call    0 returned 100%
        -:  433:                                                         NULL, NULL);
        3:  434:  if (connections->completed_by_user == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  435:    goto failed_2;
        -:  436:
        3:  437:  connections->expire_timeout = _dbus_timeout_new (100, /* irrelevant */
call    0 returned 100%
        -:  438:                                                   expire_incomplete_timeout,
        -:  439:                                                   connections, NULL);
        3:  440:  if (connections->expire_timeout == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  441:    goto failed_3;
        -:  442:
        3:  443:  _dbus_timeout_set_enabled (connections->expire_timeout, FALSE);
call    0 returned 100%
        -:  444:
        3:  445:  connections->pending_replies = bus_expire_list_new (bus_context_get_loop (context),
call    0 returned 100%
call    1 returned 100%
call    2 returned 100%
        -:  446:                                                      bus_context_get_reply_timeout (context),
        -:  447:                                                      bus_pending_reply_expired,
        -:  448:                                                      connections);
        3:  449:  if (connections->pending_replies == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  450:    goto failed_4;
        -:  451:  
        3:  452:  if (!_dbus_loop_add_timeout (bus_context_get_loop (context),
call    0 returned 100%
call    1 returned 100%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
        -:  453:                               connections->expire_timeout,
        -:  454:                               call_timeout_callback, NULL, NULL))
    #####:  455:    goto failed_5;
        -:  456:  
        3:  457:  connections->refcount = 1;
        3:  458:  connections->context = context;
        -:  459:  
        3:  460:  return connections;
        -:  461:
    #####:  462: failed_5:
    #####:  463:  bus_expire_list_free (connections->pending_replies);
call    0 never executed
    #####:  464: failed_4:
    #####:  465:  _dbus_timeout_unref (connections->expire_timeout);
call    0 never executed
    #####:  466: failed_3:
    #####:  467:  _dbus_hash_table_unref (connections->completed_by_user);
call    0 never executed
    #####:  468: failed_2:
    #####:  469:  dbus_free (connections);
call    0 never executed
    #####:  470: failed_1:
    #####:  471:  dbus_connection_free_data_slot (&connection_data_slot);
call    0 never executed
    #####:  472: failed_0:
    #####:  473:  return NULL;
        -:  474:}
        -:  475:
        -:  476:BusConnections *
        -:  477:bus_connections_ref (BusConnections *connections)
function bus_connections_ref called 0 returned 0% blocks executed 0%
    #####:  478:{
    #####:  479:  _dbus_assert (connections->refcount > 0);
call    0 never executed
    #####:  480:  connections->refcount += 1;
        -:  481:
    #####:  482:  return connections;
        -:  483:}
        -:  484:
        -:  485:void
        -:  486:bus_connections_unref (BusConnections *connections)
function bus_connections_unref called 3 returned 100% blocks executed 83%
        3:  487:{
        3:  488:  _dbus_assert (connections->refcount > 0);
call    0 returned 100%
        3:  489:  connections->refcount -= 1;
        3:  490:  if (connections->refcount == 0)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  491:    {
        -:  492:      /* drop all incomplete */
        6:  493:      while (connections->incomplete != NULL)
branch  0 taken 0%
branch  1 taken 100% (fallthrough)
        -:  494:        {
        -:  495:          DBusConnection *connection;
        -:  496:
    #####:  497:          connection = connections->incomplete->data;
        -:  498:
    #####:  499:          dbus_connection_ref (connection);
call    0 never executed
    #####:  500:          dbus_connection_close (connection);
call    0 never executed
    #####:  501:          bus_connection_disconnected (connection);
call    0 never executed
    #####:  502:          dbus_connection_unref (connection);
call    0 never executed
        -:  503:        }
        -:  504:
        3:  505:      _dbus_assert (connections->n_incomplete == 0);
call    0 returned 100%
        -:  506:      
        -:  507:      /* drop all real connections */
       10:  508:      while (connections->completed != NULL)
branch  0 taken 57%
branch  1 taken 43% (fallthrough)
        -:  509:        {
        -:  510:          DBusConnection *connection;
        -:  511:
        4:  512:          connection = connections->completed->data;
        -:  513:
        4:  514:          dbus_connection_ref (connection);
call    0 returned 100%
        4:  515:          dbus_connection_close (connection);
call    0 returned 100%
        4:  516:          bus_connection_disconnected (connection);
call    0 returned 100%
        4:  517:          dbus_connection_unref (connection);
call    0 returned 100%
        -:  518:        }
        -:  519:
        3:  520:      _dbus_assert (connections->n_completed == 0);
call    0 returned 100%
        -:  521:
        3:  522:      bus_expire_list_free (connections->pending_replies);
call    0 returned 100%
        -:  523:      
        3:  524:      _dbus_loop_remove_timeout (bus_context_get_loop (connections->context),
call    0 returned 100%
call    1 returned 100%
        -:  525:                                 connections->expire_timeout,
        -:  526:                                 call_timeout_callback, NULL);
        -:  527:      
        3:  528:      _dbus_timeout_unref (connections->expire_timeout);
call    0 returned 100%
        -:  529:      
        3:  530:      _dbus_hash_table_unref (connections->completed_by_user);
call    0 returned 100%
        -:  531:      
        3:  532:      dbus_free (connections);
call    0 returned 100%
        -:  533:
        3:  534:      dbus_connection_free_data_slot (&connection_data_slot);
call    0 returned 100%
        -:  535:    }
        3:  536:}
        -:  537:
        -:  538:dbus_bool_t
        -:  539:bus_connections_setup_connection (BusConnections *connections,
        -:  540:                                  DBusConnection *connection)
function bus_connections_setup_connection called 7902 returned 100% blocks executed 78%
     7902:  541:{
        -:  542:  BusConnectionData *d;
        -:  543:  dbus_bool_t retval;
        -:  544:  DBusError error;
        -:  545:  
     7902:  546:  d = dbus_new0 (BusConnectionData, 1);
call    0 returned 100%
        -:  547:  
     7902:  548:  if (d == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        9:  549:    return FALSE;
        -:  550:
     7893:  551:  d->connections = connections;
     7893:  552:  d->connection = connection;
        -:  553:  
     7893:  554:  _dbus_get_current_time (&d->connection_tv_sec,
call    0 returned 100%
        -:  555:                          &d->connection_tv_usec);
        -:  556:  
     7893:  557:  _dbus_assert (connection_data_slot >= 0);
call    0 returned 100%
        -:  558:  
     7893:  559:  if (!dbus_connection_set_data (connection,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  560:                                 connection_data_slot,
        -:  561:                                 d, free_connection_data))
        -:  562:    {
        9:  563:      dbus_free (d);
call    0 returned 100%
        9:  564:      return FALSE;
        -:  565:    }
        -:  566:
     7884:  567:  retval = FALSE;
        -:  568:
     7884:  569:  dbus_error_init (&error);
call    0 returned 100%
     7884:  570:  d->selinux_id = bus_selinux_init_connection_id (connection,
call    0 returned 100%
        -:  571:                                                  &error);
     7884:  572:  if (dbus_error_is_set (&error))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  573:    {
        -:  574:      /* This is a bit bogus because we pretend all errors
        -:  575:       * are OOM; this is done because we know that in bus.c
        -:  576:       * an OOM error disconnects the connection, which is
        -:  577:       * the same thing we want on any other error.
        -:  578:       */
    #####:  579:      dbus_error_free (&error);
call    0 never executed
    #####:  580:      goto out;
        -:  581:    }
        -:  582:  
     7884:  583:  if (!dbus_connection_set_watch_functions (connection,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  584:                                            add_connection_watch,
        -:  585:                                            remove_connection_watch,
        -:  586:                                            NULL,
        -:  587:                                            connection,
        -:  588:                                            NULL))
       42:  589:    goto out;
        -:  590:  
     7842:  591:  if (!dbus_connection_set_timeout_functions (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  592:                                              add_connection_timeout,
        -:  593:                                              remove_connection_timeout,
        -:  594:                                              NULL,
        -:  595:                                              connection, NULL))
    #####:  596:    goto out;
        -:  597:  
     7842:  598:  dbus_connection_set_unix_user_function (connection,
call    0 returned 100%
        -:  599:                                          allow_user_function,
        -:  600:                                          NULL, NULL);
        -:  601:
     7842:  602:  dbus_connection_set_dispatch_status_function (connection,
call    0 returned 100%
call    1 returned 100%
        -:  603:                                                dispatch_status_function,
        -:  604:                                                bus_context_get_loop (connections->context),
        -:  605:                                                NULL);
        -:  606:
     7842:  607:  d->link_in_connection_list = _dbus_list_alloc_link (connection);
call    0 returned 100%
     7842:  608:  if (d->link_in_connection_list == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        9:  609:    goto out;
        -:  610:  
        -:  611:  /* Setup the connection with the dispatcher */
     7833:  612:  if (!bus_dispatch_add_connection (connection))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
       22:  613:    goto out;
        -:  614:
     7811:  615:  if (dbus_connection_get_dispatch_status (connection) != DBUS_DISPATCH_COMPLETE)
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  616:    {
    #####:  617:      if (!_dbus_loop_queue_dispatch (bus_context_get_loop (connections->context), connection))
call    0 never executed
call    1 never executed
branch  2 never executed
branch  3 never executed
        -:  618:        {
    #####:  619:          bus_dispatch_remove_connection (connection);
call    0 never executed
    #####:  620:          goto out;
        -:  621:        }
        -:  622:    }
        -:  623:
     7811:  624:  _dbus_list_append_link (&connections->incomplete, d->link_in_connection_list);
call    0 returned 100%
     7811:  625:  connections->n_incomplete += 1;
        -:  626:  
     7811:  627:  dbus_connection_ref (connection);
call    0 returned 100%
        -:  628:
        -:  629:  /* Note that we might disconnect ourselves here, but it only takes
        -:  630:   * effect on return to the main loop. We call this to free up
        -:  631:   * expired connections if possible, and to queue the timeout for our
        -:  632:   * own expiration.
        -:  633:   */
     7811:  634:  bus_connections_expire_incomplete (connections);
call    0 returned 100%
        -:  635:  
        -:  636:  /* And we might also disconnect ourselves here, but again it
        -:  637:   * only takes effect on return to main loop.
        -:  638:   */
     7811:  639:  if (connections->n_incomplete >
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  640:      bus_context_get_max_incomplete_connections (connections->context))
        -:  641:    {
    #####:  642:      _dbus_verbose ("Number of incomplete connections exceeds max, dropping oldest one\n");
call    0 never executed
        -:  643:      
    #####:  644:      _dbus_assert (connections->incomplete != NULL);
call    0 never executed
        -:  645:      /* Disconnect the oldest unauthenticated connection.  FIXME
        -:  646:       * would it be more secure to drop a *random* connection?  This
        -:  647:       * algorithm seems to mean that if someone can create new
        -:  648:       * connections quickly enough, they can keep anyone else from
        -:  649:       * completing authentication. But random may or may not really
        -:  650:       * help with that, a more elaborate solution might be required.
        -:  651:       */
    #####:  652:      dbus_connection_close (connections->incomplete->data);
call    0 never executed
        -:  653:    }
        -:  654:  
     7811:  655:  retval = TRUE;
        -:  656:
     7884:  657: out:
     7884:  658:  if (!retval)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  659:    {
       73:  660:      if (d->selinux_id)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  661:        bus_selinux_id_unref (d->selinux_id);
call    0 never executed
       73:  662:      d->selinux_id = NULL;
        -:  663:      
       73:  664:      if (!dbus_connection_set_watch_functions (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  665:                                                NULL, NULL, NULL,
        -:  666:                                                connection,
        -:  667:                                                NULL))
    #####:  668:        _dbus_assert_not_reached ("setting watch functions to NULL failed");
call    0 never executed
        -:  669:      
       73:  670:      if (!dbus_connection_set_timeout_functions (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  671:                                                  NULL, NULL, NULL,
        -:  672:                                                  connection,
        -:  673:                                                  NULL))
    #####:  674:        _dbus_assert_not_reached ("setting timeout functions to NULL failed");
call    0 never executed
        -:  675:
       73:  676:      dbus_connection_set_unix_user_function (connection,
call    0 returned 100%
        -:  677:                                              NULL, NULL, NULL);
        -:  678:
       73:  679:      dbus_connection_set_dispatch_status_function (connection,
call    0 returned 100%
        -:  680:                                                    NULL, NULL, NULL);
        -:  681:
       73:  682:      if (d->link_in_connection_list != NULL)
branch  0 taken 30% (fallthrough)
branch  1 taken 70%
        -:  683:        {
       22:  684:          _dbus_assert (d->link_in_connection_list->next == NULL);
call    0 returned 100%
       22:  685:          _dbus_assert (d->link_in_connection_list->prev == NULL);
call    0 returned 100%
       22:  686:          _dbus_list_free_link (d->link_in_connection_list);
call    0 returned 100%
       22:  687:          d->link_in_connection_list = NULL;
        -:  688:        }
        -:  689:      
       73:  690:      if (!dbus_connection_set_data (connection,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  691:                                     connection_data_slot,
        -:  692:                                     NULL, NULL))
    #####:  693:        _dbus_assert_not_reached ("failed to set connection data to null");
call    0 never executed
        -:  694:
        -:  695:      /* "d" has now been freed */
        -:  696:    }
        -:  697:  
     7884:  698:  return retval;
        -:  699:}
        -:  700:
        -:  701:void
        -:  702:bus_connections_expire_incomplete (BusConnections *connections)
function bus_connections_expire_incomplete called 13910 returned 100% blocks executed 84%
    13910:  703:{    
        -:  704:  int next_interval;
        -:  705:
    13910:  706:  next_interval = -1;
        -:  707:  
    13910:  708:  if (connections->incomplete != NULL)
branch  0 taken 56% (fallthrough)
branch  1 taken 44%
        -:  709:    {
        -:  710:      long tv_sec, tv_usec;
        -:  711:      DBusList *link;
        -:  712:      int auth_timeout;
        -:  713:      
     7814:  714:      _dbus_get_current_time (&tv_sec, &tv_usec);
call    0 returned 100%
     7814:  715:      auth_timeout = bus_context_get_auth_timeout (connections->context);
call    0 returned 100%
        -:  716:  
     7814:  717:      link = _dbus_list_get_first_link (&connections->incomplete);
call    0 returned 100%
    15628:  718:      while (link != NULL)
branch  0 taken 100%
branch  1 taken 0% (fallthrough)
        -:  719:        {
     7814:  720:          DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
branch  0 taken 21% (fallthrough)
branch  1 taken 79%
        -:  721:          DBusConnection *connection;
        -:  722:          BusConnectionData *d;
        -:  723:          double elapsed;
        -:  724:      
     7814:  725:          connection = link->data;
        -:  726:      
     7814:  727:          d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  728:      
     7814:  729:          _dbus_assert (d != NULL);
call    0 returned 100%
        -:  730:      
     7814:  731:          elapsed = ELAPSED_MILLISECONDS_SINCE (d->connection_tv_sec,
        -:  732:                                                d->connection_tv_usec,
        -:  733:                                                tv_sec, tv_usec);
        -:  734:
     7814:  735:          if (elapsed >= (double) auth_timeout)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  736:            {
    #####:  737:              _dbus_verbose ("Timing out authentication for connection %p\n", connection);
call    0 never executed
    #####:  738:              dbus_connection_close (connection);
call    0 never executed
        -:  739:            }
        -:  740:          else
        -:  741:            {
        -:  742:              /* We can end the loop, since the connections are in oldest-first order */
     7814:  743:              next_interval = ((double)auth_timeout) - elapsed;
     7814:  744:              _dbus_verbose ("Connection %p authentication expires in %d milliseconds\n",
call    0 returned 100%
        -:  745:                             connection, next_interval);
        -:  746:          
     7814:  747:              break;
        -:  748:            }
        -:  749:      
    #####:  750:          link = next;
        -:  751:        }
        -:  752:    }
        -:  753:
    13910:  754:  bus_expire_timeout_set_interval (connections->expire_timeout,
call    0 returned 100%
        -:  755:                                   next_interval);
    13910:  756:}
        -:  757:
        -:  758:static dbus_bool_t
        -:  759:expire_incomplete_timeout (void *data)
function expire_incomplete_timeout called 3 returned 100% blocks executed 100%
        3:  760:{
        3:  761:  BusConnections *connections = data;
        -:  762:
        3:  763:  _dbus_verbose ("Running %s\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
        -:  764:  
        -:  765:  /* note that this may remove the timeout */
        3:  766:  bus_connections_expire_incomplete (connections);
call    0 returned 100%
        -:  767:
        3:  768:  return TRUE;
        -:  769:}
        -:  770:
        -:  771:dbus_bool_t
        -:  772:bus_connection_get_groups  (DBusConnection   *connection,
        -:  773:                            unsigned long   **groups,
        -:  774:                            int              *n_groups,
        -:  775:                            DBusError        *error)
function bus_connection_get_groups called 0 returned 0% blocks executed 0%
    #####:  776:{
        -:  777:  BusConnectionData *d;
        -:  778:  unsigned long uid;
        -:  779:  DBusUserDatabase *user_database;
        -:  780:  
    #####:  781:  d = BUS_CONNECTION_DATA (connection);
call    0 never executed
        -:  782:
    #####:  783:  _dbus_assert (d != NULL);
call    0 never executed
        -:  784:
    #####:  785:  user_database = bus_context_get_user_database (d->connections->context);
call    0 never executed
        -:  786:  
    #####:  787:  *groups = NULL;
    #####:  788:  *n_groups = 0;
        -:  789:
    #####:  790:  if (dbus_connection_get_unix_user (connection, &uid))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  791:    {
    #####:  792:      if (!_dbus_user_database_get_groups (user_database,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  793:                                           uid, groups, n_groups,
        -:  794:                                           error))
        -:  795:        {
    #####:  796:          _DBUS_ASSERT_ERROR_IS_SET (error);
branch  0 never executed
branch  1 never executed
call    2 never executed
branch  3 never executed
branch  4 never executed
call    5 never executed
    #####:  797:          _dbus_verbose ("Did not get any groups for UID %lu\n",
call    0 never executed
        -:  798:                         uid);
    #####:  799:          return FALSE;
        -:  800:        }
        -:  801:      else
        -:  802:        {
    #####:  803:          _dbus_verbose ("Got %d groups for UID %lu\n",
call    0 never executed
        -:  804:                         *n_groups, uid);
    #####:  805:          return TRUE;
        -:  806:        }
        -:  807:    }
        -:  808:  else
    #####:  809:    return TRUE; /* successfully got 0 groups */
        -:  810:}
        -:  811:
        -:  812:dbus_bool_t
        -:  813:bus_connection_is_in_group (DBusConnection *connection,
        -:  814:                            unsigned long   gid)
function bus_connection_is_in_group called 0 returned 0% blocks executed 0%
    #####:  815:{
        -:  816:  int i;
        -:  817:  unsigned long *group_ids;
        -:  818:  int n_group_ids;
        -:  819:
    #####:  820:  if (!bus_connection_get_groups (connection, &group_ids, &n_group_ids,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  821:                                  NULL))
    #####:  822:    return FALSE;
        -:  823:
    #####:  824:  i = 0;
    #####:  825:  while (i < n_group_ids)
branch  0 never executed
branch  1 never executed
        -:  826:    {
    #####:  827:      if (group_ids[i] == gid)
branch  0 never executed
branch  1 never executed
        -:  828:        {
    #####:  829:          dbus_free (group_ids);
call    0 never executed
    #####:  830:          return TRUE;
        -:  831:        }
    #####:  832:      ++i;
        -:  833:    }
        -:  834:
    #####:  835:  dbus_free (group_ids);
call    0 never executed
    #####:  836:  return FALSE;
        -:  837:}
        -:  838:
        -:  839:BusClientPolicy*
        -:  840:bus_connection_get_policy (DBusConnection *connection)
function bus_connection_get_policy called 153244 returned 100% blocks executed 100%
   153244:  841:{
        -:  842:  BusConnectionData *d;
        -:  843:    
   153244:  844:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  845:
   153244:  846:  _dbus_assert (d != NULL);
call    0 returned 100%
   153244:  847:  _dbus_assert (d->policy != NULL);
call    0 returned 100%
        -:  848:  
   153244:  849:  return d->policy;
        -:  850:}
        -:  851:
        -:  852:static dbus_bool_t
        -:  853:foreach_active (BusConnections               *connections,
        -:  854:                BusConnectionForeachFunction  function,
        -:  855:                void                         *data)
function foreach_active called 0 returned 0% blocks executed 0%
    #####:  856:{
        -:  857:  DBusList *link;
        -:  858:  
    #####:  859:  link = _dbus_list_get_first_link (&connections->completed);
call    0 never executed
    #####:  860:  while (link != NULL)
branch  0 never executed
branch  1 never executed
        -:  861:    {
    #####:  862:      DBusConnection *connection = link->data;
    #####:  863:      DBusList *next = _dbus_list_get_next_link (&connections->completed, link);
branch  0 never executed
branch  1 never executed
        -:  864:
    #####:  865:      if (!(* function) (connection, data))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  866:        return FALSE;
        -:  867:      
    #####:  868:      link = next;
        -:  869:    }
        -:  870:
    #####:  871:  return TRUE;
        -:  872:}
        -:  873:
        -:  874:static dbus_bool_t
        -:  875:foreach_inactive (BusConnections               *connections,
        -:  876:                  BusConnectionForeachFunction  function,
        -:  877:                  void                         *data)
function foreach_inactive called 0 returned 0% blocks executed 0%
    #####:  878:{
        -:  879:  DBusList *link;
        -:  880:  
    #####:  881:  link = _dbus_list_get_first_link (&connections->incomplete);
call    0 never executed
    #####:  882:  while (link != NULL)
branch  0 never executed
branch  1 never executed
        -:  883:    {
    #####:  884:      DBusConnection *connection = link->data;
    #####:  885:      DBusList *next = _dbus_list_get_next_link (&connections->incomplete, link);
branch  0 never executed
branch  1 never executed
        -:  886:
    #####:  887:      if (!(* function) (connection, data))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  888:        return FALSE;
        -:  889:      
    #####:  890:      link = next;
        -:  891:    }
        -:  892:
    #####:  893:  return TRUE;
        -:  894:}
        -:  895:
        -:  896:/**
        -:  897: * Calls function on each active connection; if the function returns
        -:  898: * #FALSE, stops iterating. Active connections are authenticated
        -:  899: * and have sent a Hello message.
        -:  900: *
        -:  901: * @param connections the connections object
        -:  902: * @param function the function
        -:  903: * @param data data to pass to it as a second arg
        -:  904: */
        -:  905:void
        -:  906:bus_connections_foreach_active (BusConnections               *connections,
        -:  907:                                BusConnectionForeachFunction  function,
        -:  908:                                void                         *data)
function bus_connections_foreach_active called 0 returned 0% blocks executed 0%
    #####:  909:{
    #####:  910:  foreach_active (connections, function, data);
call    0 never executed
    #####:  911:}
        -:  912:
        -:  913:/**
        -:  914: * Calls function on each connection; if the function returns
        -:  915: * #FALSE, stops iterating.
        -:  916: *
        -:  917: * @param connections the connections object
        -:  918: * @param function the function
        -:  919: * @param data data to pass to it as a second arg
        -:  920: */
        -:  921:void
        -:  922:bus_connections_foreach (BusConnections               *connections,
        -:  923:                         BusConnectionForeachFunction  function,
        -:  924:                         void                         *data)
function bus_connections_foreach called 0 returned 0% blocks executed 0%
    #####:  925:{
    #####:  926:  if (!foreach_active (connections, function, data))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  927:    return;
        -:  928:
    #####:  929:  foreach_inactive (connections, function, data);
call    0 never executed
        -:  930:}
        -:  931:
        -:  932:BusContext*
        -:  933:bus_connections_get_context (BusConnections *connections)
function bus_connections_get_context called 0 returned 0% blocks executed 0%
    #####:  934:{
    #####:  935:  return connections->context;
        -:  936:}
        -:  937:
        -:  938:/*
        -:  939: * This is used to avoid covering the same connection twice when
        -:  940: * traversing connections. Note that it assumes we will
        -:  941: * bus_connection_mark_stamp() each connection at least once per
        -:  942: * INT_MAX increments of the global stamp, or wraparound would break
        -:  943: * things.
        -:  944: */
        -:  945:void
        -:  946:bus_connections_increment_stamp (BusConnections *connections)
function bus_connections_increment_stamp called 29069 returned 100% blocks executed 100%
    29069:  947:{
    29069:  948:  connections->stamp += 1;
    29069:  949:}
        -:  950:
        -:  951:/* Mark connection with current stamp, return TRUE if it
        -:  952: * didn't already have that stamp
        -:  953: */
        -:  954:dbus_bool_t
        -:  955:bus_connection_mark_stamp (DBusConnection *connection)
function bus_connection_mark_stamp called 73661 returned 100% blocks executed 100%
    73661:  956:{
        -:  957:  BusConnectionData *d;
        -:  958:  
    73661:  959:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  960:  
    73661:  961:  _dbus_assert (d != NULL);
call    0 returned 100%
        -:  962:
    73661:  963:  if (d->stamp == d->connections->stamp)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        3:  964:    return FALSE;
        -:  965:  else
        -:  966:    {
    73658:  967:      d->stamp = d->connections->stamp;
    73658:  968:      return TRUE;
        -:  969:    }
        -:  970:}
        -:  971:
        -:  972:BusContext*
        -:  973:bus_connection_get_context (DBusConnection *connection)
function bus_connection_get_context called 26136 returned 100% blocks executed 100%
    26136:  974:{
        -:  975:  BusConnectionData *d;
        -:  976:
    26136:  977:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  978:
    26136:  979:  _dbus_assert (d != NULL);
call    0 returned 100%
        -:  980:
    26136:  981:  return d->connections->context;
        -:  982:}
        -:  983:
        -:  984:BusConnections*
        -:  985:bus_connection_get_connections (DBusConnection *connection)
function bus_connection_get_connections called 7767 returned 100% blocks executed 100%
     7767:  986:{
        -:  987:  BusConnectionData *d;
        -:  988:    
     7767:  989:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -:  990:
     7767:  991:  _dbus_assert (d != NULL);
call    0 returned 100%
        -:  992:
     7767:  993:  return d->connections;
        -:  994:}
        -:  995:
        -:  996:BusRegistry*
        -:  997:bus_connection_get_registry (DBusConnection *connection)
function bus_connection_get_registry called 11143 returned 100% blocks executed 100%
    11143:  998:{
        -:  999:  BusConnectionData *d;
        -: 1000:
    11143: 1001:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -: 1002:
    11143: 1003:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1004:
    11143: 1005:  return bus_context_get_registry (d->connections->context);
call    0 returned 100%
        -: 1006:}
        -: 1007:
        -: 1008:BusActivation*
        -: 1009:bus_connection_get_activation (DBusConnection *connection)
function bus_connection_get_activation called 5237 returned 100% blocks executed 100%
     5237: 1010:{
        -: 1011:  BusConnectionData *d;
        -: 1012:
     5237: 1013:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -: 1014:
     5237: 1015:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1016:
     5237: 1017:  return bus_context_get_activation (d->connections->context);
call    0 returned 100%
        -: 1018:}
        -: 1019:
        -: 1020:BusMatchmaker*
        -: 1021:bus_connection_get_matchmaker (DBusConnection *connection)
function bus_connection_get_matchmaker called 3316 returned 100% blocks executed 100%
     3316: 1022:{
        -: 1023:  BusConnectionData *d;
        -: 1024:
     3316: 1025:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -: 1026:
     3316: 1027:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1028:
     3316: 1029:  return bus_context_get_matchmaker (d->connections->context);
call    0 returned 100%
        -: 1030:}
        -: 1031:
        -: 1032:BusSELinuxID*
        -: 1033:bus_connection_get_selinux_id (DBusConnection *connection)
function bus_connection_get_selinux_id called 2 returned 100% blocks executed 100%
        2: 1034:{
        -: 1035:  BusConnectionData *d;
        -: 1036:
        2: 1037:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -: 1038:
        2: 1039:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1040:
        2: 1041:  return d->selinux_id;
        -: 1042:}
        -: 1043:
        -: 1044:/**
        -: 1045: * Checks whether the connection is registered with the message bus.
        -: 1046: *
        -: 1047: * @param connection the connection
        -: 1048: * @returns #TRUE if we're an active message bus participant
        -: 1049: */
        -: 1050:dbus_bool_t
        -: 1051:bus_connection_is_active (DBusConnection *connection)
function bus_connection_is_active called 254379 returned 100% blocks executed 100%
   254379: 1052:{
        -: 1053:  BusConnectionData *d;
        -: 1054:
   254379: 1055:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
        -: 1056:  
   254379: 1057:  return d != NULL && d->name != NULL;
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 90% (fallthrough)
branch  3 taken 10%
        -: 1058:}
        -: 1059:
        -: 1060:dbus_bool_t
        -: 1061:bus_connection_preallocate_oom_error (DBusConnection *connection)
function bus_connection_preallocate_oom_error called 26218 returned 100% blocks executed 70%
    26218: 1062:{
        -: 1063:  DBusMessage *message;
        -: 1064:  DBusPreallocatedSend *preallocated;
        -: 1065:  BusConnectionData *d;
        -: 1066:
    26218: 1067:  d = BUS_CONNECTION_DATA (connection);  
call    0 returned 100%
        -: 1068:
    26218: 1069:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1070:
    26218: 1071:  if (d->oom_preallocated != NULL)
branch  0 taken 57% (fallthrough)
branch  1 taken 43%
    14884: 1072:    return TRUE;
        -: 1073:  
    11334: 1074:  preallocated = dbus_connection_preallocate_send (connection);
call    0 returned 100%
    11334: 1075:  if (preallocated == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       82: 1076:    return FALSE;
        -: 1077:
    11252: 1078:  message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
call    0 returned 100%
        -: 1079:
    11252: 1080:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1081:    {
    #####: 1082:      dbus_connection_free_preallocated_send (connection, preallocated);
call    0 never executed
    #####: 1083:      return FALSE;
        -: 1084:    }
        -: 1085:
        -: 1086:  /* d->name may be NULL, but that is OK */
    11252: 1087:  if (!dbus_message_set_error_name (message, DBUS_ERROR_NO_MEMORY) ||
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 0% (fallthrough)
branch  8 taken 100%
        -: 1088:      !dbus_message_set_destination (message, d->name) ||
        -: 1089:      !dbus_message_set_sender (message,
        -: 1090:                                DBUS_SERVICE_DBUS))
        -: 1091:    {
    #####: 1092:      dbus_connection_free_preallocated_send (connection, preallocated);
call    0 never executed
    #####: 1093:      dbus_message_unref (message);
call    0 never executed
    #####: 1094:      return FALSE;
        -: 1095:    }
        -: 1096:  
        -: 1097:  /* set reply serial to placeholder value just so space is already allocated
        -: 1098:   * for it.
        -: 1099:   */
    11252: 1100:  if (!dbus_message_set_reply_serial (message, 14))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1101:    {
    #####: 1102:      dbus_connection_free_preallocated_send (connection, preallocated);
call    0 never executed
    #####: 1103:      dbus_message_unref (message);
call    0 never executed
    #####: 1104:      return FALSE;
        -: 1105:    }
        -: 1106:
    11252: 1107:  d->oom_message = message;
    11252: 1108:  d->oom_preallocated = preallocated;
        -: 1109:  
    11252: 1110:  return TRUE;
        -: 1111:}
        -: 1112:
        -: 1113:void
        -: 1114:bus_connection_send_oom_error (DBusConnection *connection,
        -: 1115:                               DBusMessage    *in_reply_to)
function bus_connection_send_oom_error called 3441 returned 100% blocks executed 92%
     3441: 1116:{
        -: 1117:  BusConnectionData *d;
        -: 1118:
     3441: 1119:  d = BUS_CONNECTION_DATA (connection);  
call    0 returned 100%
        -: 1120:
     3441: 1121:  _dbus_assert (d != NULL);  
call    0 returned 100%
     3441: 1122:  _dbus_assert (d->oom_message != NULL);
call    0 returned 100%
        -: 1123:
        -: 1124:  /* should always succeed since we set it to a placeholder earlier */
     3441: 1125:  if (!dbus_message_set_reply_serial (d->oom_message,
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -: 1126:                                      dbus_message_get_serial (in_reply_to)))
    #####: 1127:    _dbus_assert_not_reached ("Failed to set reply serial for preallocated oom message");
call    0 never executed
        -: 1128:
     3441: 1129:  _dbus_assert (dbus_message_get_sender (d->oom_message) != NULL);
call    0 returned 100%
call    1 returned 100%
        -: 1130:  
     3441: 1131:  dbus_connection_send_preallocated (connection, d->oom_preallocated,
call    0 returned 100%
        -: 1132:                                     d->oom_message, NULL);
        -: 1133:
     3441: 1134:  dbus_message_unref (d->oom_message);
call    0 returned 100%
     3441: 1135:  d->oom_message = NULL;
     3441: 1136:  d->oom_preallocated = NULL;
     3441: 1137:}
        -: 1138:
        -: 1139:void
        -: 1140:bus_connection_add_match_rule_link (DBusConnection *connection,
        -: 1141:                                    DBusList       *link)
function bus_connection_add_match_rule_link called 3308 returned 100% blocks executed 100%
     3308: 1142:{
        -: 1143:  BusConnectionData *d;
        -: 1144:
     3308: 1145:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     3308: 1146:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1147:
     3308: 1148:  _dbus_list_append_link (&d->match_rules, link);
call    0 returned 100%
        -: 1149:
     3308: 1150:  d->n_match_rules += 1;
     3308: 1151:}
        -: 1152:
        -: 1153:dbus_bool_t
        -: 1154:bus_connection_add_match_rule (DBusConnection *connection,
        -: 1155:                               BusMatchRule   *rule)
function bus_connection_add_match_rule called 3312 returned 100% blocks executed 100%
     3312: 1156:{
        -: 1157:    DBusList *link;
        -: 1158:
     3312: 1159:  link = _dbus_list_alloc_link (rule);
call    0 returned 100%
        -: 1160:
     3312: 1161:  if (link == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        4: 1162:    return FALSE;
        -: 1163:
     3308: 1164:  bus_connection_add_match_rule_link (connection, link);
call    0 returned 100%
        -: 1165:
     3308: 1166:  return TRUE;
        -: 1167:}
        -: 1168:
        -: 1169:void
        -: 1170:bus_connection_remove_match_rule (DBusConnection *connection,
        -: 1171:                                  BusMatchRule   *rule)
function bus_connection_remove_match_rule called 3308 returned 100% blocks executed 100%
     3308: 1172:{
        -: 1173:  BusConnectionData *d;
        -: 1174:
     3308: 1175:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     3308: 1176:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1177:
     3308: 1178:  _dbus_list_remove_last (&d->match_rules, rule);
call    0 returned 100%
        -: 1179:
     3308: 1180:  d->n_match_rules -= 1;
     3308: 1181:  _dbus_assert (d->n_match_rules >= 0);
call    0 returned 100%
     3308: 1182:}
        -: 1183:
        -: 1184:int
        -: 1185:bus_connection_get_n_match_rules (DBusConnection *connection)
function bus_connection_get_n_match_rules called 3328 returned 100% blocks executed 100%
     3328: 1186:{
        -: 1187:  BusConnectionData *d;
        -: 1188:
     3328: 1189:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     3328: 1190:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1191:  
     3328: 1192:  return d->n_match_rules;
        -: 1193:}
        -: 1194:
        -: 1195:void
        -: 1196:bus_connection_add_owned_service_link (DBusConnection *connection,
        -: 1197:                                       DBusList       *link)
function bus_connection_add_owned_service_link called 7032 returned 100% blocks executed 100%
     7032: 1198:{
        -: 1199:  BusConnectionData *d;
        -: 1200:
     7032: 1201:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     7032: 1202:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1203:
     7032: 1204:  _dbus_list_append_link (&d->services_owned, link);
call    0 returned 100%
        -: 1205:
     7032: 1206:  d->n_services_owned += 1;
     7032: 1207:}
        -: 1208:
        -: 1209:dbus_bool_t
        -: 1210:bus_connection_add_owned_service (DBusConnection *connection,
        -: 1211:                                  BusService     *service)
function bus_connection_add_owned_service called 7040 returned 100% blocks executed 100%
     7040: 1212:{
        -: 1213:  DBusList *link;
        -: 1214:
     7040: 1215:  link = _dbus_list_alloc_link (service);
call    0 returned 100%
        -: 1216:
     7040: 1217:  if (link == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        8: 1218:    return FALSE;
        -: 1219:
     7032: 1220:  bus_connection_add_owned_service_link (connection, link);
call    0 returned 100%
        -: 1221:
     7032: 1222:  return TRUE;
        -: 1223:}
        -: 1224:
        -: 1225:void
        -: 1226:bus_connection_remove_owned_service (DBusConnection *connection,
        -: 1227:                                     BusService     *service)
function bus_connection_remove_owned_service called 7032 returned 100% blocks executed 100%
     7032: 1228:{
        -: 1229:  BusConnectionData *d;
        -: 1230:
     7032: 1231:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     7032: 1232:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1233:
     7032: 1234:  _dbus_list_remove_last (&d->services_owned, service);
call    0 returned 100%
        -: 1235:
     7032: 1236:  d->n_services_owned -= 1;
     7032: 1237:  _dbus_assert (d->n_services_owned >= 0);
call    0 returned 100%
     7032: 1238:}
        -: 1239:
        -: 1240:int
        -: 1241:bus_connection_get_n_services_owned (DBusConnection *connection)
function bus_connection_get_n_services_owned called 1950 returned 100% blocks executed 100%
     1950: 1242:{
        -: 1243:  BusConnectionData *d;
        -: 1244:
     1950: 1245:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     1950: 1246:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1247:  
     1950: 1248:  return d->n_services_owned;
        -: 1249:}
        -: 1250:
        -: 1251:dbus_bool_t
        -: 1252:bus_connection_complete (DBusConnection   *connection,
        -: 1253:			 const DBusString *name,
        -: 1254:                         DBusError        *error)
function bus_connection_complete called 6152 returned 100% blocks executed 90%
     6152: 1255:{
        -: 1256:  BusConnectionData *d;
        -: 1257:  unsigned long uid;
        -: 1258:  
     6152: 1259:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     6152: 1260:  _dbus_assert (d != NULL);
call    0 returned 100%
     6152: 1261:  _dbus_assert (d->name == NULL);
call    0 returned 100%
     6152: 1262:  _dbus_assert (d->policy == NULL);
call    0 returned 100%
        -: 1263:
     6152: 1264:  _dbus_assert (!bus_connection_is_active (connection));
call    0 returned 100%
call    1 returned 100%
        -: 1265:  
     6152: 1266:  if (!_dbus_string_copy_data (name, &d->name))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1267:    {
        7: 1268:      BUS_SET_OOM (error);
call    0 returned 100%
        7: 1269:      return FALSE;
        -: 1270:    }
        -: 1271:
     6145: 1272:  _dbus_assert (d->name != NULL);
call    0 returned 100%
        -: 1273:  
     6145: 1274:  _dbus_verbose ("Name %s assigned to %p\n", d->name, connection);
call    0 returned 100%
        -: 1275:
     6145: 1276:  d->policy = bus_context_create_client_policy (d->connections->context,
call    0 returned 100%
        -: 1277:                                                connection,
        -: 1278:                                                error);
        -: 1279:
        -: 1280:  /* we may have a NULL policy on OOM or error getting list of
        -: 1281:   * groups for a user. In the latter case we don't handle it so
        -: 1282:   * well currently, as it will just keep failing over and over.
        -: 1283:   */
        -: 1284:
     6145: 1285:  if (d->policy == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1286:    {
       49: 1287:      _dbus_verbose ("Failed to create security policy for connection %p\n",
call    0 returned 100%
        -: 1288:                     connection);
       49: 1289:      _DBUS_ASSERT_ERROR_IS_SET (error);
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
call    5 returned 100%
       49: 1290:      dbus_free (d->name);
call    0 returned 100%
       49: 1291:      d->name = NULL;
       49: 1292:      return FALSE;
        -: 1293:    }
        -: 1294:  
     6096: 1295:  if (dbus_connection_get_unix_user (connection, &uid))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -: 1296:    {
     6096: 1297:      if (!adjust_connections_for_uid (d->connections,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1298:                                       uid, 1))
        -: 1299:        {
    #####: 1300:          BUS_SET_OOM (error);
call    0 never executed
    #####: 1301:          dbus_free (d->name);
call    0 never executed
    #####: 1302:          d->name = NULL;
    #####: 1303:          return FALSE;
        -: 1304:        }
        -: 1305:    }
        -: 1306:  
        -: 1307:  /* Now the connection is active, move it between lists */
     6096: 1308:  _dbus_list_unlink (&d->connections->incomplete,
call    0 returned 100%
        -: 1309:                     d->link_in_connection_list);
     6096: 1310:  d->connections->n_incomplete -= 1;
     6096: 1311:  _dbus_list_append_link (&d->connections->completed,
call    0 returned 100%
        -: 1312:                          d->link_in_connection_list);
     6096: 1313:  d->connections->n_completed += 1;
        -: 1314:
     6096: 1315:  _dbus_assert (d->connections->n_incomplete >= 0);
call    0 returned 100%
     6096: 1316:  _dbus_assert (d->connections->n_completed > 0);
call    0 returned 100%
        -: 1317:
        -: 1318:  /* See if we can remove the timeout */
     6096: 1319:  bus_connections_expire_incomplete (d->connections);
call    0 returned 100%
        -: 1320:
     6096: 1321:  _dbus_assert (bus_connection_is_active (connection));
call    0 returned 100%
call    1 returned 100%
        -: 1322:  
     6096: 1323:  return TRUE;
        -: 1324:}
        -: 1325:
        -: 1326:const char *
        -: 1327:bus_connection_get_name (DBusConnection *connection)
function bus_connection_get_name called 84912 returned 100% blocks executed 100%
    84912: 1328:{
        -: 1329:  BusConnectionData *d;
        -: 1330:  
    84912: 1331:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
    84912: 1332:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1333:  
    84912: 1334:  return d->name;
        -: 1335:}
        -: 1336:
        -: 1337:/**
        -: 1338: * Check whether completing the passed-in connection would
        -: 1339: * exceed limits, and if so set error and return #FALSE
        -: 1340: */
        -: 1341:dbus_bool_t
        -: 1342:bus_connections_check_limits (BusConnections  *connections,
        -: 1343:                              DBusConnection  *requesting_completion,
        -: 1344:                              DBusError       *error)
function bus_connections_check_limits called 6184 returned 100% blocks executed 75%
     6184: 1345:{
        -: 1346:  BusConnectionData *d;
        -: 1347:  unsigned long uid;
        -: 1348:  
     6184: 1349:  d = BUS_CONNECTION_DATA (requesting_completion);
call    0 returned 100%
     6184: 1350:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1351:
     6184: 1352:  _dbus_assert (d->name == NULL);
call    0 returned 100%
        -: 1353:
     6184: 1354:  if (connections->n_completed >=
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1355:      bus_context_get_max_completed_connections (connections->context))
        -: 1356:    {
    #####: 1357:      dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
call    0 never executed
        -: 1358:                      "The maximum number of active connections has been reached");
    #####: 1359:      return FALSE;
        -: 1360:    }
        -: 1361:  
     6184: 1362:  if (dbus_connection_get_unix_user (requesting_completion, &uid))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -: 1363:    {
     6184: 1364:      if (get_connections_for_uid (connections, uid) >=
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -: 1365:          bus_context_get_max_connections_per_user (connections->context))
        -: 1366:        {
    #####: 1367:          dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
call    0 never executed
        -: 1368:                          "The maximum number of active connections for UID %lu has been reached",
        -: 1369:                          uid);
    #####: 1370:          return FALSE;
        -: 1371:        }
        -: 1372:    }
        -: 1373:  
     6184: 1374:  return TRUE;
        -: 1375:}
        -: 1376:
        -: 1377:static void
        -: 1378:bus_pending_reply_free (BusPendingReply *pending)
function bus_pending_reply_free called 1577 returned 100% blocks executed 100%
     1577: 1379:{
     1577: 1380:  _dbus_verbose ("Freeing pending reply %p, replier %p receiver %p serial %u\n",
call    0 returned 100%
        -: 1381:                 pending,
        -: 1382:                 pending->will_send_reply,
        -: 1383:                 pending->will_get_reply,
        -: 1384:                 pending->reply_serial);
        -: 1385:
     1577: 1386:  dbus_free (pending);
call    0 returned 100%
     1577: 1387:}
        -: 1388:
        -: 1389:static dbus_bool_t
        -: 1390:bus_pending_reply_send_no_reply (BusConnections  *connections,
        -: 1391:                                 BusTransaction  *transaction,
        -: 1392:                                 BusPendingReply *pending)
function bus_pending_reply_send_no_reply called 1560 returned 100% blocks executed 86%
     1560: 1393:{
        -: 1394:  DBusMessage *message;
        -: 1395:  DBusMessageIter iter;
        -: 1396:  dbus_bool_t retval;
        -: 1397:  const char *errmsg;
        -: 1398:
     1560: 1399:  retval = FALSE;
        -: 1400:  
     1560: 1401:  message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR);
call    0 returned 100%
     1560: 1402:  if (message == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1403:    return FALSE;
        -: 1404:  
     1560: 1405:  dbus_message_set_no_reply (message, TRUE);
call    0 returned 100%
        -: 1406:  
     1560: 1407:  if (!dbus_message_set_reply_serial (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1408:                                      pending->reply_serial))
    #####: 1409:    goto out;
        -: 1410:
     1560: 1411:  if (!dbus_message_set_error_name (message,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1412:                                    DBUS_ERROR_NO_REPLY))
    #####: 1413:    goto out;
        -: 1414:
     1560: 1415:  errmsg = "Message did not receive a reply (timeout by message bus)";
     1560: 1416:  dbus_message_iter_init_append (message, &iter);
call    0 returned 100%
     1560: 1417:  if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &errmsg))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        8: 1418:    goto out;
        -: 1419:    
     1552: 1420:  if (!bus_transaction_send_from_driver (transaction, pending->will_get_reply,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1421:                                         message))
       14: 1422:    goto out;
        -: 1423:
     1538: 1424:  retval = TRUE;
        -: 1425:
     1560: 1426: out:
     1560: 1427:  dbus_message_unref (message);
call    0 returned 100%
     1560: 1428:  return retval;
        -: 1429:}
        -: 1430:
        -: 1431:static dbus_bool_t
        -: 1432:bus_pending_reply_expired (BusExpireList *list,
        -: 1433:                           DBusList      *link,
        -: 1434:                           void          *data)
function bus_pending_reply_expired called 1590 returned 100% blocks executed 100%
     1590: 1435:{
     1590: 1436:  BusPendingReply *pending = link->data;
     1590: 1437:  BusConnections *connections = data;
        -: 1438:  BusTransaction *transaction;
        -: 1439:  
        -: 1440:  /* No reply is forthcoming. So nuke it if we can. If not,
        -: 1441:   * leave it in the list to try expiring again later when we
        -: 1442:   * get more memory.
        -: 1443:   */
        -: 1444:
     1590: 1445:  _dbus_verbose ("Expiring pending reply %p, replier %p receiver %p serial %u\n",
call    0 returned 100%
        -: 1446:                 pending,
        -: 1447:                 pending->will_send_reply,
        -: 1448:                 pending->will_get_reply,
        -: 1449:                 pending->reply_serial);
        -: 1450:  
     1590: 1451:  transaction = bus_transaction_new (connections->context);
call    0 returned 100%
     1590: 1452:  if (transaction == NULL)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
       30: 1453:    return FALSE;
        -: 1454:  
     1560: 1455:  if (!bus_pending_reply_send_no_reply (connections,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1456:                                        transaction,
        -: 1457:                                        pending))
        -: 1458:    {
       22: 1459:      bus_transaction_cancel_and_free (transaction);
call    0 returned 100%
       22: 1460:      return FALSE;
        -: 1461:    }
        -: 1462:  
     1538: 1463:  _dbus_list_remove_link (&connections->pending_replies->items,
call    0 returned 100%
        -: 1464:                          link);
     1538: 1465:  bus_pending_reply_free (pending);
call    0 returned 100%
     1538: 1466:  bus_transaction_execute_and_free (transaction);
call    0 returned 100%
        -: 1467:
     1538: 1468:  return TRUE;
        -: 1469:}
        -: 1470:
        -: 1471:static void
        -: 1472:bus_connection_drop_pending_replies (BusConnections  *connections,
        -: 1473:                                     DBusConnection  *connection)
function bus_connection_drop_pending_replies called 7811 returned 100% blocks executed 75%
     7811: 1474:{
        -: 1475:  /* The DBusConnection is almost 100% finalized here, so you can't
        -: 1476:   * do anything with it except check for pointer equality
        -: 1477:   */
        -: 1478:  DBusList *link;
        -: 1479:
     7811: 1480:  _dbus_verbose ("Dropping pending replies that involve connection %p\n",
call    0 returned 100%
        -: 1481:                 connection);
        -: 1482:  
     7811: 1483:  link = _dbus_list_get_first_link (&connections->pending_replies->items);
call    0 returned 100%
    17160: 1484:  while (link != NULL)
branch  0 taken 16%
branch  1 taken 84% (fallthrough)
        -: 1485:    {
        -: 1486:      DBusList *next;
        -: 1487:      BusPendingReply *pending;
        -: 1488:
     1538: 1489:      next = _dbus_list_get_next_link (&connections->pending_replies->items,
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1490:                                       link);
     1538: 1491:      pending = link->data;
        -: 1492:
     1538: 1493:      if (pending->will_get_reply == connection)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1494:        {
        -: 1495:          /* We don't need to track this pending reply anymore */
        -: 1496:
    #####: 1497:          _dbus_verbose ("Dropping pending reply %p, replier %p receiver %p serial %u\n",
call    0 never executed
        -: 1498:                         pending,
        -: 1499:                         pending->will_send_reply,
        -: 1500:                         pending->will_get_reply,
        -: 1501:                         pending->reply_serial);
        -: 1502:          
    #####: 1503:          _dbus_list_remove_link (&connections->pending_replies->items,
call    0 never executed
        -: 1504:                                  link);
    #####: 1505:          bus_pending_reply_free (pending);
call    0 never executed
        -: 1506:        }
     1538: 1507:      else if (pending->will_send_reply == connection)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 1508:        {
        -: 1509:          /* The reply isn't going to be sent, so set things
        -: 1510:           * up so it will be expired right away
        -: 1511:           */
     1538: 1512:          _dbus_verbose ("Will expire pending reply %p, replier %p receiver %p serial %u\n",
call    0 returned 100%
        -: 1513:                         pending,
        -: 1514:                         pending->will_send_reply,
        -: 1515:                         pending->will_get_reply,
        -: 1516:                         pending->reply_serial);
        -: 1517:          
     1538: 1518:          pending->will_send_reply = NULL;
     1538: 1519:          pending->expire_item.added_tv_sec = 0;
     1538: 1520:          pending->expire_item.added_tv_usec = 0;
        -: 1521:
     1538: 1522:          bus_expire_timeout_set_interval (connections->pending_replies->timeout,
call    0 returned 100%
        -: 1523:                                           0);
        -: 1524:        }
        -: 1525:      
     1538: 1526:      link = next;
        -: 1527:    }
     7811: 1528:}
        -: 1529:
        -: 1530:
        -: 1531:typedef struct
        -: 1532:{
        -: 1533:  BusPendingReply *pending;
        -: 1534:  BusConnections  *connections;
        -: 1535:} CancelPendingReplyData;
        -: 1536:
        -: 1537:static void
        -: 1538:cancel_pending_reply (void *data)
function cancel_pending_reply called 22 returned 100% blocks executed 83%
       22: 1539:{
       22: 1540:  CancelPendingReplyData *d = data;
        -: 1541:
       22: 1542:  _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
call    0 returned 100%
        -: 1543:  
       22: 1544:  if (!_dbus_list_remove (&d->connections->pending_replies->items,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1545:                          d->pending))
    #####: 1546:    _dbus_assert_not_reached ("pending reply did not exist to be cancelled");
call    0 never executed
        -: 1547:
       22: 1548:  bus_pending_reply_free (d->pending); /* since it's been cancelled */
call    0 returned 100%
       22: 1549:}
        -: 1550:
        -: 1551:static void
        -: 1552:cancel_pending_reply_data_free (void *data)
function cancel_pending_reply_data_free called 1564 returned 100% blocks executed 100%
     1564: 1553:{
     1564: 1554:  CancelPendingReplyData *d = data;
        -: 1555:
     1564: 1556:  _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
call    0 returned 100%
        -: 1557:  
        -: 1558:  /* d->pending should be either freed or still
        -: 1559:   * in the list of pending replies (owned by someone
        -: 1560:   * else)
        -: 1561:   */
        -: 1562:  
     1564: 1563:  dbus_free (d);
call    0 returned 100%
     1564: 1564:}
        -: 1565:
        -: 1566:/*
        -: 1567: * Record that a reply is allowed; return TRUE on success.
        -: 1568: */
        -: 1569:dbus_bool_t
        -: 1570:bus_connections_expect_reply (BusConnections  *connections,
        -: 1571:                              BusTransaction  *transaction,
        -: 1572:                              DBusConnection  *will_get_reply,
        -: 1573:                              DBusConnection  *will_send_reply,
        -: 1574:                              DBusMessage     *reply_to_this,
        -: 1575:                              DBusError       *error)
function bus_connections_expect_reply called 1579 returned 100% blocks executed 82%
     1579: 1576:{
        -: 1577:  BusPendingReply *pending;
        -: 1578:  dbus_uint32_t reply_serial;
        -: 1579:  DBusList *link;
        -: 1580:  CancelPendingReplyData *cprd;
        -: 1581:  int count;
        -: 1582:
     1579: 1583:  _dbus_assert (will_get_reply != NULL);
call    0 returned 100%
     1579: 1584:  _dbus_assert (will_send_reply != NULL);
call    0 returned 100%
     1579: 1585:  _dbus_assert (reply_to_this != NULL);
call    0 returned 100%
        -: 1586:  
     1579: 1587:  if (dbus_message_get_no_reply (reply_to_this))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1588:    return TRUE; /* we won't allow a reply, since client doesn't care for one. */
        -: 1589:  
     1579: 1590:  reply_serial = dbus_message_get_serial (reply_to_this);
call    0 returned 100%
        -: 1591:
     1579: 1592:  link = _dbus_list_get_first_link (&connections->pending_replies->items);
call    0 returned 100%
     1579: 1593:  count = 0;
     3159: 1594:  while (link != NULL)
branch  0 taken 1%
branch  1 taken 99% (fallthrough)
        -: 1595:    {
        1: 1596:      pending = link->data;
        -: 1597:
        1: 1598:      if (pending->reply_serial == reply_serial &&
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
branch  2 never executed
branch  3 never executed
branch  4 never executed
branch  5 never executed
        -: 1599:          pending->will_get_reply == will_get_reply &&
        -: 1600:          pending->will_send_reply == will_send_reply)
        -: 1601:        {
    #####: 1602:          dbus_set_error (error, DBUS_ERROR_ACCESS_DENIED,
call    0 never executed
        -: 1603:                          "Message has the same reply serial as a currently-outstanding existing method call");
    #####: 1604:          return FALSE;
        -: 1605:        }
        -: 1606:      
        1: 1607:      link = _dbus_list_get_next_link (&connections->pending_replies->items,
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1608:                                       link);
        1: 1609:      if (pending->will_get_reply == will_get_reply)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1610:        ++count;
        -: 1611:    }
        -: 1612:  
     1579: 1613:  if (count >=
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1614:      bus_context_get_max_replies_per_connection (connections->context))
        -: 1615:    {
    #####: 1616:      dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
call    0 never executed
        -: 1617:		      "The maximum number of pending replies per connection has been reached");
    #####: 1618:      return FALSE;
        -: 1619:    }
        -: 1620:
     1579: 1621:  pending = dbus_new0 (BusPendingReply, 1);
call    0 returned 100%
     1579: 1622:  if (pending == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1623:    {
        2: 1624:      BUS_SET_OOM (error);
call    0 returned 100%
        2: 1625:      return FALSE;
        -: 1626:    }
        -: 1627:
        -: 1628:#ifdef DBUS_ENABLE_VERBOSE_MODE
        -: 1629:  /* so we can see a not-yet-added pending reply */
     1577: 1630:  pending->expire_item.added_tv_sec = 1;
     1577: 1631:  pending->expire_item.added_tv_usec = 1;
        -: 1632:#endif
        -: 1633:
     1577: 1634:  pending->will_get_reply = will_get_reply;
     1577: 1635:  pending->will_send_reply = will_send_reply;
     1577: 1636:  pending->reply_serial = reply_serial;
        -: 1637:  
     1577: 1638:  cprd = dbus_new0 (CancelPendingReplyData, 1);
call    0 returned 100%
     1577: 1639:  if (cprd == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1640:    {
        4: 1641:      BUS_SET_OOM (error);
call    0 returned 100%
        4: 1642:      bus_pending_reply_free (pending);
call    0 returned 100%
        4: 1643:      return FALSE;
        -: 1644:    }
        -: 1645:  
     1573: 1646:  if (!_dbus_list_prepend (&connections->pending_replies->items,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1647:                           pending))
        -: 1648:    {
        4: 1649:      BUS_SET_OOM (error);
call    0 returned 100%
        4: 1650:      dbus_free (cprd);
call    0 returned 100%
        4: 1651:      bus_pending_reply_free (pending);
call    0 returned 100%
        4: 1652:      return FALSE;
        -: 1653:    }
        -: 1654:
     1569: 1655:  if (!bus_transaction_add_cancel_hook (transaction,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1656:                                        cancel_pending_reply,
        -: 1657:                                        cprd,
        -: 1658:                                        cancel_pending_reply_data_free))
        -: 1659:    {
        5: 1660:      BUS_SET_OOM (error);
call    0 returned 100%
        5: 1661:      _dbus_list_remove (&connections->pending_replies->items, pending);
call    0 returned 100%
        5: 1662:      dbus_free (cprd);
call    0 returned 100%
        5: 1663:      bus_pending_reply_free (pending);
call    0 returned 100%
        5: 1664:      return FALSE;
        -: 1665:    }
        -: 1666:                                        
     1564: 1667:  cprd->pending = pending;
     1564: 1668:  cprd->connections = connections;
        -: 1669:  
     1564: 1670:  _dbus_get_current_time (&pending->expire_item.added_tv_sec,
call    0 returned 100%
        -: 1671:                          &pending->expire_item.added_tv_usec);
        -: 1672:
     1564: 1673:  _dbus_verbose ("Added pending reply %p, replier %p receiver %p serial %u\n",
call    0 returned 100%
        -: 1674:                 pending,
        -: 1675:                 pending->will_send_reply,
        -: 1676:                 pending->will_get_reply,
        -: 1677:                 pending->reply_serial);
        -: 1678:  
     1564: 1679:  return TRUE;
        -: 1680:}
        -: 1681:
        -: 1682:typedef struct
        -: 1683:{
        -: 1684:  DBusList        *link;
        -: 1685:  BusConnections  *connections;
        -: 1686:} CheckPendingReplyData;
        -: 1687:
        -: 1688:static void
        -: 1689:cancel_check_pending_reply (void *data)
function cancel_check_pending_reply called 0 returned 0% blocks executed 0%
    #####: 1690:{
    #####: 1691:  CheckPendingReplyData *d = data;
        -: 1692:
    #####: 1693:  _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
call    0 never executed
        -: 1694:  
    #####: 1695:  _dbus_list_prepend_link (&d->connections->pending_replies->items,
call    0 never executed
        -: 1696:                           d->link);
    #####: 1697:  d->link = NULL;
    #####: 1698:}
        -: 1699:
        -: 1700:static void
        -: 1701:check_pending_reply_data_free (void *data)
function check_pending_reply_data_free called 4 returned 100% blocks executed 100%
        4: 1702:{
        4: 1703:  CheckPendingReplyData *d = data;
        -: 1704:
        4: 1705:  _dbus_verbose ("%s: d = %p\n", _DBUS_FUNCTION_NAME, d);
call    0 returned 100%
        -: 1706:  
        4: 1707:  if (d->link != NULL)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 1708:    {
        4: 1709:      BusPendingReply *pending = d->link->data;
        -: 1710:      
        4: 1711:      _dbus_assert (_dbus_list_find_last (&d->connections->pending_replies->items,
call    0 returned 100%
call    1 returned 100%
        -: 1712:                                          pending) == NULL);
        -: 1713:      
        4: 1714:      bus_pending_reply_free (pending);
call    0 returned 100%
        4: 1715:      _dbus_list_free_link (d->link);
call    0 returned 100%
        -: 1716:    }
        -: 1717:  
        4: 1718:  dbus_free (d);
call    0 returned 100%
        4: 1719:}
        -: 1720:
        -: 1721:/*
        -: 1722: * Check whether a reply is allowed, remove BusPendingReply
        -: 1723: * if so, return TRUE if so.
        -: 1724: */
        -: 1725:dbus_bool_t
        -: 1726:bus_connections_check_reply (BusConnections *connections,
        -: 1727:                             BusTransaction *transaction,
        -: 1728:                             DBusConnection *sending_reply,
        -: 1729:                             DBusConnection *receiving_reply,
        -: 1730:                             DBusMessage    *reply,
        -: 1731:                             DBusError      *error)
function bus_connections_check_reply called 4 returned 100% blocks executed 66%
        4: 1732:{
        -: 1733:  CheckPendingReplyData *cprd;
        -: 1734:  DBusList *link;
        -: 1735:  dbus_uint32_t reply_serial;
        -: 1736:  
        4: 1737:  _dbus_assert (sending_reply != NULL);
call    0 returned 100%
        4: 1738:  _dbus_assert (receiving_reply != NULL);
call    0 returned 100%
        -: 1739:
        4: 1740:  reply_serial = dbus_message_get_reply_serial (reply);
call    0 returned 100%
        -: 1741:
        4: 1742:  link = _dbus_list_get_first_link (&connections->pending_replies->items);
call    0 returned 100%
        8: 1743:  while (link != NULL)
branch  0 taken 100%
branch  1 taken 0% (fallthrough)
        -: 1744:    {
        4: 1745:      BusPendingReply *pending = link->data;
        -: 1746:
        4: 1747:      if (pending->reply_serial == reply_serial &&
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
branch  4 taken 100% (fallthrough)
branch  5 taken 0%
        -: 1748:          pending->will_get_reply == receiving_reply &&
        -: 1749:          pending->will_send_reply == sending_reply)
        -: 1750:        {
        4: 1751:          _dbus_verbose ("Found pending reply with serial %u\n", reply_serial);
call    0 returned 100%
        4: 1752:          break;
        -: 1753:        }
        -: 1754:      
    #####: 1755:      link = _dbus_list_get_next_link (&connections->pending_replies->items,
branch  0 never executed
branch  1 never executed
        -: 1756:                                       link);
        -: 1757:    }
        -: 1758:
        4: 1759:  if (link == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1760:    {
    #####: 1761:      _dbus_verbose ("No pending reply expected\n");
call    0 never executed
        -: 1762:
    #####: 1763:      return FALSE;
        -: 1764:    }
        -: 1765:
        4: 1766:  cprd = dbus_new0 (CheckPendingReplyData, 1);
call    0 returned 100%
        4: 1767:  if (cprd == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1768:    {
    #####: 1769:      BUS_SET_OOM (error);
call    0 never executed
    #####: 1770:      return FALSE;
        -: 1771:    }
        -: 1772:  
        4: 1773:  if (!bus_transaction_add_cancel_hook (transaction,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1774:                                        cancel_check_pending_reply,
        -: 1775:                                        cprd,
        -: 1776:                                        check_pending_reply_data_free))
        -: 1777:    {
    #####: 1778:      BUS_SET_OOM (error);
call    0 never executed
    #####: 1779:      dbus_free (cprd);
call    0 never executed
    #####: 1780:      return FALSE;
        -: 1781:    }
        -: 1782:
        4: 1783:  cprd->link = link;
        4: 1784:  cprd->connections = connections;
        -: 1785:  
        4: 1786:  _dbus_list_unlink (&connections->pending_replies->items,
call    0 returned 100%
        -: 1787:                     link);
        -: 1788:  
        4: 1789:  _dbus_assert (_dbus_list_find_last (&connections->pending_replies->items,
call    0 returned 100%
call    1 returned 100%
        -: 1790:                                      link->data) == NULL);
        -: 1791:
        4: 1792:  return TRUE;
        -: 1793:}
        -: 1794:
        -: 1795:/*
        -: 1796: * Transactions
        -: 1797: *
        -: 1798: * Note that this is fairly fragile; in particular, don't try to use
        -: 1799: * one transaction across any main loop iterations.
        -: 1800: */
        -: 1801:
        -: 1802:typedef struct
        -: 1803:{
        -: 1804:  BusTransaction *transaction;
        -: 1805:  DBusMessage    *message;
        -: 1806:  DBusPreallocatedSend *preallocated;
        -: 1807:} MessageToSend;
        -: 1808:
        -: 1809:typedef struct
        -: 1810:{
        -: 1811:  BusTransactionCancelFunction cancel_function;
        -: 1812:  DBusFreeFunction free_data_function;
        -: 1813:  void *data;
        -: 1814:} CancelHook;
        -: 1815:
        -: 1816:struct BusTransaction
        -: 1817:{
        -: 1818:  DBusList *connections;
        -: 1819:  BusContext *context;
        -: 1820:  DBusList *cancel_hooks;
        -: 1821:};
        -: 1822:
        -: 1823:static void
        -: 1824:message_to_send_free (DBusConnection *connection,
        -: 1825:                      MessageToSend  *to_send)
function message_to_send_free called 58761 returned 100% blocks executed 100%
    58761: 1826:{
    58761: 1827:  if (to_send->message)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
    58761: 1828:    dbus_message_unref (to_send->message);
call    0 returned 100%
        -: 1829:
    58761: 1830:  if (to_send->preallocated)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
     3509: 1831:    dbus_connection_free_preallocated_send (connection, to_send->preallocated);
call    0 returned 100%
        -: 1832:
    58761: 1833:  dbus_free (to_send);
call    0 returned 100%
    58761: 1834:}
        -: 1835:
        -: 1836:static void
        -: 1837:cancel_hook_cancel (void *element,
        -: 1838:                    void *data)
function cancel_hook_cancel called 1757 returned 100% blocks executed 100%
     1757: 1839:{
     1757: 1840:  CancelHook *ch = element;
        -: 1841:
     1757: 1842:  _dbus_verbose ("Running transaction cancel hook\n");
call    0 returned 100%
        -: 1843:  
     1757: 1844:  if (ch->cancel_function)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
     1757: 1845:    (* ch->cancel_function) (ch->data);  
call    0 returned 100%
     1757: 1846:}
        -: 1847:
        -: 1848:static void
        -: 1849:cancel_hook_free (void *element,
        -: 1850:                  void *data)
function cancel_hook_free called 21517 returned 100% blocks executed 100%
    21517: 1851:{
    21517: 1852:  CancelHook *ch = element;
        -: 1853:
    21517: 1854:  if (ch->free_data_function)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
    21517: 1855:    (* ch->free_data_function) (ch->data);
call    0 returned 100%
        -: 1856:
    21517: 1857:  dbus_free (ch);
call    0 returned 100%
    21517: 1858:}
        -: 1859:
        -: 1860:static void
        -: 1861:free_cancel_hooks (BusTransaction *transaction)
function free_cancel_hooks called 28644 returned 100% blocks executed 100%
    28644: 1862:{
    28644: 1863:  _dbus_list_foreach (&transaction->cancel_hooks,
call    0 returned 100%
        -: 1864:                      cancel_hook_free, NULL);
        -: 1865:  
    28644: 1866:  _dbus_list_clear (&transaction->cancel_hooks);
call    0 returned 100%
    28644: 1867:}
        -: 1868:
        -: 1869:BusTransaction*
        -: 1870:bus_transaction_new (BusContext *context)
function bus_transaction_new called 29367 returned 100% blocks executed 100%
    29367: 1871:{
        -: 1872:  BusTransaction *transaction;
        -: 1873:
    29367: 1874:  transaction = dbus_new0 (BusTransaction, 1);
call    0 returned 100%
    29367: 1875:  if (transaction == NULL)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
      723: 1876:    return NULL;
        -: 1877:
    28644: 1878:  transaction->context = context;
        -: 1879:  
    28644: 1880:  return transaction;
        -: 1881:}
        -: 1882:
        -: 1883:BusContext*
        -: 1884:bus_transaction_get_context (BusTransaction  *transaction)
function bus_transaction_get_context called 62669 returned 100% blocks executed 100%
    62669: 1885:{
    62669: 1886:  return transaction->context;
        -: 1887:}
        -: 1888:
        -: 1889:BusConnections*
        -: 1890:bus_transaction_get_connections (BusTransaction  *transaction)
function bus_transaction_get_connections called 29069 returned 100% blocks executed 100%
    29069: 1891:{
    29069: 1892:  return bus_context_get_connections (transaction->context);
call    0 returned 100%
        -: 1893:}
        -: 1894:
        -: 1895:dbus_bool_t
        -: 1896:bus_transaction_send_from_driver (BusTransaction *transaction,
        -: 1897:                                  DBusConnection *connection,
        -: 1898:                                  DBusMessage    *message)
function bus_transaction_send_from_driver called 30905 returned 100% blocks executed 97%
    30905: 1899:{
        -: 1900:  /* We have to set the sender to the driver, and have
        -: 1901:   * to check security policy since it was not done in
        -: 1902:   * dispatch.c
        -: 1903:   */
    30905: 1904:  _dbus_verbose ("Sending %s %s %s from driver\n",
call    0 returned 100%
branch  1 taken 11% (fallthrough)
branch  2 taken 89%
call    3 returned 100%
call    4 returned 100%
branch  5 taken 47% (fallthrough)
branch  6 taken 53%
call    7 returned 100%
call    8 returned 100%
branch  9 taken 47% (fallthrough)
branch 10 taken 53%
call   11 returned 100%
call   12 returned 100%
        -: 1905:                 dbus_message_get_interface (message) ?
        -: 1906:                 dbus_message_get_interface (message) : "(no interface)",
        -: 1907:                 dbus_message_get_member (message) ?
        -: 1908:                 dbus_message_get_member (message) : "(no member)",
        -: 1909:                 dbus_message_get_error_name (message) ?
        -: 1910:                 dbus_message_get_error_name (message) : "(no error name)");
        -: 1911:                 
    30905: 1912:  if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
       40: 1913:    return FALSE;
        -: 1914:
    30865: 1915:  if (bus_connection_is_active (connection))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -: 1916:    {
    30865: 1917:      if (!dbus_message_set_destination (message,
call    0 returned 100%
call    1 returned 100%
branch  2 taken 2% (fallthrough)
branch  3 taken 98%
        -: 1918:                                         bus_connection_get_name (connection)))
      593: 1919:        return FALSE;
        -: 1920:    }
        -: 1921:  
        -: 1922:  /* bus driver never wants a reply */
    30272: 1923:  dbus_message_set_no_reply (message, TRUE);
call    0 returned 100%
        -: 1924:  
        -: 1925:  /* If security policy doesn't allow the message, we silently
        -: 1926:   * eat it; the driver doesn't care about getting a reply.
        -: 1927:   */
    30272: 1928:  if (!bus_context_check_security_policy (bus_transaction_get_context (transaction),
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -: 1929:                                          transaction,
        -: 1930:                                          NULL, connection, connection, message, NULL))
    #####: 1931:    return TRUE;
        -: 1932:
    30272: 1933:  return bus_transaction_send (transaction, connection, message);
call    0 returned 100%
        -: 1934:}
        -: 1935:
        -: 1936:dbus_bool_t
        -: 1937:bus_transaction_send (BusTransaction *transaction,
        -: 1938:                      DBusConnection *connection,
        -: 1939:                      DBusMessage    *message)
function bus_transaction_send called 66250 returned 100% blocks executed 99%
    66250: 1940:{
        -: 1941:  MessageToSend *to_send;
        -: 1942:  BusConnectionData *d;
        -: 1943:  DBusList *link;
        -: 1944:
    66250: 1945:  _dbus_verbose ("  trying to add %s interface=%s member=%s error=%s to transaction%s\n",
call    0 returned 100%
branch  1 taken 89% (fallthrough)
branch  2 taken 11%
call    3 returned 100%
branch  4 taken 5% (fallthrough)
branch  5 taken 95%
call    6 returned 100%
call    7 returned 100%
branch  8 taken 76% (fallthrough)
branch  9 taken 24%
call   10 returned 100%
call   11 returned 100%
branch 12 taken 76% (fallthrough)
branch 13 taken 24%
call   14 returned 100%
call   15 returned 100%
branch 16 taken 95% (fallthrough)
branch 17 taken 5%
call   18 returned 100%
branch 19 taken 20% (fallthrough)
branch 20 taken 80%
call   21 returned 100%
        -: 1946:                 dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_ERROR ? "error" :
        -: 1947:                 dbus_message_get_reply_serial (message) != 0 ? "reply" :
        -: 1948:                 "message",
        -: 1949:                 dbus_message_get_interface (message) ?
        -: 1950:                 dbus_message_get_interface (message) : "(unset)",
        -: 1951:                 dbus_message_get_member (message) ?
        -: 1952:                 dbus_message_get_member (message) : "(unset)",
        -: 1953:                 dbus_message_get_error_name (message) ?
        -: 1954:                 dbus_message_get_error_name (message) : "(unset)",
        -: 1955:                 dbus_connection_get_is_connected (connection) ?
        -: 1956:                 "" : " (disconnected)");
        -: 1957:
    66250: 1958:  _dbus_assert (dbus_message_get_sender (message) != NULL);
call    0 returned 100%
call    1 returned 100%
        -: 1959:  
    66250: 1960:  if (!dbus_connection_get_is_connected (connection))
call    0 returned 100%
branch  1 taken 11% (fallthrough)
branch  2 taken 89%
     7220: 1961:    return TRUE; /* silently ignore disconnected connections */
        -: 1962:  
    59030: 1963:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
    59030: 1964:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 1965:  
    59030: 1966:  to_send = dbus_new (MessageToSend, 1);
call    0 returned 100%
    59030: 1967:  if (to_send == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1968:    {
      103: 1969:      return FALSE;
        -: 1970:    }
        -: 1971:
    58927: 1972:  to_send->preallocated = dbus_connection_preallocate_send (connection);
call    0 returned 100%
    58927: 1973:  if (to_send->preallocated == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1974:    {
      166: 1975:      dbus_free (to_send);
call    0 returned 100%
      166: 1976:      return FALSE;
        -: 1977:    }  
        -: 1978:  
    58761: 1979:  dbus_message_ref (message);
call    0 returned 100%
    58761: 1980:  to_send->message = message;
    58761: 1981:  to_send->transaction = transaction;
        -: 1982:
    58761: 1983:  _dbus_verbose ("about to prepend message\n");
call    0 returned 100%
        -: 1984:  
    58761: 1985:  if (!_dbus_list_prepend (&d->transaction_messages, to_send))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1986:    {
      100: 1987:      message_to_send_free (connection, to_send);
call    0 returned 100%
      100: 1988:      return FALSE;
        -: 1989:    }
        -: 1990:
    58661: 1991:  _dbus_verbose ("prepended message\n");
call    0 returned 100%
        -: 1992:  
        -: 1993:  /* See if we already had this connection in the list
        -: 1994:   * for this transaction. If we have a pending message,
        -: 1995:   * then we should already be in transaction->connections
        -: 1996:   */
    58661: 1997:  link = _dbus_list_get_first_link (&d->transaction_messages);
call    0 returned 100%
    58661: 1998:  _dbus_assert (link->data == to_send);
call    0 returned 100%
    58661: 1999:  link = _dbus_list_get_next_link (&d->transaction_messages, link);
branch  0 taken 15% (fallthrough)
branch  1 taken 85%
   117322: 2000:  while (link != NULL)
branch  0 taken 15%
branch  1 taken 85% (fallthrough)
        -: 2001:    {
     8712: 2002:      MessageToSend *m = link->data;
     8712: 2003:      DBusList *next = _dbus_list_get_next_link (&d->transaction_messages, link);
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 2004:      
     8712: 2005:      if (m->transaction == transaction)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
     8712: 2006:        break;
        -: 2007:        
    #####: 2008:      link = next;
        -: 2009:    }
        -: 2010:
    58661: 2011:  if (link == NULL)
branch  0 taken 85% (fallthrough)
branch  1 taken 15%
        -: 2012:    {
    49949: 2013:      if (!_dbus_list_prepend (&transaction->connections, connection))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 2014:        {
      102: 2015:          _dbus_list_remove (&d->transaction_messages, to_send);
call    0 returned 100%
      102: 2016:          message_to_send_free (connection, to_send);
call    0 returned 100%
      102: 2017:          return FALSE;
        -: 2018:        }
        -: 2019:    }
        -: 2020:
    58559: 2021:  return TRUE;
        -: 2022:}
        -: 2023:
        -: 2024:static void
        -: 2025:connection_cancel_transaction (DBusConnection *connection,
        -: 2026:                               BusTransaction *transaction)
function connection_cancel_transaction called 2974 returned 100% blocks executed 100%
     2974: 2027:{
        -: 2028:  DBusList *link;
        -: 2029:  BusConnectionData *d;
        -: 2030:  
     2974: 2031:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     2974: 2032:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 2033:  
     2974: 2034:  link = _dbus_list_get_first_link (&d->transaction_messages);
call    0 returned 100%
     9255: 2035:  while (link != NULL)
branch  0 taken 53%
branch  1 taken 47% (fallthrough)
        -: 2036:    {
     3307: 2037:      MessageToSend *m = link->data;
     3307: 2038:      DBusList *next = _dbus_list_get_next_link (&d->transaction_messages, link);
branch  0 taken 10% (fallthrough)
branch  1 taken 90%
        -: 2039:      
     3307: 2040:      if (m->transaction == transaction)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 2041:        {
     3307: 2042:          _dbus_list_remove_link (&d->transaction_messages,
call    0 returned 100%
        -: 2043:                                  link);
        -: 2044:          
     3307: 2045:          message_to_send_free (connection, m);
call    0 returned 100%
        -: 2046:        }
        -: 2047:        
     3307: 2048:      link = next;
        -: 2049:    }
     2974: 2050:}
        -: 2051:
        -: 2052:void
        -: 2053:bus_transaction_cancel_and_free (BusTransaction *transaction)
function bus_transaction_cancel_and_free called 4036 returned 100% blocks executed 100%
     4036: 2054:{
        -: 2055:  DBusConnection *connection;
        -: 2056:
     4036: 2057:  _dbus_verbose ("TRANSACTION: cancelled\n");
call    0 returned 100%
        -: 2058:  
    11046: 2059:  while ((connection = _dbus_list_pop_first (&transaction->connections)))
call    0 returned 100%
branch  1 taken 42%
branch  2 taken 58% (fallthrough)
     2974: 2060:    connection_cancel_transaction (connection, transaction);
call    0 returned 100%
        -: 2061:
     4036: 2062:  _dbus_assert (transaction->connections == NULL);
call    0 returned 100%
        -: 2063:
     4036: 2064:  _dbus_list_foreach (&transaction->cancel_hooks,
call    0 returned 100%
        -: 2065:                      cancel_hook_cancel, NULL);
        -: 2066:
     4036: 2067:  free_cancel_hooks (transaction);
call    0 returned 100%
        -: 2068:  
     4036: 2069:  dbus_free (transaction);
call    0 returned 100%
     4036: 2070:}
        -: 2071:
        -: 2072:static void
        -: 2073:connection_execute_transaction (DBusConnection *connection,
        -: 2074:                                BusTransaction *transaction)
function connection_execute_transaction called 46873 returned 100% blocks executed 100%
    46873: 2075:{
        -: 2076:  DBusList *link;
        -: 2077:  BusConnectionData *d;
        -: 2078:  
    46873: 2079:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
    46873: 2080:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 2081:
        -: 2082:  /* Send the queue in order (FIFO) */
    46873: 2083:  link = _dbus_list_get_last_link (&d->transaction_messages);
call    0 returned 100%
   148998: 2084:  while (link != NULL)
branch  0 taken 54%
branch  1 taken 46% (fallthrough)
        -: 2085:    {
    55252: 2086:      MessageToSend *m = link->data;
    55252: 2087:      DBusList *prev = _dbus_list_get_prev_link (&d->transaction_messages, link);
branch  0 taken 15% (fallthrough)
branch  1 taken 85%
        -: 2088:      
    55252: 2089:      if (m->transaction == transaction)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 2090:        {
    55252: 2091:          _dbus_list_remove_link (&d->transaction_messages,
call    0 returned 100%
        -: 2092:                                  link);
        -: 2093:
    55252: 2094:          _dbus_assert (dbus_message_get_sender (m->message) != NULL);
call    0 returned 100%
call    1 returned 100%
        -: 2095:          
    55252: 2096:          dbus_connection_send_preallocated (connection,
call    0 returned 100%
        -: 2097:                                             m->preallocated,
        -: 2098:                                             m->message,
        -: 2099:                                             NULL);
        -: 2100:
    55252: 2101:          m->preallocated = NULL; /* so we don't double-free it */
        -: 2102:          
    55252: 2103:          message_to_send_free (connection, m);
call    0 returned 100%
        -: 2104:        }
        -: 2105:        
    55252: 2106:      link = prev;
        -: 2107:    }
    46873: 2108:}
        -: 2109:
        -: 2110:void
        -: 2111:bus_transaction_execute_and_free (BusTransaction *transaction)
function bus_transaction_execute_and_free called 24608 returned 100% blocks executed 100%
    24608: 2112:{
        -: 2113:  /* For each connection in transaction->connections
        -: 2114:   * send the messages
        -: 2115:   */
        -: 2116:  DBusConnection *connection;
        -: 2117:
    24608: 2118:  _dbus_verbose ("TRANSACTION: executing\n");
call    0 returned 100%
        -: 2119:  
    96089: 2120:  while ((connection = _dbus_list_pop_first (&transaction->connections)))
call    0 returned 100%
branch  1 taken 66%
branch  2 taken 34% (fallthrough)
    46873: 2121:    connection_execute_transaction (connection, transaction);
call    0 returned 100%
        -: 2122:
    24608: 2123:  _dbus_assert (transaction->connections == NULL);
call    0 returned 100%
        -: 2124:
    24608: 2125:  free_cancel_hooks (transaction);
call    0 returned 100%
        -: 2126:  
    24608: 2127:  dbus_free (transaction);
call    0 returned 100%
    24608: 2128:}
        -: 2129:
        -: 2130:static void
        -: 2131:bus_connection_remove_transactions (DBusConnection *connection)
function bus_connection_remove_transactions called 7811 returned 100% blocks executed 67%
     7811: 2132:{
        -: 2133:  MessageToSend *to_send;
        -: 2134:  BusConnectionData *d;
        -: 2135:  
     7811: 2136:  d = BUS_CONNECTION_DATA (connection);
call    0 returned 100%
     7811: 2137:  _dbus_assert (d != NULL);
call    0 returned 100%
        -: 2138:  
    15622: 2139:  while ((to_send = _dbus_list_get_first (&d->transaction_messages)))
call    0 returned 100%
branch  1 taken 0%
branch  2 taken 100% (fallthrough)
        -: 2140:    {
        -: 2141:      /* only has an effect for the first MessageToSend listing this transaction */
    #####: 2142:      _dbus_list_remove (&to_send->transaction->connections,
call    0 never executed
        -: 2143:                         connection);
        -: 2144:
    #####: 2145:      _dbus_list_remove (&d->transaction_messages, to_send);
call    0 never executed
    #####: 2146:      message_to_send_free (connection, to_send);
call    0 never executed
        -: 2147:    }
     7811: 2148:}
        -: 2149:
        -: 2150:/**
        -: 2151: * Converts the DBusError to a message reply
        -: 2152: */
        -: 2153:dbus_bool_t
        -: 2154:bus_transaction_send_error_reply (BusTransaction  *transaction,
        -: 2155:                                  DBusConnection  *connection,
        -: 2156:                                  const DBusError *error,
        -: 2157:                                  DBusMessage     *in_reply_to)
function bus_transaction_send_error_reply called 2011 returned 100% blocks executed 94%
     2011: 2158:{
        -: 2159:  DBusMessage *reply;
        -: 2160:  
     2011: 2161:  _dbus_assert (error != NULL);
call    0 returned 100%
     2011: 2162:  _DBUS_ASSERT_ERROR_IS_SET (error);
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
call    5 returned 100%
        -: 2163:  
     2011: 2164:  _dbus_verbose ("Sending error reply %s \"%s\"\n",
call    0 returned 100%
        -: 2165:                 error->name, error->message);
        -: 2166:
     2011: 2167:  reply = dbus_message_new_error (in_reply_to,
call    0 returned 100%
        -: 2168:                                  error->name,
        -: 2169:                                  error->message);
     2011: 2170:  if (reply == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       30: 2171:    return FALSE;
        -: 2172:
     1981: 2173:  if (!bus_transaction_send_from_driver (transaction, connection, reply))
call    0 returned 100%
branch  1 taken 13% (fallthrough)
branch  2 taken 87%
        -: 2174:    {
      261: 2175:      dbus_message_unref (reply);
call    0 returned 100%
      261: 2176:      return FALSE;
        -: 2177:    }
        -: 2178:
     1720: 2179:  dbus_message_unref (reply);
call    0 returned 100%
        -: 2180:  
     1720: 2181:  return TRUE;
        -: 2182:}
        -: 2183:
        -: 2184:dbus_bool_t
        -: 2185:bus_transaction_add_cancel_hook (BusTransaction               *transaction,
        -: 2186:                                 BusTransactionCancelFunction  cancel_function,
        -: 2187:                                 void                         *data,
        -: 2188:                                 DBusFreeFunction              free_data_function)
function bus_transaction_add_cancel_hook called 21583 returned 100% blocks executed 100%
    21583: 2189:{
        -: 2190:  CancelHook *ch;
        -: 2191:
    21583: 2192:  ch = dbus_new (CancelHook, 1);
call    0 returned 100%
    21583: 2193:  if (ch == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       32: 2194:    return FALSE;
        -: 2195:
    21551: 2196:  _dbus_verbose ("     adding cancel hook function = %p data = %p\n",
call    0 returned 100%
        -: 2197:                 cancel_function, data);
        -: 2198:  
    21551: 2199:  ch->cancel_function = cancel_function;
    21551: 2200:  ch->data = data;
    21551: 2201:  ch->free_data_function = free_data_function;
        -: 2202:
        -: 2203:  /* It's important that the hooks get run in reverse order that they
        -: 2204:   * were added
        -: 2205:   */
    21551: 2206:  if (!_dbus_list_prepend (&transaction->cancel_hooks, ch))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 2207:    {
       34: 2208:      dbus_free (ch);
call    0 returned 100%
       34: 2209:      return FALSE;
        -: 2210:    }
        -: 2211:
    21517: 2212:  return TRUE;
        -: 2213:}