Coverage report for bus/activation.c.gcov

        -:    0:Source:activation.c
        -:    0:Graph:activation.gcno
        -:    0:Data:activation.gcda
        -:    0:Runs:10122
        -:    0:Programs:2
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* activation.c  Activation of services
        -:    3: *
        -:    4: * Copyright (C) 2003  CodeFactory AB
        -:    5: * Copyright (C) 2003  Red Hat, Inc.
        -:    6: * Copyright (C) 2004  Imendio HB
        -:    7: *
        -:    8: * Licensed under the Academic Free License version 2.1
        -:    9: * 
        -:   10: * This program is free software; you can redistribute it and/or modify
        -:   11: * it under the terms of the GNU General Public License as published by
        -:   12: * the Free Software Foundation; either version 2 of the License, or
        -:   13: * (at your option) any later version.
        -:   14: *
        -:   15: * This program is distributed in the hope that it will be useful,
        -:   16: * but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   17: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   18: * GNU General Public License for more details.
        -:   19: * 
        -:   20: * You should have received a copy of the GNU General Public License
        -:   21: * along with this program; if not, write to the Free Software
        -:   22: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        -:   23: *
        -:   24: */
        -:   25:#include "activation.h"
        -:   26:#include "desktop-file.h"
        -:   27:#include "services.h"
        -:   28:#include "test.h"
        -:   29:#include "utils.h"
        -:   30:#include <dbus/dbus-internals.h>
        -:   31:#include <dbus/dbus-hash.h>
        -:   32:#include <dbus/dbus-list.h>
        -:   33:#include <dbus/dbus-shell.h>
        -:   34:#include <dbus/dbus-spawn.h>
        -:   35:#include <dbus/dbus-timeout.h>
        -:   36:#include <dirent.h>
        -:   37:#include <errno.h>
        -:   38:
        -:   39:#define DBUS_SERVICE_SECTION "D-BUS Service"
        -:   40:#define DBUS_SERVICE_NAME "Name"
        -:   41:#define DBUS_SERVICE_EXEC "Exec"
        -:   42:
        -:   43:struct BusActivation
        -:   44:{
        -:   45:  int refcount;
        -:   46:  DBusHashTable *entries;
        -:   47:  DBusHashTable *pending_activations;
        -:   48:  char *server_address;
        -:   49:  BusContext *context;
        -:   50:  int n_pending_activations; /**< This is in fact the number of BusPendingActivationEntry,
        -:   51:                              * i.e. number of pending activation requests, not pending
        -:   52:                              * activations per se
        -:   53:                              */
        -:   54:  DBusHashTable *directories;
        -:   55:};
        -:   56:
        -:   57:typedef struct
        -:   58:{
        -:   59:  int refcount;
        -:   60:  char *dir_c;
        -:   61:  DBusHashTable *entries;
        -:   62:} BusServiceDirectory;
        -:   63:
        -:   64:typedef struct
        -:   65:{
        -:   66:  int refcount;
        -:   67:  char *name;
        -:   68:  char *exec;
        -:   69:  unsigned long mtime;
        -:   70:  BusServiceDirectory *s_dir;
        -:   71:  char *filename;
        -:   72:} BusActivationEntry;
        -:   73:
        -:   74:typedef struct BusPendingActivationEntry BusPendingActivationEntry;
        -:   75:
        -:   76:struct BusPendingActivationEntry
        -:   77:{
        -:   78:  DBusMessage *activation_message;
        -:   79:  DBusConnection *connection;
        -:   80:
        -:   81:  dbus_bool_t auto_activation;
        -:   82:};
        -:   83:
        -:   84:typedef struct
        -:   85:{
        -:   86:  int refcount;
        -:   87:  BusActivation *activation;
        -:   88:  char *service_name;
        -:   89:  char *exec;
        -:   90:  DBusList *entries;
        -:   91:  int n_entries;
        -:   92:  DBusBabysitter *babysitter;
        -:   93:  DBusTimeout *timeout;
        -:   94:  unsigned int timeout_added : 1;
        -:   95:} BusPendingActivation;
        -:   96:
        -:   97:#if 0
        -:   98:static BusServiceDirectory *
        -:   99:bus_service_directory_ref (BusServiceDirectory *dir)
        -:  100:{
        -:  101:  _dbus_assert (dir->refcount);
        -:  102:  
        -:  103:  dir->refcount++;
        -:  104:
        -:  105:  return dir;
        -:  106:}
        -:  107:#endif
        -:  108:
        -:  109:static void
        -:  110:bus_service_directory_unref (BusServiceDirectory *dir)
function bus_service_directory_unref called 10 returned 100% blocks executed 90%
       10:  111:{
       10:  112:  if (dir == NULL) 
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        5:  113:    return; 
        -:  114:
        5:  115:  _dbus_assert (dir->refcount > 0);
call    0 returned 100%
        5:  116:  dir->refcount--;
        -:  117:
        5:  118:  if (dir->refcount > 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  119:    return;
        -:  120:
        5:  121:  if (dir->entries)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        5:  122:    _dbus_hash_table_unref (dir->entries);
call    0 returned 100%
        -:  123:
        5:  124:  dbus_free (dir->dir_c);
call    0 returned 100%
        5:  125:  dbus_free (dir);
call    0 returned 100%
        -:  126:}
        -:  127:
        -:  128:static void
        -:  129:bus_pending_activation_entry_free (BusPendingActivationEntry *entry)
function bus_pending_activation_entry_free called 4602 returned 100% blocks executed 100%
     4602:  130:{
     4602:  131:  if (entry->activation_message)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
     4602:  132:    dbus_message_unref (entry->activation_message);
call    0 returned 100%
        -:  133:  
     4602:  134:  if (entry->connection)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
     4602:  135:    dbus_connection_unref (entry->connection);
call    0 returned 100%
        -:  136:  
     4602:  137:  dbus_free (entry);
call    0 returned 100%
     4602:  138:}
        -:  139:
        -:  140:static void
        -:  141:handle_timeout_callback (DBusTimeout   *timeout,
        -:  142:                         void          *data)
function handle_timeout_callback called 0 returned 0% blocks executed 0%
    #####:  143:{
    #####:  144:  BusPendingActivation *pending_activation = data;
        -:  145:
    #####:  146:  while (!dbus_timeout_handle (pending_activation->timeout))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  147:    _dbus_wait_for_memory ();
call    0 never executed
    #####:  148:}
        -:  149:
        -:  150:static BusPendingActivation * 
        -:  151:bus_pending_activation_ref (BusPendingActivation *pending_activation)
function bus_pending_activation_ref called 6225 returned 100% blocks executed 100%
     6225:  152:{
     6225:  153:  _dbus_assert (pending_activation->refcount > 0);
call    0 returned 100%
     6225:  154:  pending_activation->refcount += 1;
        -:  155:
     6225:  156:  return pending_activation;
        -:  157:}
        -:  158:
        -:  159:static void
        -:  160:bus_pending_activation_unref (BusPendingActivation *pending_activation)
function bus_pending_activation_unref called 15419 returned 100% blocks executed 93%
    15419:  161:{
        -:  162:  DBusList *link;
        -:  163:  
    15419:  164:  if (pending_activation == NULL) /* hash table requires this */
branch  0 taken 30% (fallthrough)
branch  1 taken 70%
     4604:  165:    return;
        -:  166:
    10815:  167:  _dbus_assert (pending_activation->refcount > 0);
call    0 returned 100%
    10815:  168:  pending_activation->refcount -= 1;
        -:  169:
    10815:  170:  if (pending_activation->refcount > 0)
branch  0 taken 58% (fallthrough)
branch  1 taken 42%
     6225:  171:    return;
        -:  172:  
     4590:  173:  if (pending_activation->timeout_added)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
        -:  174:    {
     4530:  175:      _dbus_loop_remove_timeout (bus_context_get_loop (pending_activation->activation->context),
call    0 returned 100%
call    1 returned 100%
        -:  176:                                 pending_activation->timeout,
        -:  177:                                 handle_timeout_callback, pending_activation);
     4530:  178:      pending_activation->timeout_added = FALSE;
        -:  179:    }
        -:  180:
     4590:  181:  if (pending_activation->timeout)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
     4554:  182:    _dbus_timeout_unref (pending_activation->timeout);
call    0 returned 100%
        -:  183:  
     4590:  184:  if (pending_activation->babysitter)
branch  0 taken 64% (fallthrough)
branch  1 taken 36%
        -:  185:    {
     2926:  186:      if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  187:                                                 NULL, NULL, NULL,
        -:  188:                                                 pending_activation->babysitter,
        -:  189:                                                 NULL))
    #####:  190:        _dbus_assert_not_reached ("setting watch functions to NULL failed");
call    0 never executed
        -:  191:      
     2926:  192:      _dbus_babysitter_unref (pending_activation->babysitter);
call    0 returned 100%
        -:  193:    }
        -:  194:  
     4590:  195:  dbus_free (pending_activation->service_name);
call    0 returned 100%
     4590:  196:  dbus_free (pending_activation->exec);
call    0 returned 100%
        -:  197:
     4590:  198:  link = _dbus_list_get_first_link (&pending_activation->entries);
call    0 returned 100%
        -:  199:
    13698:  200:  while (link != NULL)
branch  0 taken 50%
branch  1 taken 50% (fallthrough)
        -:  201:    {
     4518:  202:      BusPendingActivationEntry *entry = link->data;
        -:  203:
     4518:  204:      bus_pending_activation_entry_free (entry);
call    0 returned 100%
        -:  205:
     4518:  206:      link = _dbus_list_get_next_link (&pending_activation->entries, link);
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  207:    }
     4590:  208:  _dbus_list_clear (&pending_activation->entries);
call    0 returned 100%
        -:  209:
     4590:  210:  pending_activation->activation->n_pending_activations -=
        -:  211:    pending_activation->n_entries;
        -:  212:
     4590:  213:  _dbus_assert (pending_activation->activation->n_pending_activations >= 0);
call    0 returned 100%
        -:  214:  
     4590:  215:  dbus_free (pending_activation);
call    0 returned 100%
        -:  216:}
        -:  217:
        -:  218:static BusActivationEntry *
        -:  219:bus_activation_entry_ref (BusActivationEntry *entry)
function bus_activation_entry_ref called 48 returned 100% blocks executed 100%
       48:  220:{
       48:  221:  _dbus_assert (entry->refcount > 0);
call    0 returned 100%
       48:  222:  entry->refcount++;
        -:  223:
       48:  224:  return entry;
        -:  225:}
        -:  226:
        -:  227:static void
        -:  228:bus_activation_entry_unref (BusActivationEntry *entry)
function bus_activation_entry_unref called 116 returned 100% blocks executed 100%
      116:  229:{
      116:  230:  if (entry == NULL) /* hash table requires this */
branch  0 taken 40% (fallthrough)
branch  1 taken 60%
       46:  231:    return;
        -:  232:  
       70:  233:  _dbus_assert (entry->refcount > 0);
call    0 returned 100%
       70:  234:  entry->refcount--;
        -:  235:  
       70:  236:  if (entry->refcount > 0) 
branch  0 taken 69% (fallthrough)
branch  1 taken 31%
       48:  237:    return;
        -:  238:  
       22:  239:  dbus_free (entry->name);
call    0 returned 100%
       22:  240:  dbus_free (entry->exec);
call    0 returned 100%
       22:  241:  dbus_free (entry->filename);
call    0 returned 100%
        -:  242:
       22:  243:  dbus_free (entry);
call    0 returned 100%
        -:  244:}
        -:  245:
        -:  246:static dbus_bool_t
        -:  247:update_desktop_file_entry (BusActivation       *activation,
        -:  248:                           BusServiceDirectory *s_dir,
        -:  249:                           DBusString          *filename,
        -:  250:                           BusDesktopFile      *desktop_file,
        -:  251:                           DBusError           *error)
function update_desktop_file_entry called 24 returned 100% blocks executed 57%
       24:  252:{
        -:  253:  char *name, *exec;
        -:  254:  BusActivationEntry *entry;
        -:  255:  DBusStat stat_buf;
        -:  256:  DBusString file_path;
        -:  257:
       24:  258:  _DBUS_ASSERT_ERROR_IS_CLEAR (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%
        -:  259:  
       24:  260:  name = NULL;
       24:  261:  exec = NULL;
       24:  262:  entry = NULL;
        -:  263:  
       24:  264:  if (!_dbus_string_init (&file_path))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  265:    {
    #####:  266:      BUS_SET_OOM (error);
call    0 never executed
    #####:  267:      return FALSE;
        -:  268:    }
        -:  269: 
       24:  270:  if (!_dbus_string_append (&file_path, s_dir->dir_c) ||
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
call    3 returned 100%
branch  4 taken 0% (fallthrough)
branch  5 taken 100%
        -:  271:      !_dbus_concat_dir_and_file (&file_path, filename))
        -:  272:    {
    #####:  273:      BUS_SET_OOM (error);
call    0 never executed
    #####:  274:      goto failed;
        -:  275:    }
        -:  276: 
       24:  277:  if (!_dbus_stat (&file_path, &stat_buf, NULL)) 
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  278:    {
    #####:  279:      dbus_set_error (error, DBUS_ERROR_FAILED,
call    0 never executed
        -:  280:                      "Can't stat the service file\n");
    #####:  281:      goto failed;
        -:  282:    }
        -:  283: 
       24:  284:  if (!bus_desktop_file_get_string (desktop_file,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  285:                                    DBUS_SERVICE_SECTION,
        -:  286:                                    DBUS_SERVICE_NAME,
        -:  287:                                    &name))
        -:  288:    {
    #####:  289:      dbus_set_error (error, DBUS_ERROR_FAILED,
call    0 never executed
        -:  290:                      "No \""DBUS_SERVICE_NAME"\" key in .service file\n");
    #####:  291:      goto failed;
        -:  292:    }
        -:  293:
       24:  294:  if (!bus_desktop_file_get_string (desktop_file,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  295:                                    DBUS_SERVICE_SECTION,
        -:  296:                                    DBUS_SERVICE_EXEC,
        -:  297:                                    &exec))
        -:  298:    {
    #####:  299:      dbus_set_error (error, DBUS_ERROR_FAILED,
call    0 never executed
        -:  300:                      "No \""DBUS_SERVICE_EXEC"\" key in .service file\n");
    #####:  301:      goto failed;
        -:  302:    }
        -:  303:
       24:  304:  entry = _dbus_hash_table_lookup_string (s_dir->entries, 
call    0 returned 100%
call    1 returned 100%
        -:  305:                                          _dbus_string_get_const_data (filename));
       24:  306:  if (entry == NULL) /* New file */
branch  0 taken 92% (fallthrough)
branch  1 taken 8%
        -:  307:    { 
        -:  308:      /* FIXME we need a better-defined algorithm for which service file to
        -:  309:       * pick than "whichever one is first in the directory listing"
        -:  310:       */
       22:  311:      if (_dbus_hash_table_lookup_string (activation->entries, name))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  312:        {
    #####:  313:          dbus_set_error (error, DBUS_ERROR_FAILED,
call    0 never executed
        -:  314:                          "Service %s already exists in activation entry list\n", name);
    #####:  315:          goto failed;
        -:  316:        }
        -:  317:      
       22:  318:      entry = dbus_new0 (BusActivationEntry, 1);
call    0 returned 100%
       22:  319:      if (entry == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  320:        {
    #####:  321:          BUS_SET_OOM (error);
call    0 never executed
    #####:  322:          goto failed;
        -:  323:        }
        -:  324:     
       22:  325:      entry->name = name;
       22:  326:      entry->exec = exec;
       22:  327:      entry->refcount = 1;
        -:  328:    
       22:  329:      entry->s_dir = s_dir;
       22:  330:      entry->filename = _dbus_strdup (_dbus_string_get_const_data (filename));
call    0 returned 100%
call    1 returned 100%
       22:  331:      if (!entry->filename)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  332:        {
    #####:  333:          BUS_SET_OOM (error);
call    0 never executed
    #####:  334:          goto failed;
        -:  335:        }
        -:  336:
       22:  337:      if (!_dbus_hash_table_insert_string (activation->entries, entry->name, bus_activation_entry_ref (entry)))
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  338:        {
    #####:  339:          BUS_SET_OOM (error);
call    0 never executed
    #####:  340:          goto failed;
        -:  341:        }
        -:  342:     
       22:  343:      if (!_dbus_hash_table_insert_string (s_dir->entries, entry->filename, bus_activation_entry_ref (entry)))
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  344:        {
        -:  345:          /* Revert the insertion in the entries table */
    #####:  346:          _dbus_hash_table_remove_string (activation->entries, entry->name);
call    0 never executed
    #####:  347:          BUS_SET_OOM (error);
call    0 never executed
    #####:  348:          goto failed;
        -:  349:        }
        -:  350:
       22:  351:      _dbus_verbose ("Added \"%s\" to list of services\n", entry->name);
call    0 returned 100%
        -:  352:    }
        -:  353:  else /* Just update the entry */
        -:  354:    {
        2:  355:      bus_activation_entry_ref (entry);
call    0 returned 100%
        2:  356:      _dbus_hash_table_remove_string (activation->entries, entry->name);
call    0 returned 100%
        -:  357:
        2:  358:      if (_dbus_hash_table_lookup_string (activation->entries, name))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  359:        {
    #####:  360:          _dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n",
call    0 never executed
call    1 never executed
        -:  361:                         name, _dbus_string_get_const_data (&file_path));
    #####:  362:          goto failed;
        -:  363:        }
        -:  364: 
        2:  365:      dbus_free (entry->name);
call    0 returned 100%
        2:  366:      dbus_free (entry->exec);
call    0 returned 100%
        2:  367:      entry->name = name;
        2:  368:      entry->exec = exec;
        2:  369:      if (!_dbus_hash_table_insert_string (activation->entries,
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  370:                                           entry->name, bus_activation_entry_ref(entry)))
        -:  371:        {
    #####:  372:          BUS_SET_OOM (error);
call    0 never executed
        -:  373:          /* Also remove path to entries hash since we want this in sync with
        -:  374:           * the entries hash table */
    #####:  375:          _dbus_hash_table_remove_string (entry->s_dir->entries, 
call    0 never executed
        -:  376:                                          entry->filename);
    #####:  377:          bus_activation_entry_unref (entry);
call    0 never executed
    #####:  378:          return FALSE;
        -:  379:        }
        -:  380:    }
        -:  381:  
       24:  382:  entry->mtime = stat_buf.mtime;
        -:  383:  
       24:  384:  _dbus_string_free (&file_path);
call    0 returned 100%
       24:  385:  bus_activation_entry_unref (entry);
call    0 returned 100%
        -:  386:
       24:  387:  return TRUE;
        -:  388:
    #####:  389:failed:
    #####:  390:  dbus_free (name);
call    0 never executed
    #####:  391:  dbus_free (exec);
call    0 never executed
    #####:  392:  _dbus_string_free (&file_path);
call    0 never executed
        -:  393:
    #####:  394:  if (entry)
branch  0 never executed
branch  1 never executed
    #####:  395:    bus_activation_entry_unref (entry);
call    0 never executed
        -:  396:  
    #####:  397:  return FALSE;
        -:  398:}
        -:  399:
        -:  400:static dbus_bool_t
        -:  401:check_service_file (BusActivation       *activation,
        -:  402:                    BusActivationEntry  *entry,
        -:  403:                    BusActivationEntry **updated_entry,
        -:  404:                    DBusError           *error)
function check_service_file called 8075 returned 100% blocks executed 57%
     8075:  405:{
        -:  406:  DBusStat stat_buf;
        -:  407:  dbus_bool_t retval;
        -:  408:  BusActivationEntry *tmp_entry;
        -:  409:  DBusString file_path;
        -:  410:  DBusString filename;
        -:  411:
     8075:  412:  retval = TRUE;
     8075:  413:  tmp_entry = entry;
        -:  414:  
     8075:  415:  _dbus_string_init_const (&filename, entry->filename);
call    0 returned 100%
        -:  416:  
     8075:  417:  if (!_dbus_string_init (&file_path))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  418:    {
       66:  419:      BUS_SET_OOM (error);
call    0 returned 100%
       66:  420:      return FALSE;
        -:  421:    }
        -:  422: 
     8009:  423:  if (!_dbus_string_append (&file_path, entry->s_dir->dir_c) ||
call    0 returned 100%
branch  1 taken 99% (fallthrough)
branch  2 taken 1%
call    3 returned 100%
branch  4 taken 2% (fallthrough)
branch  5 taken 98%
        -:  424:      !_dbus_concat_dir_and_file (&file_path, &filename))
        -:  425:    {
      200:  426:      BUS_SET_OOM (error);
call    0 returned 100%
      200:  427:      retval = FALSE;
      200:  428:      goto out;
        -:  429:    }
        -:  430:  
     7809:  431:  if (!_dbus_stat (&file_path, &stat_buf, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  432:    {
    #####:  433:      _dbus_verbose ("****** Can't stat file \"%s\", removing from cache\n",
call    0 never executed
call    1 never executed
        -:  434:                     _dbus_string_get_const_data (&file_path));
        -:  435:
    #####:  436:      _dbus_hash_table_remove_string (activation->entries, entry->name);
call    0 never executed
    #####:  437:      _dbus_hash_table_remove_string (entry->s_dir->entries, entry->filename);
call    0 never executed
        -:  438:
    #####:  439:      tmp_entry = NULL;
    #####:  440:      retval = TRUE;
    #####:  441:      goto out;
        -:  442:    }
        -:  443:  else 
        -:  444:    {
     7809:  445:      if (stat_buf.mtime > entry->mtime) 
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  446:        {
        -:  447:          BusDesktopFile *desktop_file;
        -:  448:          DBusError tmp_error;
        -:  449:          
        2:  450:          dbus_error_init (&tmp_error);
call    0 returned 100%
        -:  451:          
        2:  452:          desktop_file = bus_desktop_file_load (&file_path, &tmp_error);
call    0 returned 100%
        2:  453:          if (desktop_file == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  454:            {
    #####:  455:              _dbus_verbose ("Could not load %s: %s\n",
call    0 never executed
call    1 never executed
        -:  456:                             _dbus_string_get_const_data (&file_path), 
        -:  457:                             tmp_error.message);
    #####:  458:              if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  459:                {
    #####:  460:                  dbus_move_error (&tmp_error, error);
call    0 never executed
    #####:  461:                  retval = FALSE;
    #####:  462:                  goto out;
        -:  463:                }
    #####:  464:              dbus_error_free (&tmp_error);
call    0 never executed
    #####:  465:              retval = TRUE;
    #####:  466:              goto out;
        -:  467:            }
        -:  468:          
        2:  469:          if (!update_desktop_file_entry (activation, entry->s_dir, &filename, desktop_file, &tmp_error))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  470:            {
    #####:  471:              bus_desktop_file_free (desktop_file);
call    0 never executed
    #####:  472:              if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  473:                {
    #####:  474:                  dbus_move_error (&tmp_error, error);
call    0 never executed
    #####:  475:                  retval = FALSE;
    #####:  476:                  goto out;
        -:  477:                }
    #####:  478:              dbus_error_free (&tmp_error);
call    0 never executed
    #####:  479:              retval = TRUE;
    #####:  480:              goto out;
        -:  481:            }
        -:  482:         
        2:  483:          bus_desktop_file_free (desktop_file);
call    0 returned 100%
        2:  484:          retval = TRUE;
        -:  485:        }
        -:  486:    }
        -:  487:  
     8009:  488:out:
     8009:  489:  _dbus_string_free (&file_path);
call    0 returned 100%
        -:  490:
     8009:  491:  if (updated_entry != NULL)
branch  0 taken 62% (fallthrough)
branch  1 taken 38%
     4958:  492:    *updated_entry = tmp_entry;
     8009:  493:  return retval;
        -:  494:}
        -:  495:
        -:  496:
        -:  497:/* warning: this doesn't fully "undo" itself on failure, i.e. doesn't strip
        -:  498: * hash entries it already added.
        -:  499: */
        -:  500:static dbus_bool_t
        -:  501:update_directory (BusActivation       *activation,
        -:  502:                  BusServiceDirectory *s_dir,
        -:  503:                  DBusError           *error)
function update_directory called 797 returned 100% blocks executed 75%
      797:  504:{
        -:  505:  DBusDirIter *iter;
        -:  506:  DBusString dir, filename;
        -:  507:  BusDesktopFile *desktop_file;
        -:  508:  DBusError tmp_error;
        -:  509:  dbus_bool_t retval;
        -:  510:  BusActivationEntry *entry;
        -:  511:  DBusString full_path;
        -:  512:  
      797:  513:  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
call    5 returned 100%
        -:  514:  
      797:  515:  iter = NULL;
      797:  516:  desktop_file = NULL;
        -:  517:  
      797:  518:  _dbus_string_init_const (&dir, s_dir->dir_c);
call    0 returned 100%
        -:  519:  
      797:  520:  if (!_dbus_string_init (&filename))
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
        -:  521:    {
       15:  522:      BUS_SET_OOM (error);
call    0 returned 100%
       15:  523:      return FALSE;
        -:  524:    }
        -:  525:
      782:  526:  if (!_dbus_string_init (&full_path))
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
        -:  527:    {
       15:  528:      BUS_SET_OOM (error);
call    0 returned 100%
       15:  529:      _dbus_string_free (&filename);
call    0 returned 100%
       15:  530:      return FALSE;
        -:  531:    }
        -:  532:
      767:  533:  retval = FALSE;
        -:  534:
        -:  535:  /* from this point it's safe to "goto out" */
        -:  536:  
      767:  537:  iter = _dbus_directory_open (&dir, error);
call    0 returned 100%
      767:  538:  if (iter == NULL)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
        -:  539:    {
       15:  540:      _dbus_verbose ("Failed to open directory %s: %s\n",
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
        -:  541:                     s_dir->dir_c, 
        -:  542:                     error ? error->message : "unknown");
       15:  543:      goto out;
        -:  544:    }
        -:  545:  
        -:  546:  /* Now read the files */
      752:  547:  dbus_error_init (&tmp_error);
call    0 returned 100%
     8523:  548:  while (_dbus_directory_get_next_file (iter, &filename, &tmp_error))
call    0 returned 100%
branch  1 taken 93%
branch  2 taken 7% (fallthrough)
        -:  549:    {
     7201:  550:      _dbus_assert (!dbus_error_is_set (&tmp_error));
call    0 returned 100%
call    1 returned 100%
        -:  551:      
     7201:  552:      _dbus_string_set_length (&full_path, 0);
call    0 returned 100%
        -:  553:      
     7201:  554:      if (!_dbus_string_ends_with_c_str (&filename, ".service"))
call    0 returned 100%
branch  1 taken 57% (fallthrough)
branch  2 taken 43%
        -:  555:        {
     4083:  556:          _dbus_verbose ("Skipping non-.service file %s\n",
call    0 returned 100%
call    1 returned 100%
        -:  557:                         _dbus_string_get_const_data (&filename));
     4083:  558:          continue;
        -:  559:        }
        -:  560:
     3118:  561:      entry = _dbus_hash_table_lookup_string (s_dir->entries, _dbus_string_get_const_data (&filename));
call    0 returned 100%
call    1 returned 100%
     3118:  562:      if (entry) /* Already has this service file in the cache */ 
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
        -:  563:        {
     3096:  564:          if (!check_service_file (activation, entry, NULL, error))
call    0 returned 100%
branch  1 taken 6% (fallthrough)
branch  2 taken 94%
      182:  565:            goto out;
        -:  566:
     2914:  567:          continue;
        -:  568:        }
        -:  569:      
       22:  570:      if (!_dbus_string_append (&full_path, s_dir->dir_c) ||
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
call    3 returned 100%
branch  4 taken 0% (fallthrough)
branch  5 taken 100%
        -:  571:          !_dbus_concat_dir_and_file (&full_path, &filename))
        -:  572:        {
    #####:  573:          BUS_SET_OOM (error);
call    0 never executed
    #####:  574:          goto out;
        -:  575:        }
        -:  576:          
        -:  577:      /* New file */
       22:  578:      desktop_file = bus_desktop_file_load (&full_path, &tmp_error);
call    0 returned 100%
       22:  579:      if (desktop_file == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  580:        {
    #####:  581:          _dbus_verbose ("Could not load %s: %s\n",
call    0 never executed
call    1 never executed
        -:  582:                         _dbus_string_get_const_data (&full_path),
        -:  583:                         tmp_error.message);
        -:  584:
    #####:  585:          if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  586:            {
    #####:  587:              dbus_move_error (&tmp_error, error);
call    0 never executed
    #####:  588:              goto out;
        -:  589:            }
        -:  590:          
    #####:  591:          dbus_error_free (&tmp_error);
call    0 never executed
    #####:  592:          continue;
        -:  593:        }
        -:  594:
       22:  595:      if (!update_desktop_file_entry (activation, s_dir, &filename, desktop_file, &tmp_error))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  596:        {
    #####:  597:          bus_desktop_file_free (desktop_file);
call    0 never executed
    #####:  598:          desktop_file = NULL;
        -:  599:          
    #####:  600:          _dbus_verbose ("Could not add %s to activation entry list: %s\n",
call    0 never executed
call    1 never executed
        -:  601:                         _dbus_string_get_const_data (&full_path), tmp_error.message);
        -:  602:
    #####:  603:          if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  604:            {
    #####:  605:              dbus_move_error (&tmp_error, error);
call    0 never executed
    #####:  606:              goto out;
        -:  607:            }
        -:  608:
    #####:  609:          dbus_error_free (&tmp_error);
call    0 never executed
    #####:  610:          continue;
        -:  611:        }
        -:  612:      else
        -:  613:        {
       22:  614:          bus_desktop_file_free (desktop_file);
call    0 returned 100%
       22:  615:          desktop_file = NULL;
       22:  616:          continue;
        -:  617:        }
        -:  618:    }
        -:  619:
      570:  620:  if (dbus_error_is_set (&tmp_error))
call    0 returned 100%
branch  1 taken 4% (fallthrough)
branch  2 taken 96%
        -:  621:    {
       21:  622:      dbus_move_error (&tmp_error, error);
call    0 returned 100%
       21:  623:      goto out;
        -:  624:    }
        -:  625:  
      549:  626:  retval = TRUE;
        -:  627:
      767:  628: out:
      767:  629:  if (!retval)
branch  0 taken 28% (fallthrough)
branch  1 taken 72%
      218:  630:    _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%
        -:  631:  else
      549:  632:    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
call    5 returned 100%
        -:  633:  
      767:  634:  if (iter != NULL)
branch  0 taken 98% (fallthrough)
branch  1 taken 2%
      752:  635:    _dbus_directory_close (iter);
call    0 returned 100%
      767:  636:  if (desktop_file)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  637:    bus_desktop_file_free (desktop_file);
call    0 never executed
      767:  638:  _dbus_string_free (&filename);
call    0 returned 100%
      767:  639:  _dbus_string_free (&full_path);
call    0 returned 100%
        -:  640:  
      767:  641:  return retval;
        -:  642:}
        -:  643:
        -:  644:BusActivation*
        -:  645:bus_activation_new (BusContext        *context,
        -:  646:                    const DBusString  *address,
        -:  647:                    DBusList         **directories,
        -:  648:                    DBusError         *error)
function bus_activation_new called 5 returned 100% blocks executed 56%
        5:  649:{
        -:  650:  BusActivation *activation;
        -:  651:  DBusList      *link;
        -:  652:  char          *dir;
        -:  653:  
        5:  654:  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch  0 taken 60% (fallthrough)
branch  1 taken 40%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
call    5 returned 100%
        -:  655:  
        5:  656:  activation = dbus_new0 (BusActivation, 1);
call    0 returned 100%
        5:  657:  if (activation == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  658:    {
    #####:  659:      BUS_SET_OOM (error);
call    0 never executed
    #####:  660:      return NULL;
        -:  661:    }
        -:  662:  
        5:  663:  activation->refcount = 1;
        5:  664:  activation->context = context;
        5:  665:  activation->n_pending_activations = 0;
        -:  666:  
        5:  667:  if (!_dbus_string_copy_data (address, &activation->server_address))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  668:    {
    #####:  669:      BUS_SET_OOM (error);
call    0 never executed
    #####:  670:      goto failed;
        -:  671:    }
        -:  672:  
        5:  673:  activation->entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
call    0 returned 100%
        -:  674:                                             (DBusFreeFunction)bus_activation_entry_unref);
        5:  675:  if (activation->entries == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  676:    {      
    #####:  677:      BUS_SET_OOM (error);
call    0 never executed
    #####:  678:      goto failed;
        -:  679:    }
        -:  680:
        5:  681:  activation->pending_activations = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
call    0 returned 100%
        -:  682:                                                          (DBusFreeFunction)bus_pending_activation_unref);
        -:  683:
        5:  684:  if (activation->pending_activations == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  685:    {
    #####:  686:      BUS_SET_OOM (error);
call    0 never executed
    #####:  687:      goto failed;
        -:  688:    }
        -:  689:
        5:  690:  activation->directories = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
call    0 returned 100%
        -:  691:                                                  (DBusFreeFunction)bus_service_directory_unref);
        -:  692:  
        5:  693:  if (activation->directories == NULL) 
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  694:    {
    #####:  695:      BUS_SET_OOM (error);
call    0 never executed
    #####:  696:      goto failed;
        -:  697:    }
        -:  698: 
        -:  699:  /* Load service files */
        5:  700:  link = _dbus_list_get_first_link (directories);
call    0 returned 100%
       15:  701:  while (link != NULL)
branch  0 taken 50%
branch  1 taken 50% (fallthrough)
        -:  702:    {
        -:  703:      BusServiceDirectory *s_dir;
        -:  704:      
        5:  705:      dir = _dbus_strdup ((const char *) link->data);
call    0 returned 100%
        5:  706:      if (!dir)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  707:        {
    #####:  708:          BUS_SET_OOM (error);
call    0 never executed
    #####:  709:          goto failed;
        -:  710:        }
        -:  711:      
        5:  712:      s_dir = dbus_new0 (BusServiceDirectory, 1);
call    0 returned 100%
        5:  713:      if (!s_dir)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  714:        {
    #####:  715:          dbus_free (dir);
call    0 never executed
    #####:  716:          BUS_SET_OOM (error);
call    0 never executed
    #####:  717:          goto failed;
        -:  718:        }
        -:  719:
        5:  720:      s_dir->refcount = 1;
        5:  721:      s_dir->dir_c = dir;
        -:  722:      
        5:  723:      s_dir->entries = _dbus_hash_table_new (DBUS_HASH_STRING, NULL,
call    0 returned 100%
        -:  724:                                             (DBusFreeFunction)bus_activation_entry_unref);
        -:  725:
        5:  726:      if (!s_dir->entries)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  727:        {
    #####:  728:          bus_service_directory_unref (s_dir);
call    0 never executed
    #####:  729:          BUS_SET_OOM (error);
call    0 never executed
    #####:  730:          goto failed;
        -:  731:        }
        -:  732:
        5:  733:      if (!_dbus_hash_table_insert_string (activation->directories, s_dir->dir_c, s_dir))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  734:        {
    #####:  735:          bus_service_directory_unref (s_dir);
call    0 never executed
    #####:  736:          BUS_SET_OOM (error);
call    0 never executed
    #####:  737:          goto failed;
        -:  738:        }
        -:  739:
        5:  740:      if (!update_directory (activation, s_dir, error))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  741:        goto failed;
        -:  742:      
        5:  743:      link = _dbus_list_get_next_link (directories, link);
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  744:    }
        -:  745:
        5:  746:  return activation;
        -:  747:  
    #####:  748: failed:
    #####:  749:  bus_activation_unref (activation);  
call    0 never executed
    #####:  750:  return NULL;
        -:  751:}
        -:  752:
        -:  753:BusActivation *
        -:  754:bus_activation_ref (BusActivation *activation)
function bus_activation_ref called 0 returned 0% blocks executed 0%
    #####:  755:{
    #####:  756:  _dbus_assert (activation->refcount > 0);
call    0 never executed
        -:  757:  
    #####:  758:  activation->refcount += 1;
        -:  759:
    #####:  760:  return activation;
        -:  761:}
        -:  762:
        -:  763:void
        -:  764:bus_activation_unref (BusActivation *activation)
function bus_activation_unref called 5 returned 100% blocks executed 92%
        5:  765:{
        5:  766:  _dbus_assert (activation->refcount > 0);
call    0 returned 100%
        -:  767:
        5:  768:  activation->refcount -= 1;
        -:  769:
        5:  770:  if (activation->refcount > 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  771:    return;
        -:  772:  
        5:  773:  dbus_free (activation->server_address);
call    0 returned 100%
        5:  774:  if (activation->entries)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        5:  775:    _dbus_hash_table_unref (activation->entries);
call    0 returned 100%
        5:  776:  if (activation->pending_activations)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        5:  777:    _dbus_hash_table_unref (activation->pending_activations);
call    0 returned 100%
        5:  778:  if (activation->directories)  
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        5:  779:    _dbus_hash_table_unref (activation->directories);
call    0 returned 100%
        -:  780:  
        5:  781:  dbus_free (activation);
call    0 returned 100%
        -:  782:}
        -:  783:
        -:  784:static void
        -:  785:child_setup (void *data)
function child_setup called 2923 returned 100% blocks executed 25%
     2923:  786:{
     2923:  787:  BusActivation *activation = data;
        -:  788:  const char *type;
        -:  789:  
        -:  790:  /* If no memory, we simply have the child exit, so it won't try
        -:  791:   * to connect to the wrong thing.
        -:  792:   */
     2923:  793:  if (!_dbus_setenv ("DBUS_STARTER_ADDRESS", activation->server_address))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  794:    _dbus_exit (1);
call    0 never executed
        -:  795:  
     2923:  796:  type = bus_context_get_type (activation->context);
call    0 returned 100%
     2923:  797:  if (type != NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  798:    {
    #####:  799:      if (!_dbus_setenv ("DBUS_STARTER_BUS_TYPE", type))
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  800:        _dbus_exit (1);
call    0 never executed
        -:  801:
    #####:  802:      if (strcmp (type, "session") == 0)
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  803:        {
    #####:  804:          if (!_dbus_setenv ("DBUS_SESSION_BUS_ADDRESS",
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  805:                             activation->server_address))
    #####:  806:            _dbus_exit (1);
call    0 never executed
        -:  807:        }
    #####:  808:      else if (strcmp (type, "system") == 0)
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  809:        {
    #####:  810:          if (!_dbus_setenv ("DBUS_SYSTEM_BUS_ADDRESS",
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  811:                             activation->server_address))
    #####:  812:            _dbus_exit (1);
call    0 never executed
        -:  813:        }
        -:  814:    }
     2923:  815:}
        -:  816:
        -:  817:typedef struct
        -:  818:{
        -:  819:  BusPendingActivation *pending_activation;
        -:  820:  DBusPreallocatedHash *hash_entry;
        -:  821:} RestorePendingData;
        -:  822:
        -:  823:static void
        -:  824:restore_pending (void *data)
function restore_pending called 98 returned 100% blocks executed 100%
       98:  825:{
       98:  826:  RestorePendingData *d = data;
        -:  827:
       98:  828:  _dbus_assert (d->pending_activation != NULL);
call    0 returned 100%
       98:  829:  _dbus_assert (d->hash_entry != NULL);
call    0 returned 100%
        -:  830:
       98:  831:  _dbus_verbose ("Restoring pending activation for service %s, has timeout = %d\n",
call    0 returned 100%
        -:  832:                 d->pending_activation->service_name,
        -:  833:                 d->pending_activation->timeout_added);
        -:  834:  
       98:  835:  _dbus_hash_table_insert_string_preallocated (d->pending_activation->activation->pending_activations,
call    0 returned 100%
        -:  836:                                               d->hash_entry,
        -:  837:                                               d->pending_activation->service_name, d->pending_activation);
        -:  838:
       98:  839:  bus_pending_activation_ref (d->pending_activation);
call    0 returned 100%
        -:  840:  
       98:  841:  d->hash_entry = NULL;
       98:  842:}
        -:  843:
        -:  844:static void
        -:  845:free_pending_restore_data (void *data)
function free_pending_restore_data called 1645 returned 100% blocks executed 100%
     1645:  846:{
     1645:  847:  RestorePendingData *d = data;
        -:  848:
     1645:  849:  if (d->hash_entry)
branch  0 taken 94% (fallthrough)
branch  1 taken 6%
     1544:  850:    _dbus_hash_table_free_preallocated_entry (d->pending_activation->activation->pending_activations,
call    0 returned 100%
        -:  851:                                              d->hash_entry);
        -:  852:
     1645:  853:  bus_pending_activation_unref (d->pending_activation);
call    0 returned 100%
        -:  854:  
     1645:  855:  dbus_free (d);
call    0 returned 100%
     1645:  856:}
        -:  857:
        -:  858:static dbus_bool_t
        -:  859:add_restore_pending_to_transaction (BusTransaction       *transaction,
        -:  860:                                    BusPendingActivation *pending_activation)
function add_restore_pending_to_transaction called 1648 returned 100% blocks executed 100%
     1648:  861:{
        -:  862:  RestorePendingData *d;
        -:  863:
     1648:  864:  d = dbus_new (RestorePendingData, 1);
call    0 returned 100%
     1648:  865:  if (d == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        3:  866:    return FALSE;
        -:  867:  
     1645:  868:  d->pending_activation = pending_activation;
     1645:  869:  d->hash_entry = _dbus_hash_table_preallocate_entry (d->pending_activation->activation->pending_activations);
call    0 returned 100%
        -:  870:  
     1645:  871:  bus_pending_activation_ref (d->pending_activation);
call    0 returned 100%
        -:  872:  
     1645:  873:  if (d->hash_entry == NULL ||
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
call    2 returned 100%
branch  3 taken 1% (fallthrough)
branch  4 taken 99%
        -:  874:      !bus_transaction_add_cancel_hook (transaction, restore_pending, d,
        -:  875:                                        free_pending_restore_data))
        -:  876:    {
        9:  877:      free_pending_restore_data (d);
call    0 returned 100%
        9:  878:      return FALSE;
        -:  879:    }
        -:  880:
     1636:  881:  _dbus_verbose ("Saved pending activation to be restored if the transaction fails\n");
call    0 returned 100%
        -:  882:  
     1636:  883:  return TRUE;
        -:  884:}
        -:  885:
        -:  886:dbus_bool_t
        -:  887:bus_activation_service_created (BusActivation  *activation,
        -:  888:                                const char     *service_name,
        -:  889:                                BusTransaction *transaction,
        -:  890:                                DBusError      *error)
function bus_activation_service_created called 7461 returned 100% blocks executed 95%
     7461:  891:{
        -:  892:  BusPendingActivation *pending_activation;
        -:  893:  DBusMessage *message;
        -:  894:  DBusList *link;
        -:  895:
     7461:  896:  _DBUS_ASSERT_ERROR_IS_CLEAR (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%
        -:  897:  
        -:  898:  /* Check if it's a pending activation */
     7461:  899:  pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name);
call    0 returned 100%
        -:  900:
     7461:  901:  if (!pending_activation)
branch  0 taken 75% (fallthrough)
branch  1 taken 25%
     5629:  902:    return TRUE;
        -:  903:
     1832:  904:  link = _dbus_list_get_first_link (&pending_activation->entries);
call    0 returned 100%
     5439:  905:  while (link != NULL)
branch  0 taken 51%
branch  1 taken 49% (fallthrough)
        -:  906:    {
     1832:  907:      BusPendingActivationEntry *entry = link->data;
     1832:  908:      DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  909:      
     1832:  910:      if (dbus_connection_get_is_connected (entry->connection))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -:  911:        {
        -:  912:          /* Only send activation replies to regular activation requests. */
     1832:  913:          if (!entry->auto_activation)
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
        -:  914:            {
        -:  915:              dbus_uint32_t result;
        -:  916:              
     1830:  917:              message = dbus_message_new_method_return (entry->activation_message);
call    0 returned 100%
     1830:  918:              if (!message)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  919:                {
        1:  920:                  BUS_SET_OOM (error);
call    0 returned 100%
        1:  921:                  goto error;
        -:  922:                }
        -:  923:
     1829:  924:              result = DBUS_START_REPLY_SUCCESS;
        -:  925:              
     1829:  926:              if (!dbus_message_append_args (message,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  927:                                             DBUS_TYPE_UINT32, &result,
        -:  928:                                             DBUS_TYPE_INVALID))
        -:  929:                {
        5:  930:                  dbus_message_unref (message);
call    0 returned 100%
        5:  931:                  BUS_SET_OOM (error);
call    0 returned 100%
        5:  932:                  goto error;
        -:  933:                }
        -:  934:              
     1824:  935:              if (!bus_transaction_send_from_driver (transaction, entry->connection, message))
call    0 returned 100%
branch  1 taken 3% (fallthrough)
branch  2 taken 97%
        -:  936:                {
       51:  937:                  dbus_message_unref (message);
call    0 returned 100%
       51:  938:                  BUS_SET_OOM (error);
call    0 returned 100%
       51:  939:                  goto error;
        -:  940:                }
        -:  941:              
     1773:  942:              dbus_message_unref (message);
call    0 returned 100%
        -:  943:            }
        -:  944:        }
        -:  945:      
     1775:  946:      link = next;
        -:  947:    }
        -:  948:
     1775:  949:  return TRUE;
        -:  950:
       57:  951: error:
       57:  952:  return FALSE;
        -:  953:}
        -:  954:
        -:  955:dbus_bool_t
        -:  956:bus_activation_send_pending_auto_activation_messages (BusActivation  *activation,
        -:  957:                                                      BusService     *service,
        -:  958:                                                      BusTransaction *transaction,
        -:  959:                                                      DBusError      *error)
function bus_activation_send_pending_auto_activation_messages called 1648 returned 100% blocks executed 84%
     1648:  960:{
        -:  961:  BusPendingActivation *pending_activation;
        -:  962:  DBusList *link;
        -:  963:
     1648:  964:  _DBUS_ASSERT_ERROR_IS_CLEAR (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%
        -:  965:  
        -:  966:  /* Check if it's a pending activation */
     1648:  967:  pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations,
call    0 returned 100%
call    1 returned 100%
        -:  968:                                                       bus_service_get_name (service));
        -:  969:
     1648:  970:  if (!pending_activation)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  971:    return TRUE;
        -:  972:
     1648:  973:  link = _dbus_list_get_first_link (&pending_activation->entries);
call    0 returned 100%
     4944:  974:  while (link != NULL)
branch  0 taken 50%
branch  1 taken 50% (fallthrough)
        -:  975:    {
     1648:  976:      BusPendingActivationEntry *entry = link->data;
     1648:  977:      DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  978:
     1648:  979:      if (entry->auto_activation && dbus_connection_get_is_connected (entry->connection))
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
        -:  980:        {
        -:  981:          DBusConnection *addressed_recipient;
        -:  982:          
        2:  983:          addressed_recipient = bus_service_get_primary_owners_connection (service);
call    0 returned 100%
        -:  984:
        -:  985:          /* Check the security policy, which has the side-effect of adding an
        -:  986:           * expected pending reply.
        -:  987:           */
        2:  988:          if (!bus_context_check_security_policy (activation->context, transaction,
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -:  989:                                                  entry->connection,
        -:  990:                                                  addressed_recipient,
        -:  991:                                                  addressed_recipient,
        -:  992:                                                  entry->activation_message, error))
    #####:  993:            goto error;
        -:  994:
        2:  995:          if (!bus_transaction_send (transaction, addressed_recipient, entry->activation_message))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  996:            {
    #####:  997:              BUS_SET_OOM (error);
call    0 never executed
    #####:  998:              goto error;
        -:  999:            }
        -: 1000:        }
        -: 1001:
     1648: 1002:      link = next;
        -: 1003:    }
        -: 1004:
     1648: 1005:  if (!add_restore_pending_to_transaction (transaction, pending_activation))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1006:    {
       12: 1007:      _dbus_verbose ("Could not add cancel hook to transaction to revert removing pending activation\n");
call    0 returned 100%
       12: 1008:      BUS_SET_OOM (error);
call    0 returned 100%
       12: 1009:      goto error;
        -: 1010:    }
        -: 1011:  
     1636: 1012:  _dbus_hash_table_remove_string (activation->pending_activations, bus_service_get_name (service));
call    0 returned 100%
call    1 returned 100%
        -: 1013:
     1636: 1014:  return TRUE;
        -: 1015:
       12: 1016: error:
       12: 1017:  return FALSE;
        -: 1018:}
        -: 1019:
        -: 1020:/**
        -: 1021: * FIXME @todo the error messages here would ideally be preallocated
        -: 1022: * so we don't need to allocate memory to send them.
        -: 1023: * Using the usual tactic, prealloc an OOM message, then
        -: 1024: * if we can't alloc the real error send the OOM error instead.
        -: 1025: */
        -: 1026:static dbus_bool_t
        -: 1027:try_send_activation_failure (BusPendingActivation *pending_activation,
        -: 1028:                             const DBusError      *how)
function try_send_activation_failure called 1654 returned 100% blocks executed 95%
     1654: 1029:{
        -: 1030:  BusActivation *activation;
        -: 1031:  DBusList *link;
        -: 1032:  BusTransaction *transaction;
        -: 1033:  
     1654: 1034:  activation = pending_activation->activation;
        -: 1035:
     1654: 1036:  transaction = bus_transaction_new (activation->context);
call    0 returned 100%
     1654: 1037:  if (transaction == NULL)
branch  0 taken 12% (fallthrough)
branch  1 taken 88%
      193: 1038:    return FALSE;
        -: 1039:  
     1461: 1040:  link = _dbus_list_get_first_link (&pending_activation->entries);
call    0 returned 100%
     4263: 1041:  while (link != NULL)
branch  0 taken 52%
branch  1 taken 48% (fallthrough)
        -: 1042:    {
     1461: 1043:      BusPendingActivationEntry *entry = link->data;
     1461: 1044:      DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link);
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1045:      
     1461: 1046:      if (dbus_connection_get_is_connected (entry->connection))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -: 1047:        {
     1461: 1048:          if (!bus_transaction_send_error_reply (transaction,
call    0 returned 100%
branch  1 taken 92% (fallthrough)
branch  2 taken 8%
        -: 1049:                                                 entry->connection,
        -: 1050:                                                 how,
        -: 1051:                                                 entry->activation_message))
      120: 1052:            goto error;
        -: 1053:        }
        -: 1054:      
     1341: 1055:      link = next;
        -: 1056:    }
        -: 1057:
     1341: 1058:  bus_transaction_execute_and_free (transaction);
call    0 returned 100%
        -: 1059:  
     1341: 1060:  return TRUE;
        -: 1061:
      120: 1062: error:
      120: 1063:  if (transaction)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
      120: 1064:    bus_transaction_cancel_and_free (transaction);
call    0 returned 100%
      120: 1065:  return FALSE;
        -: 1066:}
        -: 1067:
        -: 1068:/**
        -: 1069: * Free the pending activation and send an error message to all the
        -: 1070: * connections that were waiting for it.
        -: 1071: */
        -: 1072:static void
        -: 1073:pending_activation_failed (BusPendingActivation *pending_activation,
        -: 1074:                           const DBusError      *how)
function pending_activation_failed called 1341 returned 100% blocks executed 100%
     1341: 1075:{
        -: 1076:  /* FIXME use preallocated OOM messages instead of bus_wait_for_memory() */
     2995: 1077:  while (!try_send_activation_failure (pending_activation, how))
call    0 returned 100%
branch  1 taken 19%
branch  2 taken 81% (fallthrough)
      313: 1078:    _dbus_wait_for_memory ();
call    0 returned 100%
        -: 1079:
        -: 1080:  /* Destroy this pending activation */
     1341: 1081:  _dbus_hash_table_remove_string (pending_activation->activation->pending_activations,
call    0 returned 100%
        -: 1082:                                  pending_activation->service_name);
     1341: 1083:}
        -: 1084:
        -: 1085:static dbus_bool_t
        -: 1086:babysitter_watch_callback (DBusWatch     *watch,
        -: 1087:                           unsigned int   condition,
        -: 1088:                           void          *data)
function babysitter_watch_callback called 6074 returned 100% blocks executed 84%
     6074: 1089:{
     6074: 1090:  BusPendingActivation *pending_activation = data;
        -: 1091:  dbus_bool_t retval;
        -: 1092:  DBusBabysitter *babysitter;
        -: 1093:
     6074: 1094:  babysitter = pending_activation->babysitter;
        -: 1095:  
     6074: 1096:  _dbus_babysitter_ref (babysitter);
call    0 returned 100%
        -: 1097:  
     6074: 1098:  retval = dbus_watch_handle (watch, condition);
call    0 returned 100%
        -: 1099:
        -: 1100:  /* FIXME this is broken in the same way that
        -: 1101:   * connection watches used to be; there should be
        -: 1102:   * a separate callback for status change, instead
        -: 1103:   * of doing "if we handled a watch status might
        -: 1104:   * have changed"
        -: 1105:   *
        -: 1106:   * Fixing this lets us move dbus_watch_handle
        -: 1107:   * calls into dbus-mainloop.c
        -: 1108:   */
        -: 1109:  
     6074: 1110:  if (_dbus_babysitter_get_child_exited (babysitter))
call    0 returned 100%
branch  1 taken 22% (fallthrough)
branch  2 taken 78%
        -: 1111:    {
        -: 1112:      DBusError error;
        -: 1113:      DBusHashIter iter;
        -: 1114:      
     1341: 1115:      dbus_error_init (&error);
call    0 returned 100%
     1341: 1116:      _dbus_babysitter_set_child_exit_error (babysitter, &error);
call    0 returned 100%
        -: 1117:
        -: 1118:      /* Destroy all pending activations with the same exec */
     1341: 1119:      _dbus_hash_iter_init (pending_activation->activation->pending_activations,
call    0 returned 100%
        -: 1120:                            &iter);
     4023: 1121:      while (_dbus_hash_iter_next (&iter))
call    0 returned 100%
branch  1 taken 50%
branch  2 taken 50% (fallthrough)
        -: 1122:        {
     1341: 1123:          BusPendingActivation *p = _dbus_hash_iter_get_value (&iter);
call    0 returned 100%
        -: 1124:         
     1341: 1125:          if (p != pending_activation && strcmp (p->exec, pending_activation->exec) == 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
call    2 never executed
branch  3 never executed
branch  4 never executed
    #####: 1126:            pending_activation_failed (p, &error);
call    0 never executed
        -: 1127:        }
        -: 1128:      
        -: 1129:      /* Destroys the pending activation */
     1341: 1130:      pending_activation_failed (pending_activation, &error);
call    0 returned 100%
        -: 1131:
     1341: 1132:      dbus_error_free (&error);
call    0 returned 100%
        -: 1133:    }
        -: 1134:  
     6074: 1135:  _dbus_babysitter_unref (babysitter);
call    0 returned 100%
        -: 1136:
     6074: 1137:  return retval;
        -: 1138:}
        -: 1139:
        -: 1140:static dbus_bool_t
        -: 1141:add_babysitter_watch (DBusWatch      *watch,
        -: 1142:                      void           *data)
function add_babysitter_watch called 5835 returned 100% blocks executed 100%
     5835: 1143:{
     5835: 1144:  BusPendingActivation *pending_activation = data;
        -: 1145:
     5835: 1146:  return _dbus_loop_add_watch (bus_context_get_loop (pending_activation->activation->context),
call    0 returned 100%
call    1 returned 100%
        -: 1147:                               watch, babysitter_watch_callback, pending_activation,
        -: 1148:                               NULL);
        -: 1149:}
        -: 1150:
        -: 1151:static void
        -: 1152:remove_babysitter_watch (DBusWatch      *watch,
        -: 1153:                         void           *data)
function remove_babysitter_watch called 5806 returned 100% blocks executed 100%
     5806: 1154:{
     5806: 1155:  BusPendingActivation *pending_activation = data;
        -: 1156:  
     5806: 1157:  _dbus_loop_remove_watch (bus_context_get_loop (pending_activation->activation->context),
call    0 returned 100%
call    1 returned 100%
        -: 1158:                           watch, babysitter_watch_callback, pending_activation);
     5806: 1159:}
        -: 1160:
        -: 1161:static dbus_bool_t
        -: 1162:pending_activation_timed_out (void *data)
function pending_activation_timed_out called 0 returned 0% blocks executed 0%
    #####: 1163:{
    #####: 1164:  BusPendingActivation *pending_activation = data;
        -: 1165:  DBusError error;
        -: 1166:  
        -: 1167:  /* Kill the spawned process, since it sucks
        -: 1168:   * (not sure this is what we want to do, but
        -: 1169:   * may as well try it for now)
        -: 1170:   */
    #####: 1171:  if (pending_activation->babysitter) 
branch  0 never executed
branch  1 never executed
    #####: 1172:    _dbus_babysitter_kill_child (pending_activation->babysitter);
call    0 never executed
        -: 1173:
    #####: 1174:  dbus_error_init (&error);
call    0 never executed
        -: 1175:
    #####: 1176:  dbus_set_error (&error, DBUS_ERROR_TIMED_OUT,
call    0 never executed
        -: 1177:                  "Activation of %s timed out",
        -: 1178:                  pending_activation->service_name);
        -: 1179:
    #####: 1180:  pending_activation_failed (pending_activation, &error);
call    0 never executed
        -: 1181:
    #####: 1182:  dbus_error_free (&error);
call    0 never executed
        -: 1183:
    #####: 1184:  return TRUE;
        -: 1185:}
        -: 1186:
        -: 1187:static void
        -: 1188:cancel_pending (void *data)
function cancel_pending called 1488 returned 100% blocks executed 100%
     1488: 1189:{
     1488: 1190:  BusPendingActivation *pending_activation = data;
        -: 1191:
     1488: 1192:  _dbus_verbose ("Canceling pending activation of %s\n",
call    0 returned 100%
        -: 1193:                 pending_activation->service_name);
        -: 1194:
     1488: 1195:  if (pending_activation->babysitter)
branch  0 taken 3% (fallthrough)
branch  1 taken 97%
       47: 1196:    _dbus_babysitter_kill_child (pending_activation->babysitter);
call    0 returned 100%
        -: 1197:  
     1488: 1198:  _dbus_hash_table_remove_string (pending_activation->activation->pending_activations,
call    0 returned 100%
        -: 1199:                                  pending_activation->service_name);
     1488: 1200:}
        -: 1201:
        -: 1202:static void
        -: 1203:free_pending_cancel_data (void *data)
function free_pending_cancel_data called 4482 returned 100% blocks executed 100%
     4482: 1204:{
     4482: 1205:  BusPendingActivation *pending_activation = data;
        -: 1206:  
     4482: 1207:  bus_pending_activation_unref (pending_activation);
call    0 returned 100%
     4482: 1208:}
        -: 1209:
        -: 1210:static dbus_bool_t
        -: 1211:add_cancel_pending_to_transaction (BusTransaction       *transaction,
        -: 1212:                                   BusPendingActivation *pending_activation)
function add_cancel_pending_to_transaction called 4506 returned 100% blocks executed 100%
     4506: 1213:{  
     4506: 1214:  if (!bus_transaction_add_cancel_hook (transaction, cancel_pending,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1215:                                        pending_activation,
        -: 1216:                                        free_pending_cancel_data))
       24: 1217:    return FALSE;
        -: 1218:
     4482: 1219:  bus_pending_activation_ref (pending_activation); 
call    0 returned 100%
        -: 1220:  
     4482: 1221:  _dbus_verbose ("Saved pending activation to be canceled if the transaction fails\n");
call    0 returned 100%
        -: 1222:  
     4482: 1223:  return TRUE;
        -: 1224:}
        -: 1225:
        -: 1226:static dbus_bool_t 
        -: 1227:update_service_cache (BusActivation *activation, DBusError *error)
function update_service_cache called 792 returned 100% blocks executed 88%
      792: 1228:{
        -: 1229:  DBusHashIter iter;
        -: 1230: 
      792: 1231:  _dbus_hash_iter_init (activation->directories, &iter);
call    0 returned 100%
     2128: 1232:  while (_dbus_hash_iter_next (&iter))
call    0 returned 100%
branch  1 taken 59%
branch  2 taken 41% (fallthrough)
        -: 1233:    {
        -: 1234:      DBusError tmp_error;
        -: 1235:      BusServiceDirectory *s_dir;
        -: 1236:
      792: 1237:      s_dir = _dbus_hash_iter_get_value (&iter);
call    0 returned 100%
        -: 1238:
      792: 1239:      dbus_error_init (&tmp_error);
call    0 returned 100%
      792: 1240:      if (!update_directory (activation, s_dir, &tmp_error))
call    0 returned 100%
branch  1 taken 31% (fallthrough)
branch  2 taken 69%
        -: 1241:        {
      248: 1242:          if (dbus_error_has_name (&tmp_error, DBUS_ERROR_NO_MEMORY))
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -: 1243:            {
      248: 1244:              dbus_move_error (&tmp_error, error);
call    0 returned 100%
      248: 1245:              return FALSE;
        -: 1246:            }
        -: 1247:
    #####: 1248:          dbus_error_free (&tmp_error);
call    0 never executed
    #####: 1249:          continue;
        -: 1250:        }
        -: 1251:    }
        -: 1252:  
      544: 1253:  return TRUE;
        -: 1254:}
        -: 1255:
        -: 1256:static BusActivationEntry *
        -: 1257:activation_find_entry (BusActivation *activation, 
        -: 1258:                       const char    *service_name,
        -: 1259:                       DBusError     *error)
function activation_find_entry called 5771 returned 100% blocks executed 100%
     5771: 1260:{
        -: 1261:  BusActivationEntry *entry;
        -: 1262:  
     5771: 1263:  entry = _dbus_hash_table_lookup_string (activation->entries, service_name);
call    0 returned 100%
     5771: 1264:  if (!entry)
branch  0 taken 14% (fallthrough)
branch  1 taken 86%
        -: 1265:    { 
      792: 1266:      if (!update_service_cache (activation, error)) 
call    0 returned 100%
branch  1 taken 31% (fallthrough)
branch  2 taken 69%
      248: 1267:        return NULL;
        -: 1268:
      544: 1269:      entry = _dbus_hash_table_lookup_string (activation->entries,
call    0 returned 100%
        -: 1270:                                              service_name);
        -: 1271:    }
        -: 1272:  else 
        -: 1273:    {
        -: 1274:      BusActivationEntry *updated_entry;
        -: 1275:
     4979: 1276:      if (!check_service_file (activation, entry, &updated_entry, error)) 
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
       84: 1277:        return NULL;
        -: 1278:
     4895: 1279:      entry = updated_entry;
        -: 1280:    }
        -: 1281:
     5439: 1282:  if (!entry) 
branch  0 taken 10% (fallthrough)
branch  1 taken 90%
        -: 1283:    {
      540: 1284:      dbus_set_error (error, DBUS_ERROR_SERVICE_UNKNOWN,
call    0 returned 100%
        -: 1285:                      "The name %s was not provided by any .service files",
        -: 1286:                      service_name);
      540: 1287:      return NULL;
        -: 1288:    }
        -: 1289:
     4899: 1290:  return entry;
        -: 1291:}
        -: 1292:
        -: 1293:dbus_bool_t
        -: 1294:bus_activation_activate_service (BusActivation  *activation,
        -: 1295:                                 DBusConnection *connection,
        -: 1296:                                 BusTransaction *transaction,
        -: 1297:                                 dbus_bool_t     auto_activation,
        -: 1298:                                 DBusMessage    *activation_message,
        -: 1299:                                 const char     *service_name,
        -: 1300:                                 DBusError      *error)
function bus_activation_activate_service called 5237 returned 100% blocks executed 77%
     5237: 1301:{
        -: 1302:  BusActivationEntry *entry;
        -: 1303:  BusPendingActivation *pending_activation;
        -: 1304:  BusPendingActivationEntry *pending_activation_entry;
        -: 1305:  DBusMessage *message;
        -: 1306:  DBusString service_str;
        -: 1307:  char **argv;
        -: 1308:  int argc;
        -: 1309:  dbus_bool_t retval;
        -: 1310:  DBusHashIter iter;
        -: 1311:  dbus_bool_t activated;
        -: 1312:  
     5237: 1313:  activated = TRUE;
        -: 1314:
     5237: 1315:  _DBUS_ASSERT_ERROR_IS_CLEAR (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%
        -: 1316:
     5237: 1317:  if (activation->n_pending_activations >=
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1318:      bus_context_get_max_pending_activations (activation->context))
        -: 1319:    {
    #####: 1320:      dbus_set_error (error, DBUS_ERROR_LIMITS_EXCEEDED,
call    0 never executed
        -: 1321:                      "The maximum number of pending activations has been reached, activation of %s failed",
        -: 1322:                      service_name);
    #####: 1323:      return FALSE;
        -: 1324:    }
        -: 1325:
     5237: 1326:  entry = activation_find_entry (activation, service_name, error);
call    0 returned 100%
     5237: 1327:  if (!entry) 
branch  0 taken 12% (fallthrough)
branch  1 taken 88%
      623: 1328:    return FALSE;
        -: 1329:
        -: 1330:  /* Bypass the registry lookup if we're auto-activating, bus_dispatch would not
        -: 1331:   * call us if the service is already active.
        -: 1332:   */
     4614: 1333:  if (!auto_activation)
branch  0 taken 75% (fallthrough)
branch  1 taken 25%
        -: 1334:    {
        -: 1335:      /* Check if the service is active */
     3482: 1336:      _dbus_string_init_const (&service_str, service_name);
call    0 returned 100%
     3482: 1337:      if (bus_registry_lookup (bus_context_get_registry (activation->context), &service_str) != NULL)
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -: 1338:        {
        -: 1339:          dbus_uint32_t result;
        -: 1340:          
    #####: 1341:          _dbus_verbose ("Service \"%s\" is already active\n", service_name);
call    0 never executed
        -: 1342:      
    #####: 1343:          message = dbus_message_new_method_return (activation_message);
call    0 never executed
        -: 1344:
    #####: 1345:          if (!message)
branch  0 never executed
branch  1 never executed
        -: 1346:            {
    #####: 1347:              _dbus_verbose ("No memory to create reply to activate message\n");
call    0 never executed
    #####: 1348:              BUS_SET_OOM (error);
call    0 never executed
    #####: 1349:              return FALSE;
        -: 1350:            }
        -: 1351:
    #####: 1352:          result = DBUS_START_REPLY_ALREADY_RUNNING;
        -: 1353:          
    #####: 1354:          if (!dbus_message_append_args (message,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -: 1355:                                         DBUS_TYPE_UINT32, &result,
        -: 1356:                                         DBUS_TYPE_INVALID))
        -: 1357:            {
    #####: 1358:              _dbus_verbose ("No memory to set args of reply to activate message\n");
call    0 never executed
    #####: 1359:              BUS_SET_OOM (error);
call    0 never executed
    #####: 1360:              dbus_message_unref (message);
call    0 never executed
    #####: 1361:              return FALSE;
        -: 1362:            }
        -: 1363:
    #####: 1364:          retval = bus_transaction_send_from_driver (transaction, connection, message);
call    0 never executed
    #####: 1365:          dbus_message_unref (message);
call    0 never executed
    #####: 1366:          if (!retval)
branch  0 never executed
branch  1 never executed
        -: 1367:            {
    #####: 1368:              _dbus_verbose ("Failed to send reply\n");
call    0 never executed
    #####: 1369:              BUS_SET_OOM (error);
call    0 never executed
        -: 1370:            }
        -: 1371:
    #####: 1372:          return retval;
        -: 1373:        }
        -: 1374:    }
        -: 1375:  
     4614: 1376:  pending_activation_entry = dbus_new0 (BusPendingActivationEntry, 1);
call    0 returned 100%
     4614: 1377:  if (!pending_activation_entry)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1378:    {
       12: 1379:      _dbus_verbose ("Failed to create pending activation entry\n");
call    0 returned 100%
       12: 1380:      BUS_SET_OOM (error);
call    0 returned 100%
       12: 1381:      return FALSE;
        -: 1382:    }
        -: 1383:
     4602: 1384:  pending_activation_entry->auto_activation = auto_activation;
        -: 1385:
     4602: 1386:  pending_activation_entry->activation_message = activation_message;
     4602: 1387:  dbus_message_ref (activation_message);
call    0 returned 100%
     4602: 1388:  pending_activation_entry->connection = connection;
     4602: 1389:  dbus_connection_ref (connection);
call    0 returned 100%
        -: 1390:  
        -: 1391:  /* Check if the service is being activated */
     4602: 1392:  pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name);
call    0 returned 100%
     4602: 1393:  if (pending_activation)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1394:    {
    #####: 1395:      if (!_dbus_list_append (&pending_activation->entries, pending_activation_entry))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -: 1396:        {
    #####: 1397:          _dbus_verbose ("Failed to append a new entry to pending activation\n");
call    0 never executed
        -: 1398:          
    #####: 1399:          BUS_SET_OOM (error);
call    0 never executed
    #####: 1400:          bus_pending_activation_entry_free (pending_activation_entry);
call    0 never executed
    #####: 1401:          return FALSE;
        -: 1402:        }
        -: 1403:
    #####: 1404:      pending_activation->n_entries += 1;
    #####: 1405:      pending_activation->activation->n_pending_activations += 1;
        -: 1406:    }
        -: 1407:  else
        -: 1408:    {
     4602: 1409:      pending_activation = dbus_new0 (BusPendingActivation, 1);
call    0 returned 100%
     4602: 1410:      if (!pending_activation)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1411:        {
       12: 1412:          _dbus_verbose ("Failed to create pending activation\n");
call    0 returned 100%
        -: 1413:          
       12: 1414:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1415:          bus_pending_activation_entry_free (pending_activation_entry);          
call    0 returned 100%
       12: 1416:          return FALSE;
        -: 1417:        }
        -: 1418:
     4590: 1419:      pending_activation->activation = activation;
     4590: 1420:      pending_activation->refcount = 1;
        -: 1421:      
     4590: 1422:      pending_activation->service_name = _dbus_strdup (service_name);
call    0 returned 100%
     4590: 1423:      if (!pending_activation->service_name)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1424:        {
       12: 1425:          _dbus_verbose ("Failed to copy service name for pending activation\n");
call    0 returned 100%
        -: 1426:          
       12: 1427:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1428:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       12: 1429:          bus_pending_activation_entry_free (pending_activation_entry);          
call    0 returned 100%
       12: 1430:          return FALSE;
        -: 1431:        }
        -: 1432:
     4578: 1433:      pending_activation->exec = _dbus_strdup (entry->exec);
call    0 returned 100%
     4578: 1434:      if (!pending_activation->exec)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1435:        {
       12: 1436:          _dbus_verbose ("Failed to copy service exec for pending activation\n");
call    0 returned 100%
       12: 1437:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1438:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       12: 1439:          bus_pending_activation_entry_free (pending_activation_entry);
call    0 returned 100%
       12: 1440:          return FALSE;
        -: 1441:        }
        -: 1442:
     4566: 1443:      pending_activation->timeout =
call    0 returned 100%
call    1 returned 100%
        -: 1444:        _dbus_timeout_new (bus_context_get_activation_timeout (activation->context),
        -: 1445:                           pending_activation_timed_out,
        -: 1446:                           pending_activation,
        -: 1447:                           NULL);
     4566: 1448:      if (!pending_activation->timeout)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -: 1449:        {
       12: 1450:          _dbus_verbose ("Failed to create timeout for pending activation\n");
call    0 returned 100%
        -: 1451:          
       12: 1452:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1453:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       12: 1454:          bus_pending_activation_entry_free (pending_activation_entry);
call    0 returned 100%
       12: 1455:          return FALSE;
        -: 1456:        }
        -: 1457:
     4554: 1458:      if (!_dbus_loop_add_timeout (bus_context_get_loop (activation->context),
call    0 returned 100%
call    1 returned 100%
branch  2 taken 1% (fallthrough)
branch  3 taken 99%
        -: 1459:                                   pending_activation->timeout,
        -: 1460:                                   handle_timeout_callback,
        -: 1461:                                   pending_activation,
        -: 1462:                                   NULL))
        -: 1463:        {
       24: 1464:          _dbus_verbose ("Failed to add timeout for pending activation\n");
call    0 returned 100%
        -: 1465:          
       24: 1466:          BUS_SET_OOM (error);
call    0 returned 100%
       24: 1467:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       24: 1468:          bus_pending_activation_entry_free (pending_activation_entry);          
call    0 returned 100%
       24: 1469:          return FALSE;
        -: 1470:        }
        -: 1471:
     4530: 1472:      pending_activation->timeout_added = TRUE;
        -: 1473:      
     4530: 1474:      if (!_dbus_list_append (&pending_activation->entries, pending_activation_entry))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1475:        {
       12: 1476:          _dbus_verbose ("Failed to add entry to just-created pending activation\n");
call    0 returned 100%
        -: 1477:          
       12: 1478:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1479:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       12: 1480:          bus_pending_activation_entry_free (pending_activation_entry);          
call    0 returned 100%
       12: 1481:          return FALSE;
        -: 1482:        }
        -: 1483:
     4518: 1484:      pending_activation->n_entries += 1;
     4518: 1485:      pending_activation->activation->n_pending_activations += 1;
        -: 1486:    
     4518: 1487:      activated = FALSE;
     4518: 1488:      _dbus_hash_iter_init (activation->pending_activations, &iter);
call    0 returned 100%
     4518: 1489:      while (_dbus_hash_iter_next (&iter))
call    0 returned 100%
branch  1 taken 0%
branch  2 taken 100% (fallthrough)
        -: 1490:        {
    #####: 1491:          BusPendingActivation *p = _dbus_hash_iter_get_value (&iter);
call    0 never executed
        -: 1492:          
    #####: 1493:          if (strcmp (p->exec, entry->exec) == 0) 
call    0 never executed
branch  1 never executed
branch  2 never executed
        -: 1494:            {
    #####: 1495:              activated = TRUE;
    #####: 1496:              break;
        -: 1497:            }
        -: 1498:        }
        -: 1499:     
     4518: 1500:      if (!_dbus_hash_table_insert_string (activation->pending_activations,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1501:                                           pending_activation->service_name,
        -: 1502:                                           pending_activation))
        -: 1503:        {
       12: 1504:          _dbus_verbose ("Failed to put pending activation in hash table\n");
call    0 returned 100%
        -: 1505:          
       12: 1506:          BUS_SET_OOM (error);
call    0 returned 100%
       12: 1507:          bus_pending_activation_unref (pending_activation);
call    0 returned 100%
       12: 1508:          return FALSE;
        -: 1509:        }
        -: 1510:    }
        -: 1511:  
     4506: 1512:  if (!add_cancel_pending_to_transaction (transaction, pending_activation))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1513:    {
       24: 1514:      _dbus_verbose ("Failed to add pending activation cancel hook to transaction\n");
call    0 returned 100%
       24: 1515:      BUS_SET_OOM (error);
call    0 returned 100%
       24: 1516:      _dbus_hash_table_remove_string (activation->pending_activations,
call    0 returned 100%
        -: 1517:                                      pending_activation->service_name);
        -: 1518:
       24: 1519:      return FALSE;
        -: 1520:    }
        -: 1521:  
     4482: 1522:  if (activated)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1523:    return TRUE;
        -: 1524:
        -: 1525:  /* Now try to spawn the process */
     4482: 1526:  if (!_dbus_shell_parse_argv (entry->exec, &argc, &argv, error))
call    0 returned 100%
branch  1 taken 33% (fallthrough)
branch  2 taken 67%
        -: 1527:    {
     1492: 1528:      _dbus_verbose ("Failed to parse command line: %s\n", entry->exec);
call    0 returned 100%
     1492: 1529:      _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%
        -: 1530:      
     1492: 1531:      _dbus_hash_table_remove_string (activation->pending_activations,
call    0 returned 100%
        -: 1532:                                      pending_activation->service_name);
        -: 1533:
     1492: 1534:      return FALSE;
        -: 1535:    }
        -: 1536:
     2990: 1537:  _dbus_verbose ("Spawning %s ...\n", argv[0]);
call    0 returned 100%
     2990: 1538:  if (!_dbus_spawn_async_with_babysitter (&pending_activation->babysitter, argv,
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
        -: 1539:                                          child_setup, activation, 
        -: 1540:                                          error))
        -: 1541:    {
       64: 1542:      _dbus_verbose ("Failed to spawn child\n");
call    0 returned 100%
       64: 1543:      _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%
       64: 1544:      dbus_free_string_array (argv);
call    0 returned 100%
        -: 1545:
       64: 1546:      return FALSE;
        -: 1547:    }
        -: 1548:
     2926: 1549:  dbus_free_string_array (argv);
call    0 returned 100%
        -: 1550:
     2926: 1551:  _dbus_assert (pending_activation->babysitter != NULL);
call    0 returned 100%
        -: 1552:  
     2926: 1553:  if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -: 1554:                                             add_babysitter_watch,
        -: 1555:                                             remove_babysitter_watch,
        -: 1556:                                             NULL,
        -: 1557:                                             pending_activation,
        -: 1558:                                             NULL))
        -: 1559:    {
       29: 1560:      BUS_SET_OOM (error);
call    0 returned 100%
       29: 1561:      _dbus_verbose ("Failed to set babysitter watch functions\n");
call    0 returned 100%
       29: 1562:      return FALSE;
        -: 1563:    }
        -: 1564:  
     2897: 1565:  return TRUE;
        -: 1566:}
        -: 1567:
        -: 1568:#ifdef DBUS_BUILD_TESTS
        -: 1569:
        -: 1570:#include <stdio.h>
        -: 1571:
        -: 1572:#define SERVICE_NAME_1 "MyService1"
        -: 1573:#define SERVICE_NAME_2 "MyService2"
        -: 1574:#define SERVICE_NAME_3 "MyService3"
        -: 1575:
        -: 1576:#define SERVICE_FILE_1 "service-1.service"
        -: 1577:#define SERVICE_FILE_2 "service-2.service"
        -: 1578:#define SERVICE_FILE_3 "service-3.service"
        -: 1579:
        -: 1580:static dbus_bool_t
        -: 1581:test_create_service_file (DBusString *dir,
        -: 1582:                          const char *filename, 
        -: 1583:                          const char *name, 
        -: 1584:                          const char *exec)
function test_create_service_file called 6 returned 100% blocks executed 84%
        6: 1585:{
        -: 1586:  DBusString  file_name, full_path;
        -: 1587:  FILE        *file;
        -: 1588:  dbus_bool_t  ret_val;
        -: 1589:
        6: 1590:  ret_val = TRUE;
        6: 1591:  _dbus_string_init_const (&file_name, filename);
call    0 returned 100%
        -: 1592:
        6: 1593:  if (!_dbus_string_init (&full_path))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1594:    return FALSE;
        -: 1595:
        6: 1596:  if (!_dbus_string_append (&full_path, _dbus_string_get_const_data (dir)) ||
call    0 returned 100%
call    1 returned 100%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
call    4 returned 100%
branch  5 taken 0% (fallthrough)
branch  6 taken 100%
        -: 1597:      !_dbus_concat_dir_and_file (&full_path, &file_name))
        -: 1598:    {
    #####: 1599:      ret_val = FALSE;
    #####: 1600:      goto out;
        -: 1601:    }
        -: 1602:  
        6: 1603:  file = fopen (_dbus_string_get_const_data (&full_path), "w");
call    0 returned 100%
call    1 returned 100%
        6: 1604:  if (!file)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1605:    {
    #####: 1606:      ret_val = FALSE;
    #####: 1607:      goto out;
        -: 1608:    }
        -: 1609:
        6: 1610:  fprintf (file, "[D-BUS Service]\nName=%s\nExec=%s\n", name, exec);
call    0 returned 100%
        6: 1611:  fclose (file);
call    0 returned 100%
        -: 1612:
        6: 1613:out:
        6: 1614:  _dbus_string_free (&full_path);
call    0 returned 100%
        6: 1615:  return ret_val;
        -: 1616:}
        -: 1617:
        -: 1618:static dbus_bool_t
        -: 1619:test_remove_service_file (DBusString *dir, const char *filename)
function test_remove_service_file called 4 returned 100% blocks executed 81%
        4: 1620:{
        -: 1621:  DBusString  file_name, full_path;
        -: 1622:  dbus_bool_t ret_val;
        -: 1623:  
        4: 1624:  ret_val = TRUE;
        -: 1625: 
        4: 1626:  _dbus_string_init_const (&file_name, filename);
call    0 returned 100%
        -: 1627:
        4: 1628:  if (!_dbus_string_init (&full_path))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1629:    return FALSE;
        -: 1630:
        4: 1631:  if (!_dbus_string_append (&full_path, _dbus_string_get_const_data (dir)) ||
call    0 returned 100%
call    1 returned 100%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
call    4 returned 100%
branch  5 taken 0% (fallthrough)
branch  6 taken 100%
        -: 1632:      !_dbus_concat_dir_and_file (&full_path, &file_name))
        -: 1633:    {
    #####: 1634:      ret_val = FALSE;
    #####: 1635:      goto out;
        -: 1636:    }
        -: 1637:
        4: 1638:  if (!_dbus_delete_file (&full_path, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1639:    {
    #####: 1640:      ret_val = FALSE;
    #####: 1641:      goto out;
        -: 1642:    }
        -: 1643:
        4: 1644:out:
        4: 1645:  _dbus_string_free (&full_path);
call    0 returned 100%
        4: 1646:  return ret_val;
        -: 1647:}
        -: 1648:
        -: 1649:static dbus_bool_t
        -: 1650:test_remove_directory (DBusString *dir)
function test_remove_directory called 2 returned 100% blocks executed 76%
        2: 1651:{
        -: 1652:  DBusDirIter *iter;
        -: 1653:  DBusString   filename, full_path;
        -: 1654:  dbus_bool_t  ret_val;
        -: 1655:  
        2: 1656:  ret_val = TRUE;
        -: 1657:  
        2: 1658:  if (!_dbus_string_init (&filename))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1659:    return FALSE;
        -: 1660:
        2: 1661:  if (!_dbus_string_init (&full_path))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1662:    {
    #####: 1663:      _dbus_string_free (&filename);
call    0 never executed
    #####: 1664:      return FALSE;
        -: 1665:    }
        -: 1666:    
        2: 1667:  iter = _dbus_directory_open (dir, NULL);
call    0 returned 100%
        2: 1668:  if (iter == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1669:    {
    #####: 1670:      ret_val = FALSE;
    #####: 1671:      goto out;
        -: 1672:    }
        -: 1673:  
        6: 1674:  while (_dbus_directory_get_next_file (iter, &filename, NULL)) 
call    0 returned 100%
branch  1 taken 50%
branch  2 taken 50% (fallthrough)
        -: 1675:    {
        2: 1676:      if (!test_remove_service_file (dir, _dbus_string_get_const_data (&filename)))
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -: 1677:        {
    #####: 1678:          ret_val = FALSE;
    #####: 1679:          goto out;
        -: 1680:        }
        -: 1681:    }
        2: 1682:  _dbus_directory_close (iter);
call    0 returned 100%
        -: 1683:
        2: 1684:  if (!_dbus_delete_directory (dir, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1685:    {
    #####: 1686:      ret_val = FALSE;
    #####: 1687:      goto out;
        -: 1688:    }
        -: 1689:
        2: 1690:out:
        2: 1691:  _dbus_string_free (&filename);
call    0 returned 100%
        2: 1692:  _dbus_string_free (&full_path);
call    0 returned 100%
        -: 1693:
        2: 1694:  return ret_val;
        -: 1695:}
        -: 1696:
        -: 1697:static dbus_bool_t
        -: 1698:init_service_reload_test (DBusString *dir)
function init_service_reload_test called 2 returned 100% blocks executed 76%
        2: 1699:{
        -: 1700:  DBusStat stat_buf;
        -: 1701: 
        2: 1702:  if (!_dbus_stat (dir, &stat_buf, NULL))
call    0 returned 100%
branch  1 taken 50% (fallthrough)
branch  2 taken 50%
        -: 1703:    {
        1: 1704:      if (!_dbus_create_directory (dir, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1705:        return FALSE;
        -: 1706:    }
        -: 1707:  else 
        -: 1708:    {
        1: 1709:      if (!test_remove_directory (dir))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1710:        return FALSE;
        -: 1711:
        1: 1712:      if (!_dbus_create_directory (dir, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1713:        return FALSE;
        -: 1714:    }
        -: 1715:
        -: 1716:  /* Create one initial file */
        2: 1717:  if (!test_create_service_file (dir, SERVICE_FILE_1, SERVICE_NAME_1, "exec-1"))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1718:    return FALSE;
        -: 1719:
        2: 1720:  return TRUE;
        -: 1721:}
        -: 1722:
        -: 1723:static dbus_bool_t
        -: 1724:cleanup_service_reload_test (DBusString *dir)
function cleanup_service_reload_test called 1 returned 100% blocks executed 80%
        1: 1725:{
        1: 1726:  if (!test_remove_directory (dir))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1727:    return FALSE;
        -: 1728:
        1: 1729:  return TRUE;
        -: 1730:}
        -: 1731:
        -: 1732:typedef struct 
        -: 1733:{
        -: 1734:  BusActivation *activation;
        -: 1735:  const char    *service_name;
        -: 1736:  dbus_bool_t    expecting_find;
        -: 1737:} CheckData;
        -: 1738:
        -: 1739:static dbus_bool_t
        -: 1740:check_func (void *data)
function check_func called 534 returned 100% blocks executed 83%
      534: 1741:{
        -: 1742:  CheckData          *d;
        -: 1743:  BusActivationEntry *entry;
        -: 1744:  DBusError           error;
        -: 1745:  dbus_bool_t         ret_val;
        -: 1746:  
      534: 1747:  ret_val = TRUE;
      534: 1748:  d = data;
        -: 1749:  
      534: 1750:  dbus_error_init (&error);
call    0 returned 100%
        -: 1751: 
      534: 1752:  entry = activation_find_entry (d->activation, d->service_name, &error);
call    0 returned 100%
      534: 1753:  if (entry == NULL)
branch  0 taken 47% (fallthrough)
branch  1 taken 53%
        -: 1754:    {
      249: 1755:      if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) 
call    0 returned 100%
branch  1 taken 58% (fallthrough)
branch  2 taken 42%
        -: 1756:        {
      144: 1757:          ret_val = TRUE;
        -: 1758:        }
        -: 1759:      else
        -: 1760:        {
      105: 1761:          if (d->expecting_find)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1762:            ret_val = FALSE;
        -: 1763:        }
        -: 1764:      
      249: 1765:      dbus_error_free (&error);
call    0 returned 100%
        -: 1766:    }
        -: 1767:  else 
        -: 1768:    {
      285: 1769:      if (!d->expecting_find)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1770:        ret_val = FALSE;
        -: 1771:    }
        -: 1772:
      534: 1773:  return ret_val;
        -: 1774:}
        -: 1775:
        -: 1776:static dbus_bool_t
        -: 1777:do_test (const char *description, dbus_bool_t oom_test, CheckData *data)
function do_test called 12 returned 100% blocks executed 88%
       12: 1778:{
        -: 1779:  dbus_bool_t err;
        -: 1780:
       12: 1781:  if (oom_test)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        6: 1782:    err = !_dbus_test_oom_handling (description, check_func, data);
call    0 returned 100%
        -: 1783:  else
        6: 1784:    err = !check_func (data);
call    0 returned 100%
        -: 1785:
       12: 1786:  if (err) 
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1787:    _dbus_assert_not_reached ("Test failed");
call    0 never executed
        -: 1788:
       12: 1789:  return TRUE;
        -: 1790:}
        -: 1791:
        -: 1792:static dbus_bool_t
        -: 1793:do_service_reload_test (DBusString *dir, dbus_bool_t oom_test)
function do_service_reload_test called 2 returned 100% blocks executed 73%
        2: 1794:{
        -: 1795:  BusActivation *activation;
        -: 1796:  DBusString     address;
        -: 1797:  DBusList      *directories;
        -: 1798:  CheckData      d;
        -: 1799:  
        2: 1800:  directories = NULL;
        2: 1801:  _dbus_string_init_const (&address, "");
call    0 returned 100%
        -: 1802: 
        2: 1803:  if (!_dbus_list_append (&directories, _dbus_string_get_data (dir)))
call    0 returned 100%
call    1 returned 100%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
    #####: 1804:    return FALSE; 
        -: 1805:
        2: 1806:  activation = bus_activation_new (NULL, &address, &directories, NULL);
call    0 returned 100%
        2: 1807:  if (!activation)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####: 1808:    return FALSE;
        -: 1809:
        2: 1810:  d.activation = activation;
        -: 1811:  
        -: 1812:  /* Check for existing service file */
        2: 1813:  d.expecting_find = TRUE;
        2: 1814:  d.service_name = SERVICE_NAME_1;
        -: 1815:
        2: 1816:  if (!do_test ("Existing service file", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1817:    return FALSE;
        -: 1818:
        -: 1819:  /* Check for non-existing service file */
        2: 1820:  d.expecting_find = FALSE;
        2: 1821:  d.service_name = SERVICE_NAME_3;
        -: 1822:
        2: 1823:  if (!do_test ("Nonexisting service file", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1824:    return FALSE;
        -: 1825:
        -: 1826:  /* Check for added service file */
        2: 1827:  if (!test_create_service_file (dir, SERVICE_FILE_2, SERVICE_NAME_2, "exec-2"))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1828:    return FALSE;
        -: 1829:
        2: 1830:  d.expecting_find = TRUE;
        2: 1831:  d.service_name = SERVICE_NAME_2;
        -: 1832:  
        2: 1833:  if (!do_test ("Added service file", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1834:    return FALSE;
        -: 1835:  
        -: 1836:  /* Check for removed service file */
        2: 1837:  if (!test_remove_service_file (dir, SERVICE_FILE_2))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1838:    return FALSE;
        -: 1839:
        2: 1840:  d.expecting_find = FALSE;
        2: 1841:  d.service_name = SERVICE_FILE_2;
        -: 1842:
        2: 1843:  if (!do_test ("Removed service file", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1844:    return FALSE;
        -: 1845:  
        -: 1846:  /* Check for updated service file */
        -: 1847:  
        2: 1848:  _dbus_sleep_milliseconds (1000); /* Sleep a second to make sure the mtime is updated */
call    0 returned 100%
        -: 1849:
        2: 1850:  if (!test_create_service_file (dir, SERVICE_FILE_1, SERVICE_NAME_3, "exec-3"))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1851:    return FALSE;
        -: 1852:
        2: 1853:  d.expecting_find = TRUE;
        2: 1854:  d.service_name = SERVICE_NAME_3;
        -: 1855:
        2: 1856:  if (!do_test ("Updated service file, part 1", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1857:    return FALSE;
        -: 1858:
        2: 1859:  d.expecting_find = FALSE;
        2: 1860:  d.service_name = SERVICE_NAME_1;
        -: 1861:
        2: 1862:  if (!do_test ("Updated service file, part 2", oom_test, &d))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1863:    return FALSE; 
        -: 1864:
        2: 1865:  bus_activation_unref (activation);
call    0 returned 100%
        2: 1866:  _dbus_list_clear (&directories);
call    0 returned 100%
        -: 1867:
        2: 1868:  return TRUE;
        -: 1869:}
        -: 1870:
        -: 1871:dbus_bool_t
        -: 1872:bus_activation_service_reload_test (const DBusString *test_data_dir)
function bus_activation_service_reload_test called 1 returned 100% blocks executed 77%
        1: 1873:{
        -: 1874:  DBusString directory;
        -: 1875:
        1: 1876:  if (!_dbus_string_init (&directory))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1877:    return FALSE;
        -: 1878:
        1: 1879:  if (!_dbus_string_append (&directory, "/tmp/dbus-reload-test-") ||
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
call    3 returned 100%
branch  4 taken 0% (fallthrough)
branch  5 taken 100%
        -: 1880:      !_dbus_generate_random_ascii (&directory, 6))
        -: 1881:     {
    #####: 1882:       return FALSE;
        -: 1883:     }
        -: 1884:   
        -: 1885:  /* Do normal tests */
        1: 1886:  if (!init_service_reload_test (&directory))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1887:    _dbus_assert_not_reached ("could not initiate service reload test");
call    0 never executed
        -: 1888: 
        1: 1889:  if (!do_service_reload_test (&directory, FALSE))
call    0 returned 100%
        -: 1890:    ; /* Do nothing? */
        -: 1891:  
        -: 1892:  /* Do OOM tests */
        1: 1893:  if (!init_service_reload_test (&directory))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1894:    _dbus_assert_not_reached ("could not initiate service reload test");
call    0 never executed
        -: 1895: 
        1: 1896:  if (!do_service_reload_test (&directory, TRUE))
call    0 returned 100%
        -: 1897:    ; /* Do nothing? */
        -: 1898: 
        -: 1899:  /* Cleanup test directory */
        1: 1900:  if (!cleanup_service_reload_test (&directory))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####: 1901:    return FALSE;
        -: 1902:  
        1: 1903:  _dbus_string_free (&directory);
call    0 returned 100%
        -: 1904:  
        1: 1905:  return TRUE;
        -: 1906:}
        -: 1907:
        -: 1908:#endif /* DBUS_BUILD_TESTS */