diff options
Diffstat (limited to 'dbus/dbus-transport-socket.c')
-rw-r--r-- | dbus/dbus-transport-socket.c | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 0673a8ce..774f4598 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -135,7 +135,7 @@ check_write_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) needed = _dbus_connection_has_messages_to_send_unlocked (transport->connection); else { @@ -190,7 +190,7 @@ check_read_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) need_read_watch = (_dbus_counter_get_size_value (transport->live_messages) < transport->max_live_messages_size) && (_dbus_counter_get_unix_fd_value (transport->live_messages) < transport->max_live_messages_unix_fds); @@ -255,8 +255,7 @@ read_data_into_auth (DBusTransport *transport, bytes_read = _dbus_read_socket (socket_transport->fd, buffer, socket_transport->max_bytes_read_per_iteration); - _dbus_auth_return_buffer (transport->auth, buffer, - bytes_read > 0 ? bytes_read : 0); + _dbus_auth_return_buffer (transport->auth, buffer); if (bytes_read > 0) { @@ -404,7 +403,7 @@ do_authentication (DBusTransport *transport, oom = FALSE; - orig_auth_state = _dbus_transport_get_is_authenticated (transport); + orig_auth_state = _dbus_transport_try_to_authenticate (transport); /* This is essential to avoid the check_write_watch() at the end, * we don't want to add a write watch in do_iteration before @@ -419,7 +418,7 @@ do_authentication (DBusTransport *transport, _dbus_transport_ref (transport); - while (!_dbus_transport_get_is_authenticated (transport) && + while (!_dbus_transport_try_to_authenticate (transport) && _dbus_transport_get_is_connected (transport)) { if (!exchange_credentials (transport, do_reading, do_writing)) @@ -477,7 +476,7 @@ do_authentication (DBusTransport *transport, out: if (auth_completed) - *auth_completed = (orig_auth_state != _dbus_transport_get_is_authenticated (transport)); + *auth_completed = (orig_auth_state != _dbus_transport_try_to_authenticate (transport)); check_read_watch (transport); check_write_watch (transport); @@ -498,7 +497,7 @@ do_writing (DBusTransport *transport) dbus_bool_t oom; /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) { _dbus_verbose ("Not authenticated, not writing anything\n"); return TRUE; @@ -703,7 +702,7 @@ do_reading (DBusTransport *transport) _dbus_verbose ("fd = %d\n",socket_transport->fd); /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) return TRUE; oom = FALSE; @@ -748,29 +747,23 @@ do_reading (DBusTransport *transport) if (bytes_read > 0) { - int orig_len; - _dbus_message_loader_get_buffer (transport->loader, &buffer); - orig_len = _dbus_string_get_length (buffer); - if (!_dbus_auth_decode_data (transport->auth, &socket_transport->encoded_incoming, buffer)) { _dbus_verbose ("Out of memory decoding incoming data\n"); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); oom = TRUE; goto out; } _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); _dbus_string_set_length (&socket_transport->encoded_incoming, 0); _dbus_string_compact (&socket_transport->encoded_incoming, 2048); @@ -789,7 +782,7 @@ do_reading (DBusTransport *transport) if (!_dbus_message_loader_get_unix_fds(transport->loader, &fds, &n_fds)) { _dbus_verbose ("Out of memory reading file descriptors\n"); - _dbus_message_loader_return_buffer (transport->loader, buffer, 0); + _dbus_message_loader_return_buffer (transport->loader, buffer); oom = TRUE; goto out; } @@ -812,8 +805,7 @@ do_reading (DBusTransport *transport) } _dbus_message_loader_return_buffer (transport->loader, - buffer, - bytes_read < 0 ? 0 : bytes_read); + buffer); } if (bytes_read < 0) @@ -1055,7 +1047,7 @@ socket_do_iteration (DBusTransport *transport, poll_fd.fd = socket_transport->fd; poll_fd.events = 0; - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) { /* This is kind of a hack; if we have stuff to write, then try * to avoid the poll. This is probably about a 5% speedup on an @@ -1299,7 +1291,7 @@ _dbus_transport_new_for_socket (int fd, * @param host the host to connect to * @param port the port to connect to * @param family the address family to connect to - * @param path to nonce file + * @param noncefile path to nonce file * @param error location to store reason for failure. * @returns a new transport, or #NULL on failure. */ @@ -1337,12 +1329,12 @@ _dbus_transport_new_for_tcp_socket (const char *host, goto error; if (family != NULL && - (!_dbus_string_append (&address, "family=") || + (!_dbus_string_append (&address, ",family=") || !_dbus_string_append (&address, family))) goto error; if (noncefile != NULL && - (!_dbus_string_append (&address, "noncefile=") || + (!_dbus_string_append (&address, ",noncefile=") || !_dbus_string_append (&address, noncefile))) goto error; |