Coverage report for dbus/dbus-transport-unix.c.gcov

        -:    0:Source:dbus-transport-unix.c
        -:    0:Graph:.libs/dbus-transport-unix.gcno
        -:    0:Data:.libs/dbus-transport-unix.gcda
        -:    0:Runs:11819
        -:    0:Programs:5
        -:    1:/* -*- mode: C; c-file-style: "gnu" -*- */
        -:    2:/* dbus-transport-unix.c UNIX socket subclasses of DBusTransport
        -:    3: *
        -:    4: * Copyright (C) 2002, 2003, 2004  Red Hat Inc.
        -:    5: *
        -:    6: * Licensed under the Academic Free License version 2.1
        -:    7: * 
        -:    8: * This program is free software; you can redistribute it and/or modify
        -:    9: * it under the terms of the GNU General Public License as published by
        -:   10: * the Free Software Foundation; either version 2 of the License, or
        -:   11: * (at your option) any later version.
        -:   12: *
        -:   13: * This program is distributed in the hope that it will be useful,
        -:   14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
        -:   15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
        -:   16: * GNU General Public License for more details.
        -:   17: * 
        -:   18: * You should have received a copy of the GNU General Public License
        -:   19: * along with this program; if not, write to the Free Software
        -:   20: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        -:   21: *
        -:   22: */
        -:   23:
        -:   24:#include "dbus-internals.h"
        -:   25:#include "dbus-connection-internal.h"
        -:   26:#include "dbus-transport-unix.h"
        -:   27:#include "dbus-transport-protected.h"
        -:   28:#include "dbus-watch.h"
        -:   29:
        -:   30:
        -:   31:/**
        -:   32: * @defgroup DBusTransportUnix DBusTransport implementations for UNIX
        -:   33: * @ingroup  DBusInternals
        -:   34: * @brief Implementation details of DBusTransport on UNIX
        -:   35: *
        -:   36: * @{
        -:   37: */
        -:   38:
        -:   39:/**
        -:   40: * Opaque object representing a Unix file descriptor transport.
        -:   41: */
        -:   42:typedef struct DBusTransportUnix DBusTransportUnix;
        -:   43:
        -:   44:/**
        -:   45: * Implementation details of DBusTransportUnix. All members are private.
        -:   46: */
        -:   47:struct DBusTransportUnix
        -:   48:{
        -:   49:  DBusTransport base;                   /**< Parent instance */
        -:   50:  int fd;                               /**< File descriptor. */
        -:   51:  DBusWatch *read_watch;                /**< Watch for readability. */
        -:   52:  DBusWatch *write_watch;               /**< Watch for writability. */
        -:   53:
        -:   54:  int max_bytes_read_per_iteration;     /**< To avoid blocking too long. */
        -:   55:  int max_bytes_written_per_iteration;  /**< To avoid blocking too long. */
        -:   56:
        -:   57:  int message_bytes_written;            /**< Number of bytes of current
        -:   58:                                         *   outgoing message that have
        -:   59:                                         *   been written.
        -:   60:                                         */
        -:   61:  DBusString encoded_outgoing;          /**< Encoded version of current
        -:   62:                                         *   outgoing message.
        -:   63:                                         */
        -:   64:  DBusString encoded_incoming;          /**< Encoded version of current
        -:   65:                                         *   incoming data.
        -:   66:                                         */
        -:   67:};
        -:   68:
        -:   69:static void
        -:   70:free_watches (DBusTransport *transport)
function free_watches called 28449 returned 100% blocks executed 100%
    28449:   71:{
    28449:   72:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:   73:
    28449:   74:  _dbus_verbose ("%s start\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
        -:   75:  
    28449:   76:  if (unix_transport->read_watch)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        -:   77:    {
    14225:   78:      if (transport->connection)
branch  0 taken 97% (fallthrough)
branch  1 taken 3%
    13838:   79:        _dbus_connection_remove_watch_unlocked (transport->connection,
call    0 returned 100%
        -:   80:                                                unix_transport->read_watch);
    14225:   81:      _dbus_watch_invalidate (unix_transport->read_watch);
call    0 returned 100%
    14225:   82:      _dbus_watch_unref (unix_transport->read_watch);
call    0 returned 100%
    14225:   83:      unix_transport->read_watch = NULL;
        -:   84:    }
        -:   85:
    28449:   86:  if (unix_transport->write_watch)
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
        -:   87:    {
    14225:   88:      if (transport->connection)
branch  0 taken 97% (fallthrough)
branch  1 taken 3%
    13838:   89:        _dbus_connection_remove_watch_unlocked (transport->connection,
call    0 returned 100%
        -:   90:                                                unix_transport->write_watch);
    14225:   91:      _dbus_watch_invalidate (unix_transport->write_watch);
call    0 returned 100%
    14225:   92:      _dbus_watch_unref (unix_transport->write_watch);
call    0 returned 100%
    14225:   93:      unix_transport->write_watch = NULL;
        -:   94:    }
        -:   95:
    28449:   96:  _dbus_verbose ("%s end\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
    28449:   97:}
        -:   98:
        -:   99:static void
        -:  100:unix_finalize (DBusTransport *transport)
function unix_finalize called 14224 returned 100% blocks executed 100%
    14224:  101:{
    14224:  102:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  103:
    14224:  104:  _dbus_verbose ("%s\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
        -:  105:  
    14224:  106:  free_watches (transport);
call    0 returned 100%
        -:  107:
    14224:  108:  _dbus_string_free (&unix_transport->encoded_outgoing);
call    0 returned 100%
    14224:  109:  _dbus_string_free (&unix_transport->encoded_incoming);
call    0 returned 100%
        -:  110:  
    14224:  111:  _dbus_transport_finalize_base (transport);
call    0 returned 100%
        -:  112:
    14224:  113:  _dbus_assert (unix_transport->read_watch == NULL);
call    0 returned 100%
    14224:  114:  _dbus_assert (unix_transport->write_watch == NULL);
call    0 returned 100%
        -:  115:  
    14224:  116:  dbus_free (transport);
call    0 returned 100%
    14224:  117:}
        -:  118:
        -:  119:static void
        -:  120:check_write_watch (DBusTransport *transport)
function check_write_watch called 192202 returned 100% blocks executed 95%
   192202:  121:{
   192202:  122:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  123:  dbus_bool_t needed;
        -:  124:
   192202:  125:  if (transport->connection == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  126:    return;
        -:  127:
   192202:  128:  if (transport->disconnected)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
        -:  129:    {
     3342:  130:      _dbus_assert (unix_transport->write_watch == NULL);
call    0 returned 100%
     3342:  131:      return;
        -:  132:    }
        -:  133:  
   188860:  134:  _dbus_transport_ref (transport);
call    0 returned 100%
        -:  135:
   188860:  136:  if (_dbus_transport_get_is_authenticated (transport))
call    0 returned 100%
branch  1 taken 48% (fallthrough)
branch  2 taken 52%
    90723:  137:    needed = _dbus_connection_has_messages_to_send_unlocked (transport->connection);
call    0 returned 100%
        -:  138:  else
        -:  139:    {
    98137:  140:      if (transport->send_credentials_pending)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
     6352:  141:        needed = TRUE;
        -:  142:      else
        -:  143:        {
        -:  144:          DBusAuthState auth_state;
        -:  145:          
    91785:  146:          auth_state = _dbus_auth_do_work (transport->auth);
call    0 returned 100%
        -:  147:          
        -:  148:          /* If we need memory we install the write watch just in case,
        -:  149:           * if there's no need for it, it will get de-installed
        -:  150:           * next time we try reading.
        -:  151:           */
   118696:  152:          if (auth_state == DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND ||
branch  0 taken 71% (fallthrough)
branch  1 taken 29%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  153:              auth_state == DBUS_AUTH_STATE_WAITING_FOR_MEMORY)
    26911:  154:            needed = TRUE;
        -:  155:          else
    64874:  156:            needed = FALSE;
        -:  157:        }
        -:  158:    }
        -:  159:
   188860:  160:  _dbus_verbose ("check_write_watch(): needed = %d on connection %p watch %p fd = %d outgoing messages exist %d\n",
call    0 returned 100%
call    1 returned 100%
        -:  161:                 needed, transport->connection, unix_transport->write_watch,
        -:  162:                 unix_transport->fd,
        -:  163:                 _dbus_connection_has_messages_to_send_unlocked (transport->connection));
        -:  164:
   188860:  165:  _dbus_connection_toggle_watch_unlocked (transport->connection,
call    0 returned 100%
        -:  166:                                          unix_transport->write_watch,
        -:  167:                                          needed);
        -:  168:
   188860:  169:  _dbus_transport_unref (transport);
call    0 returned 100%
        -:  170:}
        -:  171:
        -:  172:static void
        -:  173:check_read_watch (DBusTransport *transport)
function check_read_watch called 194493 returned 100% blocks executed 96%
   194493:  174:{
   194493:  175:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  176:  dbus_bool_t need_read_watch;
        -:  177:
   194493:  178:  _dbus_verbose ("%s: fd = %d\n",
call    0 returned 100%
        -:  179:                 _DBUS_FUNCTION_NAME, unix_transport->fd);
        -:  180:  
   194493:  181:  if (transport->connection == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  182:    return;
        -:  183:
   194493:  184:  if (transport->disconnected)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
        -:  185:    {
     3224:  186:      _dbus_assert (unix_transport->read_watch == NULL);
call    0 returned 100%
     3224:  187:      return;
        -:  188:    }
        -:  189:  
   191269:  190:  _dbus_transport_ref (transport);
call    0 returned 100%
        -:  191:
   191269:  192:  if (_dbus_transport_get_is_authenticated (transport))
call    0 returned 100%
branch  1 taken 64% (fallthrough)
branch  2 taken 36%
   121554:  193:    need_read_watch =
call    0 returned 100%
        -:  194:      _dbus_counter_get_value (transport->live_messages_size) < transport->max_live_messages_size;
        -:  195:  else
        -:  196:    {
    69715:  197:      if (transport->receive_credentials_pending)
branch  0 taken 11% (fallthrough)
branch  1 taken 89%
     7902:  198:        need_read_watch = TRUE;
        -:  199:      else
        -:  200:        {
        -:  201:          /* The reason to disable need_read_watch when not WAITING_FOR_INPUT
        -:  202:           * is to avoid spinning on the file descriptor when we're waiting
        -:  203:           * to write or for some other part of the auth process
        -:  204:           */
        -:  205:          DBusAuthState auth_state;
        -:  206:          
    61813:  207:          auth_state = _dbus_auth_do_work (transport->auth);
call    0 returned 100%
        -:  208:
        -:  209:          /* If we need memory we install the read watch just in case,
        -:  210:           * if there's no need for it, it will get de-installed
        -:  211:           * next time we try reading. If we're authenticated we
        -:  212:           * install it since we normally have it installed while
        -:  213:           * authenticated.
        -:  214:           */
    91179:  215:          if (auth_state == DBUS_AUTH_STATE_WAITING_FOR_INPUT ||
branch  0 taken 52% (fallthrough)
branch  1 taken 48%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
branch  4 taken 0% (fallthrough)
branch  5 taken 100%
        -:  216:              auth_state == DBUS_AUTH_STATE_WAITING_FOR_MEMORY ||
        -:  217:              auth_state == DBUS_AUTH_STATE_AUTHENTICATED)
    29366:  218:            need_read_watch = TRUE;
        -:  219:          else
    32447:  220:            need_read_watch = FALSE;
        -:  221:        }
        -:  222:    }
        -:  223:
   191269:  224:  _dbus_verbose ("  setting read watch enabled = %d\n", need_read_watch);
call    0 returned 100%
   191269:  225:  _dbus_connection_toggle_watch_unlocked (transport->connection,
call    0 returned 100%
        -:  226:                                          unix_transport->read_watch,
        -:  227:                                          need_read_watch);
        -:  228:
   191269:  229:  _dbus_transport_unref (transport);
call    0 returned 100%
        -:  230:}
        -:  231:
        -:  232:static void
        -:  233:do_io_error (DBusTransport *transport)
function do_io_error called 9429 returned 100% blocks executed 100%
     9429:  234:{
     9429:  235:  _dbus_transport_ref (transport);
call    0 returned 100%
     9429:  236:  _dbus_transport_disconnect (transport);
call    0 returned 100%
     9429:  237:  _dbus_transport_unref (transport);
call    0 returned 100%
     9429:  238:}
        -:  239:
        -:  240:/* return value is whether we successfully read any new data. */
        -:  241:static dbus_bool_t
        -:  242:read_data_into_auth (DBusTransport *transport,
        -:  243:                     dbus_bool_t   *oom)
function read_data_into_auth called 37173 returned 100% blocks executed 75%
    37173:  244:{
    37173:  245:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  246:  DBusString *buffer;
        -:  247:  int bytes_read;
        -:  248:  
    37173:  249:  *oom = FALSE;
        -:  250:
    37173:  251:  _dbus_auth_get_buffer (transport->auth, &buffer);
call    0 returned 100%
        -:  252:  
    37173:  253:  bytes_read = _dbus_read (unix_transport->fd,
call    0 returned 100%
        -:  254:                           buffer, unix_transport->max_bytes_read_per_iteration);
        -:  255:
    37173:  256:  _dbus_auth_return_buffer (transport->auth, buffer,
call    0 returned 100%
        -:  257:                            bytes_read > 0 ? bytes_read : 0);
        -:  258:
    37173:  259:  if (bytes_read > 0)
branch  0 taken 91% (fallthrough)
branch  1 taken 9%
        -:  260:    {
    33812:  261:      _dbus_verbose (" read %d bytes in auth phase\n", bytes_read);
call    0 returned 100%
        -:  262:
    33812:  263:      return TRUE;
        -:  264:    }
     3361:  265:  else if (bytes_read < 0)
branch  0 taken 52% (fallthrough)
branch  1 taken 48%
        -:  266:    {
        -:  267:      /* EINTR already handled for us */
        -:  268:
     1760:  269:      if (errno == ENOMEM)
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
        -:  270:        {
       30:  271:          *oom = TRUE;
        -:  272:        }
     1730:  273:      else if (errno == EAGAIN ||
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
call    3 never executed
branch  4 never executed
branch  5 never executed
        -:  274:               errno == EWOULDBLOCK)
        -:  275:        ; /* do nothing, just return FALSE below */
        -:  276:      else
        -:  277:        {
    #####:  278:          _dbus_verbose ("Error reading from remote app: %s\n",
call    0 never executed
call    1 never executed
call    2 never executed
        -:  279:                         _dbus_strerror (errno));
    #####:  280:          do_io_error (transport);
call    0 never executed
        -:  281:        }
        -:  282:
     1760:  283:      return FALSE;
        -:  284:    }
        -:  285:  else
        -:  286:    {
     1601:  287:      _dbus_assert (bytes_read == 0);
call    0 returned 100%
        -:  288:      
     1601:  289:      _dbus_verbose ("Disconnected from remote app\n");
call    0 returned 100%
     1601:  290:      do_io_error (transport);
call    0 returned 100%
        -:  291:
     1601:  292:      return FALSE;
        -:  293:    }
        -:  294:}
        -:  295:
        -:  296:/* Return value is whether we successfully wrote any bytes */
        -:  297:static dbus_bool_t
        -:  298:write_data_from_auth (DBusTransport *transport)
function write_data_from_auth called 32278 returned 100% blocks executed 42%
    32278:  299:{
    32278:  300:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  301:  int bytes_written;
        -:  302:  const DBusString *buffer;
        -:  303:
    32278:  304:  if (!_dbus_auth_get_bytes_to_send (transport->auth,
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  305:                                     &buffer))
    #####:  306:    return FALSE;
        -:  307:  
    32278:  308:  bytes_written = _dbus_write (unix_transport->fd,
call    0 returned 100%
call    1 returned 100%
        -:  309:                               buffer,
        -:  310:                               0, _dbus_string_get_length (buffer));
        -:  311:
    32278:  312:  if (bytes_written > 0)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  313:    {
    32278:  314:      _dbus_auth_bytes_sent (transport->auth, bytes_written);
call    0 returned 100%
    32278:  315:      return TRUE;
        -:  316:    }
    #####:  317:  else if (bytes_written < 0)
branch  0 never executed
branch  1 never executed
        -:  318:    {
        -:  319:      /* EINTR already handled for us */
        -:  320:      
    #####:  321:      if (errno == EAGAIN ||
call    0 never executed
branch  1 never executed
branch  2 never executed
call    3 never executed
branch  4 never executed
branch  5 never executed
        -:  322:          errno == EWOULDBLOCK)
        -:  323:        ;
        -:  324:      else
        -:  325:        {
    #####:  326:          _dbus_verbose ("Error writing to remote app: %s\n",
call    0 never executed
call    1 never executed
call    2 never executed
        -:  327:                         _dbus_strerror (errno));
    #####:  328:          do_io_error (transport);
call    0 never executed
        -:  329:        }
        -:  330:    }
        -:  331:
    #####:  332:  return FALSE;
        -:  333:}
        -:  334:
        -:  335:static void
        -:  336:exchange_credentials (DBusTransport *transport,
        -:  337:                      dbus_bool_t    do_reading,
        -:  338:                      dbus_bool_t    do_writing)
function exchange_credentials called 124789 returned 100% blocks executed 89%
   124789:  339:{
   124789:  340:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  341:
   124789:  342:  if (do_writing && transport->send_credentials_pending)
branch  0 taken 48% (fallthrough)
branch  1 taken 52%
branch  2 taken 10% (fallthrough)
branch  3 taken 90%
        -:  343:    {
     6292:  344:      if (_dbus_send_credentials_unix_socket (unix_transport->fd,
call    0 returned 100%
branch  1 taken 98% (fallthrough)
branch  2 taken 2%
        -:  345:                                              NULL))
        -:  346:        {
     6183:  347:          transport->send_credentials_pending = FALSE;
        -:  348:        }
        -:  349:      else
        -:  350:        {
      109:  351:          _dbus_verbose ("Failed to write credentials\n");
call    0 returned 100%
      109:  352:          do_io_error (transport);
call    0 returned 100%
        -:  353:        }
        -:  354:    }
        -:  355:  
   124789:  356:  if (do_reading && transport->receive_credentials_pending)
branch  0 taken 52% (fallthrough)
branch  1 taken 48%
branch  2 taken 12% (fallthrough)
branch  3 taken 88%
        -:  357:    {
     7811:  358:      if (_dbus_read_credentials_unix_socket (unix_transport->fd,
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
        -:  359:                                               &transport->credentials,
        -:  360:                                               NULL))
        -:  361:        {
     7811:  362:          transport->receive_credentials_pending = FALSE;
        -:  363:        }
        -:  364:      else
        -:  365:        {
    #####:  366:          _dbus_verbose ("Failed to read credentials\n");
call    0 never executed
    #####:  367:          do_io_error (transport);
call    0 never executed
        -:  368:        }
        -:  369:    }
        -:  370:
   124789:  371:  if (!(transport->send_credentials_pending ||
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
        -:  372:        transport->receive_credentials_pending))
        -:  373:    {
   124680:  374:      _dbus_auth_set_credentials (transport->auth,
call    0 returned 100%
        -:  375:                                  &transport->credentials);
        -:  376:    }
   124789:  377:}
        -:  378:
        -:  379:static dbus_bool_t
        -:  380:do_authentication (DBusTransport *transport,
        -:  381:                   dbus_bool_t    do_reading,
        -:  382:                   dbus_bool_t    do_writing,
        -:  383:		   dbus_bool_t   *auth_completed)
function do_authentication called 130687 returned 100% blocks executed 97%
   130687:  384:{
        -:  385:  dbus_bool_t oom;
        -:  386:  dbus_bool_t orig_auth_state;
        -:  387:
   130687:  388:  oom = FALSE;
        -:  389:  
   130687:  390:  orig_auth_state = _dbus_transport_get_is_authenticated (transport);
call    0 returned 100%
        -:  391:
        -:  392:  /* This is essential to avoid the check_write_watch() at the end,
        -:  393:   * we don't want to add a write watch in do_iteration before
        -:  394:   * we try writing and get EAGAIN
        -:  395:   */
   130687:  396:  if (orig_auth_state)
branch  0 taken 47% (fallthrough)
branch  1 taken 53%
        -:  397:    {
    61127:  398:      if (auth_completed)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
    61127:  399:        *auth_completed = FALSE;
    61127:  400:      return TRUE;
        -:  401:    }
        -:  402:  
    69560:  403:  _dbus_transport_ref (transport);
call    0 returned 100%
        -:  404:  
   206726:  405:  while (!_dbus_transport_get_is_authenticated (transport) &&
call    0 returned 100%
branch  1 taken 92% (fallthrough)
branch  2 taken 8%
call    3 returned 100%
branch  4 taken 99%
branch  5 taken 1% (fallthrough)
        -:  406:         _dbus_transport_get_is_connected (transport))
        -:  407:    {      
   124789:  408:      exchange_credentials (transport, do_reading, do_writing);
call    0 returned 100%
        -:  409:      
   124789:  410:      if (transport->send_credentials_pending ||
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
branch  2 taken 0% (fallthrough)
branch  3 taken 100%
        -:  411:          transport->receive_credentials_pending)
        -:  412:        {
      109:  413:          _dbus_verbose ("send_credentials_pending = %d receive_credentials_pending = %d\n",
call    0 returned 100%
        -:  414:                         transport->send_credentials_pending,
        -:  415:                         transport->receive_credentials_pending);
      109:  416:          goto out;
        -:  417:        }
        -:  418:
        -:  419:#define TRANSPORT_SIDE(t) ((t)->is_server ? "server" : "client")
   124680:  420:      switch (_dbus_auth_do_work (transport->auth))
call    0 returned 100%
branch  1 taken 52%
branch  2 taken 1%
branch  3 taken 46%
branch  4 taken 1%
branch  5 taken 1%
branch  6 taken 0%
        -:  421:        {
        -:  422:        case DBUS_AUTH_STATE_WAITING_FOR_INPUT:
    64779:  423:          _dbus_verbose (" %s auth state: waiting for input\n",
branch  0 taken 60% (fallthrough)
branch  1 taken 40%
call    2 returned 100%
        -:  424:                         TRANSPORT_SIDE (transport));
    64779:  425:          if (!do_reading || !read_data_into_auth (transport, &oom))
branch  0 taken 57% (fallthrough)
branch  1 taken 43%
call    2 returned 100%
branch  3 taken 91% (fallthrough)
branch  4 taken 9%
        -:  426:            goto out;
    33812:  427:          break;
        -:  428:      
        -:  429:        case DBUS_AUTH_STATE_WAITING_FOR_MEMORY:
     1615:  430:          _dbus_verbose (" %s auth state: waiting for memory\n",
branch  0 taken 45% (fallthrough)
branch  1 taken 55%
call    2 returned 100%
        -:  431:                         TRANSPORT_SIDE (transport));
     1615:  432:          oom = TRUE;
     1615:  433:          goto out;
        -:  434:          break;
        -:  435:      
        -:  436:        case DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND:
    56770:  437:          _dbus_verbose (" %s auth state: bytes to send\n",
branch  0 taken 50% (fallthrough)
branch  1 taken 50%
call    2 returned 100%
        -:  438:                         TRANSPORT_SIDE (transport));
    56770:  439:          if (!do_writing || !write_data_from_auth (transport))
branch  0 taken 57% (fallthrough)
branch  1 taken 43%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
        -:  440:            goto out;
    32278:  441:          break;
        -:  442:      
        -:  443:        case DBUS_AUTH_STATE_NEED_DISCONNECT:
     1507:  444:          _dbus_verbose (" %s auth state: need to disconnect\n",
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
call    2 returned 100%
        -:  445:                         TRANSPORT_SIDE (transport));
     1507:  446:          do_io_error (transport);
call    0 returned 100%
     1507:  447:          break;
        -:  448:      
        -:  449:        case DBUS_AUTH_STATE_AUTHENTICATED:
        9:  450:          _dbus_verbose (" %s auth state: authenticated\n",
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
        -:  451:                         TRANSPORT_SIDE (transport));
        -:  452:          break;
        -:  453:        }
        -:  454:    }
        -:  455:
    69560:  456: out:
    69560:  457:  if (auth_completed)
branch  0 taken 56% (fallthrough)
branch  1 taken 44%
    38918:  458:    *auth_completed = (orig_auth_state != _dbus_transport_get_is_authenticated (transport));
call    0 returned 100%
        -:  459:  
    69560:  460:  check_read_watch (transport);
call    0 returned 100%
    69560:  461:  check_write_watch (transport);
call    0 returned 100%
    69560:  462:  _dbus_transport_unref (transport);
call    0 returned 100%
        -:  463:
    69560:  464:  if (oom)
branch  0 taken 2% (fallthrough)
branch  1 taken 98%
     1645:  465:    return FALSE;
        -:  466:  else
    67915:  467:    return TRUE;
        -:  468:}
        -:  469:
        -:  470:/* returns false on oom */
        -:  471:static dbus_bool_t
        -:  472:do_writing (DBusTransport *transport)
function do_writing called 105521 returned 100% blocks executed 72%
   105521:  473:{
        -:  474:  int total;
   105521:  475:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  476:  dbus_bool_t oom;
        -:  477:  
        -:  478:  /* No messages without authentication! */
   105521:  479:  if (!_dbus_transport_get_is_authenticated (transport))
call    0 returned 100%
branch  1 taken 26% (fallthrough)
branch  2 taken 74%
        -:  480:    {
    27715:  481:      _dbus_verbose ("Not authenticated, not writing anything\n");
call    0 returned 100%
    27715:  482:      return TRUE;
        -:  483:    }
        -:  484:
    77806:  485:  if (transport->disconnected)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  486:    {
        3:  487:      _dbus_verbose ("Not connected, not writing anything\n");
call    0 returned 100%
        3:  488:      return TRUE;
        -:  489:    }
        -:  490:
        -:  491:#if 1
    77803:  492:  _dbus_verbose ("do_writing(), have_messages = %d, fd = %d\n",
call    0 returned 100%
call    1 returned 100%
        -:  493:                 _dbus_connection_has_messages_to_send_unlocked (transport->connection),
        -:  494:                 unix_transport->fd);
        -:  495:#endif
        -:  496:  
    77803:  497:  oom = FALSE;
    77803:  498:  total = 0;
        -:  499:
   229551:  500:  while (!transport->disconnected &&
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
branch  3 taken 49%
branch  4 taken 51% (fallthrough)
        -:  501:         _dbus_connection_has_messages_to_send_unlocked (transport->connection))
        -:  502:    {
        -:  503:      int bytes_written;
        -:  504:      DBusMessage *message;
        -:  505:      const DBusString *header;
        -:  506:      const DBusString *body;
        -:  507:      int header_len, body_len;
        -:  508:      int total_bytes_to_write;
        -:  509:      
    73947:  510:      if (total > unix_transport->max_bytes_written_per_iteration)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -:  511:        {
    #####:  512:          _dbus_verbose ("%d bytes exceeds %d bytes written per iteration, returning\n",
call    0 never executed
        -:  513:                         total, unix_transport->max_bytes_written_per_iteration);
    #####:  514:          goto out;
        -:  515:        }
        -:  516:      
    73947:  517:      message = _dbus_connection_get_message_to_send (transport->connection);
call    0 returned 100%
    73947:  518:      _dbus_assert (message != NULL);
call    0 returned 100%
    73947:  519:      _dbus_message_lock (message);
call    0 returned 100%
        -:  520:
        -:  521:#if 0
        -:  522:      _dbus_verbose ("writing message %p\n", message);
        -:  523:#endif
        -:  524:      
    73947:  525:      _dbus_message_get_network_data (message,
call    0 returned 100%
        -:  526:                                      &header, &body);
        -:  527:
    73947:  528:      header_len = _dbus_string_get_length (header);
call    0 returned 100%
    73947:  529:      body_len = _dbus_string_get_length (body);
call    0 returned 100%
        -:  530:
    73947:  531:      if (_dbus_auth_needs_encoding (transport->auth))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  532:        {
    #####:  533:          if (_dbus_string_get_length (&unix_transport->encoded_outgoing) == 0)
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  534:            {
    #####:  535:              if (!_dbus_auth_encode_data (transport->auth,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  536:                                           header, &unix_transport->encoded_outgoing))
        -:  537:                {
    #####:  538:                  oom = TRUE;
    #####:  539:                  goto out;
        -:  540:                }
        -:  541:              
    #####:  542:              if (!_dbus_auth_encode_data (transport->auth,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  543:                                           body, &unix_transport->encoded_outgoing))
        -:  544:                {
    #####:  545:                  _dbus_string_set_length (&unix_transport->encoded_outgoing, 0);
call    0 never executed
    #####:  546:                  oom = TRUE;
    #####:  547:                  goto out;
        -:  548:                }
        -:  549:            }
        -:  550:          
    #####:  551:          total_bytes_to_write = _dbus_string_get_length (&unix_transport->encoded_outgoing);
call    0 never executed
        -:  552:
        -:  553:#if 0
        -:  554:          _dbus_verbose ("encoded message is %d bytes\n",
        -:  555:                         total_bytes_to_write);
        -:  556:#endif
        -:  557:          
    #####:  558:          bytes_written =
call    0 never executed
        -:  559:            _dbus_write (unix_transport->fd,
        -:  560:                         &unix_transport->encoded_outgoing,
        -:  561:                         unix_transport->message_bytes_written,
        -:  562:                         total_bytes_to_write - unix_transport->message_bytes_written);
        -:  563:        }
        -:  564:      else
        -:  565:        {
    73947:  566:          total_bytes_to_write = header_len + body_len;
        -:  567:
        -:  568:#if 0
        -:  569:          _dbus_verbose ("message is %d bytes\n",
        -:  570:                         total_bytes_to_write);          
        -:  571:#endif
        -:  572:          
    73947:  573:          if (unix_transport->message_bytes_written < header_len)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  574:            {
    73947:  575:              bytes_written =
call    0 returned 100%
        -:  576:                _dbus_write_two (unix_transport->fd,
        -:  577:                                 header,
        -:  578:                                 unix_transport->message_bytes_written,
        -:  579:                                 header_len - unix_transport->message_bytes_written,
        -:  580:                                 body,
        -:  581:                                 0, body_len);
        -:  582:            }
        -:  583:          else
        -:  584:            {
    #####:  585:              bytes_written =
call    0 never executed
        -:  586:                _dbus_write (unix_transport->fd,
        -:  587:                             body,
        -:  588:                             (unix_transport->message_bytes_written - header_len),
        -:  589:                             body_len -
        -:  590:                             (unix_transport->message_bytes_written - header_len));
        -:  591:            }
        -:  592:        }
        -:  593:
    73947:  594:      if (bytes_written < 0)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  595:        {
        -:  596:          /* EINTR already handled for us */
        -:  597:          
        2:  598:          if (errno == EAGAIN ||
call    0 returned 100%
branch  1 taken 100% (fallthrough)
branch  2 taken 0%
call    3 returned 100%
branch  4 taken 100% (fallthrough)
branch  5 taken 0%
        -:  599:              errno == EWOULDBLOCK)
        -:  600:            goto out;
        -:  601:          else
        -:  602:            {
        2:  603:              _dbus_verbose ("Error writing to remote app: %s\n",
call    0 returned 100%
call    1 returned 100%
call    2 returned 100%
        -:  604:                             _dbus_strerror (errno));
        2:  605:              do_io_error (transport);
call    0 returned 100%
        2:  606:              goto out;
        -:  607:            }
        -:  608:        }
        -:  609:      else
        -:  610:        {
    73945:  611:          _dbus_verbose (" wrote %d bytes of %d\n", bytes_written,
call    0 returned 100%
        -:  612:                         total_bytes_to_write);
        -:  613:          
    73945:  614:          total += bytes_written;
    73945:  615:          unix_transport->message_bytes_written += bytes_written;
        -:  616:
    73945:  617:          _dbus_assert (unix_transport->message_bytes_written <=
call    0 returned 100%
        -:  618:                        total_bytes_to_write);
        -:  619:          
    73945:  620:          if (unix_transport->message_bytes_written == total_bytes_to_write)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -:  621:            {
    73945:  622:              unix_transport->message_bytes_written = 0;
    73945:  623:              _dbus_string_set_length (&unix_transport->encoded_outgoing, 0);
call    0 returned 100%
        -:  624:
    73945:  625:              _dbus_connection_message_sent (transport->connection,
call    0 returned 100%
        -:  626:                                             message);
        -:  627:            }
        -:  628:        }
        -:  629:    }
        -:  630:
    77803:  631: out:
    77803:  632:  if (oom)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  633:    return FALSE;
        -:  634:  else
    77803:  635:    return TRUE;
        -:  636:}
        -:  637:
        -:  638:/* returns false on out-of-memory */
        -:  639:static dbus_bool_t
        -:  640:do_reading (DBusTransport *transport)
function do_reading called 89651 returned 100% blocks executed 58%
    89651:  641:{
    89651:  642:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  643:  DBusString *buffer;
        -:  644:  int bytes_read;
        -:  645:  int total;
        -:  646:  dbus_bool_t oom;
        -:  647:
    89651:  648:  _dbus_verbose ("%s: fd = %d\n", _DBUS_FUNCTION_NAME,
call    0 returned 100%
        -:  649:                 unix_transport->fd);
        -:  650:  
        -:  651:  /* No messages without authentication! */
    89651:  652:  if (!_dbus_transport_get_is_authenticated (transport))
call    0 returned 100%
branch  1 taken 33% (fallthrough)
branch  2 taken 67%
    29337:  653:    return TRUE;
        -:  654:
    60314:  655:  oom = FALSE;
        -:  656:  
    60314:  657:  total = 0;
        -:  658:
   110679:  659: again:
        -:  660:  
        -:  661:  /* See if we've exceeded max messages and need to disable reading */
   110679:  662:  check_read_watch (transport);
call    0 returned 100%
        -:  663:  
   110679:  664:  if (total > unix_transport->max_bytes_read_per_iteration)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        -:  665:    {
        1:  666:      _dbus_verbose ("%d bytes exceeds %d bytes read per iteration, returning\n",
call    0 returned 100%
        -:  667:                     total, unix_transport->max_bytes_read_per_iteration);
        1:  668:      goto out;
        -:  669:    }
        -:  670:
   110678:  671:  _dbus_assert (unix_transport->read_watch != NULL ||
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
branch  2 never executed
branch  3 never executed
call    4 returned 100%
        -:  672:                transport->disconnected);
        -:  673:  
   110678:  674:  if (transport->disconnected)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
    #####:  675:    goto out;
        -:  676:
   110678:  677:  if (!dbus_watch_get_enabled (unix_transport->read_watch))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  678:    return TRUE;
        -:  679:  
   110678:  680:  if (_dbus_auth_needs_decoding (transport->auth))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  681:    {
    #####:  682:      if (_dbus_string_get_length (&unix_transport->encoded_incoming) > 0)
call    0 never executed
branch  1 never executed
branch  2 never executed
    #####:  683:        bytes_read = _dbus_string_get_length (&unix_transport->encoded_incoming);
call    0 never executed
        -:  684:      else
    #####:  685:        bytes_read = _dbus_read (unix_transport->fd,
call    0 never executed
        -:  686:                                 &unix_transport->encoded_incoming,
        -:  687:                                 unix_transport->max_bytes_read_per_iteration);
        -:  688:
    #####:  689:      _dbus_assert (_dbus_string_get_length (&unix_transport->encoded_incoming) ==
call    0 never executed
call    1 never executed
        -:  690:                    bytes_read);
        -:  691:      
    #####:  692:      if (bytes_read > 0)
branch  0 never executed
branch  1 never executed
        -:  693:        {
        -:  694:          int orig_len;
        -:  695:          
    #####:  696:          _dbus_message_loader_get_buffer (transport->loader,
call    0 never executed
        -:  697:                                           &buffer);
        -:  698:
    #####:  699:          orig_len = _dbus_string_get_length (buffer);
call    0 never executed
        -:  700:          
    #####:  701:          if (!_dbus_auth_decode_data (transport->auth,
call    0 never executed
branch  1 never executed
branch  2 never executed
        -:  702:                                       &unix_transport->encoded_incoming,
        -:  703:                                       buffer))
        -:  704:            {
    #####:  705:              _dbus_verbose ("Out of memory decoding incoming data\n");
call    0 never executed
    #####:  706:              oom = TRUE;
    #####:  707:              goto out;
        -:  708:            }
        -:  709:
    #####:  710:          _dbus_message_loader_return_buffer (transport->loader,
call    0 never executed
call    1 never executed
        -:  711:                                              buffer,
        -:  712:                                              _dbus_string_get_length (buffer) - orig_len);
        -:  713:
    #####:  714:          _dbus_string_set_length (&unix_transport->encoded_incoming, 0);
call    0 never executed
        -:  715:        }
        -:  716:    }
        -:  717:  else
        -:  718:    {
   110678:  719:      _dbus_message_loader_get_buffer (transport->loader,
call    0 returned 100%
        -:  720:                                       &buffer);
        -:  721:      
   110678:  722:      bytes_read = _dbus_read (unix_transport->fd,
call    0 returned 100%
        -:  723:                               buffer, unix_transport->max_bytes_read_per_iteration);
        -:  724:      
   110678:  725:      _dbus_message_loader_return_buffer (transport->loader,
call    0 returned 100%
        -:  726:                                          buffer,
        -:  727:                                          bytes_read < 0 ? 0 : bytes_read);
        -:  728:    }
        -:  729:  
   110678:  730:  if (bytes_read < 0)
branch  0 taken 46% (fallthrough)
branch  1 taken 54%
        -:  731:    {
        -:  732:      /* EINTR already handled for us */
        -:  733:
    50755:  734:      if (errno == ENOMEM)
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  735:        {
      486:  736:          _dbus_verbose ("Out of memory in read()/do_reading()\n");
call    0 returned 100%
      486:  737:          oom = TRUE;
      486:  738:          goto out;
        -:  739:        }
    50269:  740:      else if (errno == EAGAIN ||
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
call    3 never executed
branch  4 never executed
branch  5 never executed
        -:  741:               errno == EWOULDBLOCK)
        -:  742:        goto out;
        -:  743:      else
        -:  744:        {
    #####:  745:          _dbus_verbose ("Error reading from remote app: %s\n",
call    0 never executed
call    1 never executed
call    2 never executed
        -:  746:                         _dbus_strerror (errno));
    #####:  747:          do_io_error (transport);
call    0 never executed
    #####:  748:          goto out;
        -:  749:        }
        -:  750:    }
    59923:  751:  else if (bytes_read == 0)
branch  0 taken 10% (fallthrough)
branch  1 taken 90%
        -:  752:    {
     6206:  753:      _dbus_verbose ("Disconnected from remote app\n");
call    0 returned 100%
     6206:  754:      do_io_error (transport);
call    0 returned 100%
     6206:  755:      goto out;
        -:  756:    }
        -:  757:  else
        -:  758:    {
    53717:  759:      _dbus_verbose (" read %d bytes\n", bytes_read);
call    0 returned 100%
        -:  760:      
    53717:  761:      total += bytes_read;      
        -:  762:
    53717:  763:      if (!_dbus_transport_queue_messages (transport))
call    0 returned 100%
branch  1 taken 6% (fallthrough)
branch  2 taken 94%
        -:  764:        {
     3352:  765:          oom = TRUE;
     3352:  766:          _dbus_verbose (" out of memory when queueing messages we just read in the transport\n");
call    0 returned 100%
     3352:  767:          goto out;
        -:  768:        }
        -:  769:      
        -:  770:      /* Try reading more data until we get EAGAIN and return, or
        -:  771:       * exceed max bytes per iteration.  If in blocking mode of
        -:  772:       * course we'll block instead of returning.
        -:  773:       */
    50365:  774:      goto again;
        -:  775:    }
        -:  776:
    60314:  777: out:
    60314:  778:  if (oom)
branch  0 taken 6% (fallthrough)
branch  1 taken 94%
     3838:  779:    return FALSE;
        -:  780:  else
    56476:  781:    return TRUE;
        -:  782:}
        -:  783:
        -:  784:static dbus_bool_t
        -:  785:unix_handle_watch (DBusTransport *transport,
        -:  786:                   DBusWatch     *watch,
        -:  787:                   unsigned int   flags)
function unix_handle_watch called 126115 returned 100% blocks executed 79%
   126115:  788:{
   126115:  789:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  790:
   126115:  791:  _dbus_assert (watch == unix_transport->read_watch ||
branch  0 taken 24% (fallthrough)
branch  1 taken 76%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
call    4 returned 100%
        -:  792:                watch == unix_transport->write_watch);
   126115:  793:  _dbus_assert (watch != NULL);
call    0 returned 100%
        -:  794:  
        -:  795:  /* Disconnect in case of an error.  In case of hangup do not
        -:  796:   * disconnect the transport because data can still be in the buffer
        -:  797:   * and do_reading may need several iteration to read it all (because
        -:  798:   * of its max_bytes_read_per_iteration limit).  The condition where
        -:  799:   * flags == HANGUP (without READABLE) probably never happen in fact.
        -:  800:   */
   126115:  801:  if ((flags & DBUS_WATCH_ERROR) ||
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 6% (fallthrough)
branch  3 taken 94%
branch  4 taken 1% (fallthrough)
branch  5 taken 99%
        -:  802:      ((flags & DBUS_WATCH_HANGUP) && !(flags & DBUS_WATCH_READABLE)))
        -:  803:    {
       36:  804:      _dbus_verbose ("Hang up or error on watch\n");
call    0 returned 100%
       36:  805:      _dbus_transport_disconnect (transport);
call    0 returned 100%
       36:  806:      return TRUE;
        -:  807:    }
        -:  808:  
   216033:  809:  if (watch == unix_transport->read_watch &&
branch  0 taken 76% (fallthrough)
branch  1 taken 24%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
        -:  810:      (flags & DBUS_WATCH_READABLE))
        -:  811:    {
        -:  812:      dbus_bool_t auth_finished;
        -:  813:#if 1
    95437:  814:      _dbus_verbose ("handling read watch %p flags = %x\n",
call    0 returned 100%
        -:  815:                     watch, flags);
        -:  816:#endif
    95437:  817:      if (!do_authentication (transport, TRUE, FALSE, &auth_finished))
call    0 returned 100%
branch  1 taken 2% (fallthrough)
branch  2 taken 98%
     1645:  818:        return FALSE;
        -:  819:
        -:  820:      /* We don't want to do a read immediately following
        -:  821:       * a successful authentication.  This is so we
        -:  822:       * have a chance to propagate the authentication
        -:  823:       * state further up.  Specifically, we need to
        -:  824:       * process any pending data from the auth object.
        -:  825:       */
    93792:  826:      if (!auth_finished)
branch  0 taken 93% (fallthrough)
branch  1 taken 7%
        -:  827:	{
    87601:  828:	  if (!do_reading (transport))
call    0 returned 100%
branch  1 taken 4% (fallthrough)
branch  2 taken 96%
        -:  829:	    {
     3838:  830:	      _dbus_verbose ("no memory to read\n");
call    0 returned 100%
     3838:  831:	      return FALSE;
        -:  832:	    }
        -:  833:	}
        -:  834:      else
        -:  835:        {
     6191:  836:          _dbus_verbose ("Not reading anything since we just completed the authentication\n");
call    0 returned 100%
        -:  837:        }
        -:  838:    }
    61284:  839:  else if (watch == unix_transport->write_watch &&
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
        -:  840:           (flags & DBUS_WATCH_WRITABLE))
        -:  841:    {
        -:  842:#if 1
    30642:  843:      _dbus_verbose ("handling write watch, have_outgoing_messages = %d\n",
call    0 returned 100%
call    1 returned 100%
        -:  844:                     _dbus_connection_has_messages_to_send_unlocked (transport->connection));
        -:  845:#endif
    30642:  846:      if (!do_authentication (transport, FALSE, TRUE, NULL))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
    #####:  847:        return FALSE;
        -:  848:      
    30642:  849:      if (!do_writing (transport))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -:  850:        {
    #####:  851:          _dbus_verbose ("no memory to write\n");
call    0 never executed
    #####:  852:          return FALSE;
        -:  853:        }
        -:  854:
        -:  855:      /* See if we still need the write watch */
    30642:  856:      check_write_watch (transport);
call    0 returned 100%
        -:  857:    }
        -:  858:#ifdef DBUS_ENABLE_VERBOSE_MODE
        -:  859:  else
        -:  860:    {
    #####:  861:      if (watch == unix_transport->read_watch)
branch  0 never executed
branch  1 never executed
    #####:  862:        _dbus_verbose ("asked to handle read watch with non-read condition 0x%x\n",
call    0 never executed
        -:  863:                       flags);
    #####:  864:      else if (watch == unix_transport->write_watch)
branch  0 never executed
branch  1 never executed
    #####:  865:        _dbus_verbose ("asked to handle write watch with non-write condition 0x%x\n",
call    0 never executed
        -:  866:                       flags);
        -:  867:      else
    #####:  868:        _dbus_verbose ("asked to handle watch %p on fd %d that we don't recognize\n",
call    0 never executed
call    1 never executed
        -:  869:                       watch, dbus_watch_get_fd (watch));
        -:  870:    }
        -:  871:#endif /* DBUS_ENABLE_VERBOSE_MODE */
        -:  872:
   120596:  873:  return TRUE;
        -:  874:}
        -:  875:
        -:  876:static void
        -:  877:unix_disconnect (DBusTransport *transport)
function unix_disconnect called 14225 returned 100% blocks executed 100%
    14225:  878:{
    14225:  879:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  880:
    14225:  881:  _dbus_verbose ("%s\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
        -:  882:  
    14225:  883:  free_watches (transport);
call    0 returned 100%
        -:  884:  
    14225:  885:  _dbus_close (unix_transport->fd, NULL);
call    0 returned 100%
    14225:  886:  unix_transport->fd = -1;
    14225:  887:}
        -:  888:
        -:  889:static dbus_bool_t
        -:  890:unix_connection_set (DBusTransport *transport)
function unix_connection_set called 14278 returned 100% blocks executed 100%
    14278:  891:{
    14278:  892:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  893:
    14278:  894:  _dbus_watch_set_handler (unix_transport->write_watch,
call    0 returned 100%
        -:  895:                           _dbus_connection_handle_watch,
        -:  896:                           transport->connection, NULL);
        -:  897:
    14278:  898:  _dbus_watch_set_handler (unix_transport->read_watch,
call    0 returned 100%
        -:  899:                           _dbus_connection_handle_watch,
        -:  900:                           transport->connection, NULL);
        -:  901:  
    14278:  902:  if (!_dbus_connection_add_watch_unlocked (transport->connection,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  903:                                            unix_transport->write_watch))
       13:  904:    return FALSE;
        -:  905:
    14265:  906:  if (!_dbus_connection_add_watch_unlocked (transport->connection,
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
        -:  907:                                            unix_transport->read_watch))
        -:  908:    {
       11:  909:      _dbus_connection_remove_watch_unlocked (transport->connection,
call    0 returned 100%
        -:  910:                                              unix_transport->write_watch);
       11:  911:      return FALSE;
        -:  912:    }
        -:  913:
    14254:  914:  check_read_watch (transport);
call    0 returned 100%
    14254:  915:  check_write_watch (transport);
call    0 returned 100%
        -:  916:
    14254:  917:  return TRUE;
        -:  918:}
        -:  919:
        -:  920:/**
        -:  921: * @todo We need to have a way to wake up the select sleep if
        -:  922: * a new iteration request comes in with a flag (read/write) that
        -:  923: * we're not currently serving. Otherwise a call that just reads
        -:  924: * could block a write call forever (if there are no incoming
        -:  925: * messages).
        -:  926: */
        -:  927:static  void
        -:  928:unix_do_iteration (DBusTransport *transport,
        -:  929:                   unsigned int   flags,
        -:  930:                   int            timeout_milliseconds)
function unix_do_iteration called 77746 returned 100% blocks executed 91%
    77746:  931:{
    77746:  932:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -:  933:  DBusPollFD poll_fd;
        -:  934:  int poll_res;
        -:  935:  int poll_timeout;
        -:  936:
    77746:  937:  _dbus_verbose (" iteration flags = %s%s timeout = %d read_watch = %p write_watch = %p fd = %d\n",
branch  0 taken 98% (fallthrough)
branch  1 taken 2%
branch  2 taken 5% (fallthrough)
branch  3 taken 95%
call    4 returned 100%
        -:  938:                 flags & DBUS_ITERATION_DO_READING ? "read" : "",
        -:  939:                 flags & DBUS_ITERATION_DO_WRITING ? "write" : "",
        -:  940:                 timeout_milliseconds,
        -:  941:                 unix_transport->read_watch,
        -:  942:                 unix_transport->write_watch,
        -:  943:                 unix_transport->fd);
        -:  944:  
        -:  945:  /* the passed in DO_READING/DO_WRITING flags indicate whether to
        -:  946:   * read/write messages, but regardless of those we may need to block
        -:  947:   * for reading/writing to do auth.  But if we do reading for auth,
        -:  948:   * we don't want to read any messages yet if not given DO_READING.
        -:  949:   */
        -:  950:
    77746:  951:  poll_fd.fd = unix_transport->fd;
    77746:  952:  poll_fd.events = 0;
        -:  953:  
    77746:  954:  if (_dbus_transport_get_is_authenticated (transport))
call    0 returned 100%
branch  1 taken 97% (fallthrough)
branch  2 taken 3%
        -:  955:    {
        -:  956:      /* This is kind of a hack; if we have stuff to write, then try
        -:  957:       * to avoid the poll. This is probably about a 5% speedup on an
        -:  958:       * echo client/server.
        -:  959:       *
        -:  960:       * If both reading and writing were requested, we want to avoid this
        -:  961:       * since it could have funky effects:
        -:  962:       *   - both ends spinning waiting for the other one to read
        -:  963:       *     data so they can finish writing
        -:  964:       *   - prioritizing all writing ahead of reading
        -:  965:       */
    75181:  966:      if ((flags & DBUS_ITERATION_DO_WRITING) &&
branch  0 taken 98% (fallthrough)
branch  1 taken 2%
branch  2 taken 99% (fallthrough)
branch  3 taken 1%
branch  4 taken 100% (fallthrough)
branch  5 taken 0%
call    6 returned 100%
branch  7 taken 100% (fallthrough)
branch  8 taken 0%
        -:  967:          !(flags & (DBUS_ITERATION_DO_READING | DBUS_ITERATION_BLOCK)) &&
        -:  968:          !transport->disconnected &&
        -:  969:          _dbus_connection_has_messages_to_send_unlocked (transport->connection))
        -:  970:        {
    73134:  971:          do_writing (transport);
call    0 returned 100%
        -:  972:
    73134:  973:          if (transport->disconnected ||
branch  0 taken 99% (fallthrough)
branch  1 taken 1%
call    2 returned 100%
branch  3 taken 0% (fallthrough)
branch  4 taken 100%
        -:  974:              !_dbus_connection_has_messages_to_send_unlocked (transport->connection))
        -:  975:            goto out;
        -:  976:        }
        -:  977:
        -:  978:      /* If we get here, we decided to do the poll() after all */
     2047:  979:      _dbus_assert (unix_transport->read_watch);
call    0 returned 100%
     2047:  980:      if (flags & DBUS_ITERATION_DO_READING)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
     2047:  981:	poll_fd.events |= _DBUS_POLLIN;
        -:  982:
     2047:  983:      _dbus_assert (unix_transport->write_watch);
call    0 returned 100%
     2047:  984:      if (flags & DBUS_ITERATION_DO_WRITING)
branch  0 taken 40% (fallthrough)
branch  1 taken 60%
      816:  985:        poll_fd.events |= _DBUS_POLLOUT;
        -:  986:    }
        -:  987:  else
        -:  988:    {
        -:  989:      DBusAuthState auth_state;
        -:  990:      
     2565:  991:      auth_state = _dbus_auth_do_work (transport->auth);
call    0 returned 100%
        -:  992:
     2565:  993:      if (transport->receive_credentials_pending ||
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
branch  2 taken 32% (fallthrough)
branch  3 taken 68%
        -:  994:          auth_state == DBUS_AUTH_STATE_WAITING_FOR_INPUT)
      820:  995:	poll_fd.events |= _DBUS_POLLIN;
        -:  996:
     2565:  997:      if (transport->send_credentials_pending ||
branch  0 taken 64% (fallthrough)
branch  1 taken 36%
branch  2 taken 50% (fallthrough)
branch  3 taken 50%
        -:  998:          auth_state == DBUS_AUTH_STATE_HAVE_BYTES_TO_SEND)
     1745:  999:	poll_fd.events |= _DBUS_POLLOUT;
        -: 1000:    }
        -: 1001:
     4612: 1002:  if (poll_fd.events)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 1003:    {
     4612: 1004:      if (flags & DBUS_ITERATION_BLOCK)
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
     3683: 1005:	poll_timeout = timeout_milliseconds;
        -: 1006:      else
      929: 1007:	poll_timeout = 0;
        -: 1008:
        -: 1009:      /* For blocking selects we drop the connection lock here
        -: 1010:       * to avoid blocking out connection access during a potentially
        -: 1011:       * indefinite blocking call. The io path is still protected
        -: 1012:       * by the io_path_cond condvar, so we won't reenter this.
        -: 1013:       */
     4612: 1014:      if (flags & DBUS_ITERATION_BLOCK)
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
        -: 1015:        {
     3683: 1016:          _dbus_verbose ("unlock %s pre poll\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
     3683: 1017:          _dbus_connection_unlock (transport->connection);
call    0 returned 100%
        -: 1018:        }
        -: 1019:      
     4612: 1020:    again:
     4612: 1021:      poll_res = _dbus_poll (&poll_fd, 1, poll_timeout);
call    0 returned 100%
        -: 1022:
     4612: 1023:      if (poll_res < 0 && errno == EINTR)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
call    2 never executed
branch  3 never executed
branch  4 never executed
    #####: 1024:	goto again;
        -: 1025:
     4612: 1026:      if (flags & DBUS_ITERATION_BLOCK)
branch  0 taken 80% (fallthrough)
branch  1 taken 20%
        -: 1027:        {
     3683: 1028:          _dbus_verbose ("lock %s post poll\n", _DBUS_FUNCTION_NAME);
call    0 returned 100%
     3683: 1029:          _dbus_connection_lock (transport->connection);
call    0 returned 100%
        -: 1030:        }
        -: 1031:      
     4612: 1032:      if (poll_res >= 0)
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
        -: 1033:        {
     4612: 1034:          if (poll_fd.revents & _DBUS_POLLERR)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
        4: 1035:            do_io_error (transport);
call    0 returned 100%
        -: 1036:          else
        -: 1037:            {
     4608: 1038:              dbus_bool_t need_read = (poll_fd.revents & _DBUS_POLLIN) > 0;
     4608: 1039:              dbus_bool_t need_write = (poll_fd.revents & _DBUS_POLLOUT) > 0;
        -: 1040:	      dbus_bool_t authentication_completed;
        -: 1041:
     4608: 1042:              _dbus_verbose ("in iteration, need_read=%d need_write=%d\n",
call    0 returned 100%
        -: 1043:                             need_read, need_write);
     4608: 1044:              do_authentication (transport, need_read, need_write,
call    0 returned 100%
        -: 1045:				 &authentication_completed);
        -: 1046:
        -: 1047:	      /* See comment in unix_handle_watch. */
     4608: 1048:	      if (authentication_completed)
branch  0 taken 18% (fallthrough)
branch  1 taken 82%
      816: 1049:                goto out;
        -: 1050:                                 
     3792: 1051:              if (need_read && (flags & DBUS_ITERATION_DO_READING))
branch  0 taken 54% (fallthrough)
branch  1 taken 46%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
     2050: 1052:                do_reading (transport);
call    0 returned 100%
     3792: 1053:              if (need_write && (flags & DBUS_ITERATION_DO_WRITING))
branch  0 taken 46% (fallthrough)
branch  1 taken 54%
branch  2 taken 100% (fallthrough)
branch  3 taken 0%
     1745: 1054:                do_writing (transport);
call    0 returned 100%
        -: 1055:            }
        -: 1056:        }
        -: 1057:      else
        -: 1058:        {
    #####: 1059:          _dbus_verbose ("Error from _dbus_poll(): %s\n",
call    0 never executed
call    1 never executed
call    2 never executed
        -: 1060:                         _dbus_strerror (errno));
        -: 1061:        }
        -: 1062:    }
        -: 1063:
        -: 1064:
    77746: 1065: out:
        -: 1066:  /* We need to install the write watch only if we did not
        -: 1067:   * successfully write everything. Note we need to be careful that we
        -: 1068:   * don't call check_write_watch *before* do_writing, since it's
        -: 1069:   * inefficient to add the write watch, and we can avoid it most of
        -: 1070:   * the time since we can write immediately.
        -: 1071:   * 
        -: 1072:   * However, we MUST always call check_write_watch(); DBusConnection code
        -: 1073:   * relies on the fact that running an iteration will notice that
        -: 1074:   * messages are pending.
        -: 1075:   */
    77746: 1076:  check_write_watch (transport);
call    0 returned 100%
        -: 1077:
    77746: 1078:  _dbus_verbose (" ... leaving do_iteration()\n");
call    0 returned 100%
    77746: 1079:}
        -: 1080:
        -: 1081:static void
        -: 1082:unix_live_messages_changed (DBusTransport *transport)
function unix_live_messages_changed called 0 returned 0% blocks executed 0%
    #####: 1083:{
        -: 1084:  /* See if we should look for incoming messages again */
    #####: 1085:  check_read_watch (transport);
call    0 never executed
    #####: 1086:}
        -: 1087:
        -: 1088:
        -: 1089:static dbus_bool_t
        -: 1090:unix_get_unix_fd (DBusTransport *transport,
        -: 1091:                  int           *fd_p)
function unix_get_unix_fd called 1 returned 100% blocks executed 100%
        1: 1092:{
        1: 1093:  DBusTransportUnix *unix_transport = (DBusTransportUnix*) transport;
        -: 1094:  
        1: 1095:  *fd_p = unix_transport->fd;
        -: 1096:
        1: 1097:  return TRUE;
        -: 1098:}
        -: 1099:
        -: 1100:static const DBusTransportVTable unix_vtable = {
        -: 1101:  unix_finalize,
        -: 1102:  unix_handle_watch,
        -: 1103:  unix_disconnect,
        -: 1104:  unix_connection_set,
        -: 1105:  unix_do_iteration,
        -: 1106:  unix_live_messages_changed,
        -: 1107:  unix_get_unix_fd
        -: 1108:};
        -: 1109:
        -: 1110:/**
        -: 1111: * Creates a new transport for the given file descriptor.  The file
        -: 1112: * descriptor must be nonblocking (use _dbus_set_fd_nonblocking() to
        -: 1113: * make it so). This function is shared by various transports that
        -: 1114: * boil down to a full duplex file descriptor.
        -: 1115: *
        -: 1116: * @param fd the file descriptor.
        -: 1117: * @param server_guid non-#NULL if this transport is on the server side of a connection
        -: 1118: * @param address the transport's address
        -: 1119: * @returns the new transport, or #NULL if no memory.
        -: 1120: */
        -: 1121:DBusTransport*
        -: 1122:_dbus_transport_new_for_fd (int               fd,
        -: 1123:                            const DBusString *server_guid,
        -: 1124:                            const DBusString *address)
function _dbus_transport_new_for_fd called 14998 returned 100% blocks executed 100%
    14998: 1125:{
        -: 1126:  DBusTransportUnix *unix_transport;
        -: 1127:  
    14998: 1128:  unix_transport = dbus_new0 (DBusTransportUnix, 1);
call    0 returned 100%
    14998: 1129:  if (unix_transport == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       15: 1130:    return NULL;
        -: 1131:
    14983: 1132:  if (!_dbus_string_init (&unix_transport->encoded_outgoing))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
       15: 1133:    goto failed_0;
        -: 1134:
    14968: 1135:  if (!_dbus_string_init (&unix_transport->encoded_incoming))
call    0 returned 100%
branch  1 taken 1% (fallthrough)
branch  2 taken 99%
       15: 1136:    goto failed_1;
        -: 1137:  
    14953: 1138:  unix_transport->write_watch = _dbus_watch_new (fd,
call    0 returned 100%
        -: 1139:                                                 DBUS_WATCH_WRITABLE,
        -: 1140:                                                 FALSE,
        -: 1141:                                                 NULL, NULL, NULL);
    14953: 1142:  if (unix_transport->write_watch == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       15: 1143:    goto failed_2;
        -: 1144:  
    14938: 1145:  unix_transport->read_watch = _dbus_watch_new (fd,
call    0 returned 100%
        -: 1146:                                                DBUS_WATCH_READABLE,
        -: 1147:                                                FALSE,
        -: 1148:                                                NULL, NULL, NULL);
    14938: 1149:  if (unix_transport->read_watch == NULL)
branch  0 taken 1% (fallthrough)
branch  1 taken 99%
       15: 1150:    goto failed_3;
        -: 1151:  
    14923: 1152:  if (!_dbus_transport_init_base (&unix_transport->base,
call    0 returned 100%
branch  1 taken 98% (fallthrough)
branch  2 taken 2%
        -: 1153:                                  &unix_vtable,
        -: 1154:                                  server_guid, address))
      282: 1155:    goto failed_4;
        -: 1156:  
    14641: 1157:  unix_transport->fd = fd;
    14641: 1158:  unix_transport->message_bytes_written = 0;
        -: 1159:  
        -: 1160:  /* These values should probably be tunable or something. */     
    14641: 1161:  unix_transport->max_bytes_read_per_iteration = 2048;
    14641: 1162:  unix_transport->max_bytes_written_per_iteration = 2048;
        -: 1163:  
    14641: 1164:  return (DBusTransport*) unix_transport;
        -: 1165:
      282: 1166: failed_4:
      282: 1167:  _dbus_watch_unref (unix_transport->read_watch);
call    0 returned 100%
      297: 1168: failed_3:
      297: 1169:  _dbus_watch_unref (unix_transport->write_watch);
call    0 returned 100%
      312: 1170: failed_2:
      312: 1171:  _dbus_string_free (&unix_transport->encoded_incoming);
call    0 returned 100%
      327: 1172: failed_1:
      327: 1173:  _dbus_string_free (&unix_transport->encoded_outgoing);
call    0 returned 100%
      342: 1174: failed_0:
      342: 1175:  dbus_free (unix_transport);
call    0 returned 100%
      342: 1176:  return NULL;
        -: 1177:}
        -: 1178:
        -: 1179:/**
        -: 1180: * Creates a new transport for the given Unix domain socket
        -: 1181: * path. This creates a client-side of a transport.
        -: 1182: *
        -: 1183: * @todo once we add a way to escape paths in a dbus
        -: 1184: * address, this function needs to do escaping.
        -: 1185: *
        -: 1186: * @param path the path to the domain socket.
        -: 1187: * @param abstract #TRUE to use abstract socket namespace
        -: 1188: * @param error address where an error can be returned.
        -: 1189: * @returns a new transport, or #NULL on failure.
        -: 1190: */
        -: 1191:DBusTransport*
        -: 1192:_dbus_transport_new_for_domain_socket (const char     *path,
        -: 1193:                                       dbus_bool_t     abstract,
        -: 1194:                                       DBusError      *error)
function _dbus_transport_new_for_domain_socket called 929 returned 100% blocks executed 54%
      929: 1195:{
        -: 1196:  int fd;
        -: 1197:  DBusTransport *transport;
        -: 1198:  DBusString address;
        -: 1199:  
      929: 1200:  _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%
        -: 1201:
      929: 1202:  if (!_dbus_string_init (&address))
call    0 returned 100%
branch  1 taken 0% (fallthrough)
branch  2 taken 100%
        -: 1203:    {
    #####: 1204:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1205:      return NULL;
        -: 1206:    }
        -: 1207:
      929: 1208:  fd = -1;
        -: 1209:
      929: 1210:  if ((abstract &&
branch  0 taken 100% (fallthrough)
branch  1 taken 0%
call    2 returned 100%
branch  3 taken 100% (fallthrough)
branch  4 taken 0%
branch  5 taken 0% (fallthrough)
branch  6 taken 100%
call    7 never executed
branch  8 never executed
branch  9 never executed
call   10 returned 100%
branch 11 taken 0% (fallthrough)
branch 12 taken 100%
        -: 1211:       !_dbus_string_append (&address, "unix:abstract=")) ||
        -: 1212:      (!abstract &&
        -: 1213:       !_dbus_string_append (&address, "unix:path=")) ||
        -: 1214:      !_dbus_string_append (&address, path))
        -: 1215:    {
    #####: 1216:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1217:      goto failed_0;
        -: 1218:    }
        -: 1219:  
      929: 1220:  fd = _dbus_connect_unix_socket (path, abstract, error);
call    0 returned 100%
      929: 1221:  if (fd < 0)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1222:    {
    #####: 1223:      _DBUS_ASSERT_ERROR_IS_SET (error);
branch  0 never executed
branch  1 never executed
call    2 never executed
branch  3 never executed
branch  4 never executed
call    5 never executed
    #####: 1224:      goto failed_0;
        -: 1225:    }
        -: 1226:
      929: 1227:  _dbus_fd_set_close_on_exec (fd);
call    0 returned 100%
        -: 1228:  
      929: 1229:  _dbus_verbose ("Successfully connected to unix socket %s\n",
call    0 returned 100%
        -: 1230:                 path);
        -: 1231:
      929: 1232:  transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
call    0 returned 100%
      929: 1233:  if (transport == NULL)
branch  0 taken 0% (fallthrough)
branch  1 taken 100%
        -: 1234:    {
    #####: 1235:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1236:      goto failed_1;
        -: 1237:    }
        -: 1238:  
      929: 1239:  _dbus_string_free (&address);
call    0 returned 100%
        -: 1240:  
      929: 1241:  return transport;
        -: 1242:
    #####: 1243: failed_1:
    #####: 1244:  _dbus_close (fd, NULL);
call    0 never executed
    #####: 1245: failed_0:
    #####: 1246:  _dbus_string_free (&address);
call    0 never executed
    #####: 1247:  return NULL;
        -: 1248:}
        -: 1249:
        -: 1250:/**
        -: 1251: * Creates a new transport for the given hostname and port.
        -: 1252: *
        -: 1253: * @param host the host to connect to
        -: 1254: * @param port the port to connect to
        -: 1255: * @param error location to store reason for failure.
        -: 1256: * @returns a new transport, or #NULL on failure.
        -: 1257: */
        -: 1258:DBusTransport*
        -: 1259:_dbus_transport_new_for_tcp_socket (const char     *host,
        -: 1260:                                    dbus_int32_t    port,
        -: 1261:                                    DBusError      *error)
function _dbus_transport_new_for_tcp_socket called 0 returned 0% blocks executed 0%
    #####: 1262:{
        -: 1263:  int fd;
        -: 1264:  DBusTransport *transport;
        -: 1265:  DBusString address;
        -: 1266:  
    #####: 1267:  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
branch  0 never executed
branch  1 never executed
call    2 never executed
branch  3 never executed
branch  4 never executed
call    5 never executed
        -: 1268:
    #####: 1269:  if (!_dbus_string_init (&address))
call    0 never executed
branch  1 never executed
branch  2 never executed
        -: 1270:    {
    #####: 1271:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1272:      return NULL;
        -: 1273:    }
        -: 1274:  
    #####: 1275:  if (!_dbus_string_append (&address, "tcp:host=") ||
call    0 never executed
branch  1 never executed
branch  2 never executed
call    3 never executed
branch  4 never executed
branch  5 never executed
call    6 never executed
branch  7 never executed
branch  8 never executed
call    9 never executed
branch 10 never executed
branch 11 never executed
        -: 1276:      !_dbus_string_append (&address, host) ||
        -: 1277:      !_dbus_string_append (&address, ",port=") ||
        -: 1278:      !_dbus_string_append_int (&address, port))
        -: 1279:    {
    #####: 1280:      _dbus_string_free (&address);
call    0 never executed
    #####: 1281:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1282:      return NULL;
        -: 1283:    }
        -: 1284:  
    #####: 1285:  fd = _dbus_connect_tcp_socket (host, port, error);
call    0 never executed
    #####: 1286:  if (fd < 0)
branch  0 never executed
branch  1 never executed
        -: 1287:    {
    #####: 1288:      _DBUS_ASSERT_ERROR_IS_SET (error);
branch  0 never executed
branch  1 never executed
call    2 never executed
branch  3 never executed
branch  4 never executed
call    5 never executed
    #####: 1289:      _dbus_string_free (&address);
call    0 never executed
    #####: 1290:      return NULL;
        -: 1291:    }
        -: 1292:
    #####: 1293:  _dbus_fd_set_close_on_exec (fd);
call    0 never executed
        -: 1294:  
    #####: 1295:  _dbus_verbose ("Successfully connected to tcp socket %s:%d\n",
call    0 never executed
        -: 1296:                 host, port);
        -: 1297:  
    #####: 1298:  transport = _dbus_transport_new_for_fd (fd, FALSE, &address);
call    0 never executed
    #####: 1299:  if (transport == NULL)
branch  0 never executed
branch  1 never executed
        -: 1300:    {
    #####: 1301:      dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
call    0 never executed
    #####: 1302:      _dbus_close (fd, NULL);
call    0 never executed
    #####: 1303:      _dbus_string_free (&address);
call    0 never executed
    #####: 1304:      fd = -1;
        -: 1305:    }
        -: 1306:
    #####: 1307:  _dbus_string_free (&address);
call    0 never executed
        -: 1308:  
    #####: 1309:  return transport;
        -: 1310:}
        -: 1311:
        -: 1312:/** @} */
        -: 1313: