X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-transport.c;h=af5f97b22e9e26764ddd16f2053a654ff84c4307;hb=67f9cca382df0d03adfe6b619aa613d103fa77f6;hp=f33dc60bbf66e8f2e9419cc42cca1f47faec7c19;hpb=d5217348517e6b00a04e500ca460daf6cc928cd9;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index f33dc60..af5f97b 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -21,7 +21,7 @@ * */ -#include +#include <../config.h> #include "dbus-transport-protected.h" #include "dbus-transport-unix.h" #include "dbus-transport-socket.h" @@ -30,8 +30,10 @@ #include "dbus-auth.h" #include "dbus-address.h" #include "dbus-credentials.h" -#include "dbus-message-private.h" -#include "dbus-marshal-header.h" +#include "dbus-mainloop.h" +#include "dbus-message.h" + +#include "dbus-transport-kdbus.h" #ifdef DBUS_BUILD_TESTS #include "dbus-server-debug-pipe.h" #endif @@ -71,12 +73,16 @@ live_messages_notify (DBusCounter *counter, _dbus_verbose ("Unix FD counter value is now %d\n", (int) _dbus_counter_get_unix_fd_value (counter)); #endif - + /* disable or re-enable the read watch for the transport if * required. */ if (transport->vtable->live_messages_changed) - (* transport->vtable->live_messages_changed) (transport); + { + _dbus_connection_lock (transport->connection); + (* transport->vtable->live_messages_changed) (transport); + _dbus_connection_unlock (transport->connection); + } _dbus_transport_unref (transport); } @@ -113,7 +119,19 @@ _dbus_transport_init_base (DBusTransport *transport, if (server_guid) auth = _dbus_auth_server_new (server_guid); else - auth = _dbus_auth_client_new (); + { + _dbus_assert (address != NULL); + if (!_dbus_string_copy_data (address, &address_copy)) + { + _dbus_message_loader_unref (loader); + return FALSE; + } + if(address_copy == strstr(address_copy, "kdbus:path=")) + auth = _dbus_auth_client_new_kdbus(); + else + auth = _dbus_auth_client_new (); + } + if (auth == NULL) { _dbus_message_loader_unref (loader); @@ -142,19 +160,6 @@ _dbus_transport_init_base (DBusTransport *transport, _dbus_assert (address == NULL); address_copy = NULL; } - else - { - _dbus_assert (address != NULL); - - if (!_dbus_string_copy_data (address, &address_copy)) - { - _dbus_credentials_unref (creds); - _dbus_counter_unref (counter); - _dbus_auth_unref (auth); - _dbus_message_loader_unref (loader); - return FALSE; - } - } transport->refcount = 1; transport->vtable = vtable; @@ -249,7 +254,6 @@ check_address (const char *address, DBusError *error) int len, i; _dbus_assert (address != NULL); - _dbus_assert (*address != '\0'); if (!dbus_parse_address (address, &entries, &len, error)) return NULL; /* not a valid address */ @@ -273,7 +277,7 @@ check_address (const char *address, DBusError *error) * @returns a new transport, or #NULL on failure. */ static DBusTransport* -_dbus_transport_new_for_autolaunch (DBusError *error) +_dbus_transport_new_for_autolaunch (const char *scope, DBusError *error) { DBusString address; DBusTransport *result = NULL; @@ -286,7 +290,7 @@ _dbus_transport_new_for_autolaunch (DBusError *error) return NULL; } - if (!_dbus_get_autolaunch_address (&address, error)) + if (!_dbus_get_autolaunch_address (scope, &address, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto out; @@ -315,7 +319,9 @@ _dbus_transport_open_autolaunch (DBusAddressEntry *entry, if (strcmp (method, "autolaunch") == 0) { - *transport_p = _dbus_transport_new_for_autolaunch (error); + const char *scope = dbus_address_entry_get_value (entry, "scope"); + + *transport_p = _dbus_transport_new_for_autolaunch (scope, error); if (*transport_p == NULL) { @@ -342,6 +348,7 @@ static const struct { } open_funcs[] = { { _dbus_transport_open_socket }, { _dbus_transport_open_platform_specific }, + { _dbus_transport_open_kdbus }, { _dbus_transport_open_autolaunch } #ifdef DBUS_BUILD_TESTS , { _dbus_transport_open_debug_pipe } @@ -739,17 +746,6 @@ _dbus_transport_get_is_authenticated (DBusTransport *transport) _dbus_connection_unref_unlocked (transport->connection); return FALSE; } - - if (transport->expected_guid == NULL) - { - transport->expected_guid = _dbus_strdup (server_guid); - - if (transport->expected_guid == NULL) - { - _dbus_verbose ("No memory to complete auth\n"); - return FALSE; - } - } } /* If we're the server, see if we want to allow this identity to proceed. @@ -851,6 +847,8 @@ _dbus_transport_get_server_id (DBusTransport *transport) { if (transport->is_server) return NULL; + else if (transport->authenticated) + return _dbus_auth_get_guid_from_server (transport->auth); else return transport->expected_guid; } @@ -993,7 +991,7 @@ recover_unused_bytes (DBusTransport *transport) const DBusString *encoded; DBusString *buffer; int orig_len; - + if (!_dbus_string_init (&plaintext)) goto nomem; @@ -1006,12 +1004,12 @@ recover_unused_bytes (DBusTransport *transport) _dbus_string_free (&plaintext); goto nomem; } - + _dbus_message_loader_get_buffer (transport->loader, &buffer); orig_len = _dbus_string_get_length (buffer); - + if (!_dbus_string_move (&plaintext, 0, buffer, orig_len)) { @@ -1043,7 +1041,7 @@ recover_unused_bytes (DBusTransport *transport) &buffer); orig_len = _dbus_string_get_length (buffer); - + _dbus_auth_get_unused_bytes (transport->auth, &bytes); @@ -1150,6 +1148,13 @@ _dbus_transport_queue_messages (DBusTransport *transport) } else { + /* We didn't call the notify function when we added the counter, so + * catch up now. Since we have the connection's lock, it's desirable + * that we bypass the notify function and call this virtual method + * directly. */ + if (transport->vtable->live_messages_changed) + (* transport->vtable->live_messages_changed) (transport); + /* pass ownership of link and message ref to connection */ _dbus_connection_queue_received_message_link (transport->connection, link); @@ -1334,7 +1339,7 @@ _dbus_transport_get_unix_process_id (DBusTransport *transport, if (_dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID)) { - *pid = _dbus_credentials_get_unix_pid (auth_identity); + *pid = _dbus_credentials_get_pid (auth_identity); return TRUE; } else @@ -1488,4 +1493,26 @@ _dbus_transport_set_allow_anonymous (DBusTransport *transport, transport->allow_anonymous = value != FALSE; } +#ifdef DBUS_ENABLE_STATS +void +_dbus_transport_get_stats (DBusTransport *transport, + dbus_uint32_t *queue_bytes, + dbus_uint32_t *queue_fds, + dbus_uint32_t *peak_queue_bytes, + dbus_uint32_t *peak_queue_fds) +{ + if (queue_bytes != NULL) + *queue_bytes = _dbus_counter_get_size_value (transport->live_messages); + + if (queue_fds != NULL) + *queue_fds = _dbus_counter_get_unix_fd_value (transport->live_messages); + + if (peak_queue_bytes != NULL) + *peak_queue_bytes = _dbus_counter_get_peak_size_value (transport->live_messages); + + if (peak_queue_fds != NULL) + *peak_queue_fds = _dbus_counter_get_peak_unix_fd_value (transport->live_messages); +} +#endif /* DBUS_ENABLE_STATS */ + /** @} */