summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2021-04-29 14:48:57 +0200
committerAdrian Szyndela <adrian.s@samsung.com>2021-05-14 16:29:31 +0200
commit20a70a03d80e151d251121c3c7daf05fcb6fe32b (patch)
tree9b0ff28d5c02aaf93a1269badbde02492c461fe6
parent6c11c0aa6a8ff7a2c1d0310f44abec978f76026f (diff)
downloaddbus-20a70a03d80e151d251121c3c7daf05fcb6fe32b.tar.gz
dbus-20a70a03d80e151d251121c3c7daf05fcb6fe32b.tar.bz2
dbus-20a70a03d80e151d251121c3c7daf05fcb6fe32b.zip
dbus: prepare API for checking transport overflow
Add API for checking transport overflow and implementation of transport overflow indicator for socket transport. Other transports always show "no overflow" for now. Change-Id: I5169403c4548bdaeb9b08e909a45f9299e146e5d
-rw-r--r--dbus/dbus-connection-internal.h3
-rw-r--r--dbus/dbus-connection.c6
-rw-r--r--dbus/dbus-transport-protected.h1
-rw-r--r--dbus/dbus-transport-socket.c7
-rw-r--r--dbus/dbus-transport.c7
-rw-r--r--dbus/dbus-transport.h2
6 files changed, 24 insertions, 2 deletions
diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h
index da2db4fc..aca66313 100644
--- a/dbus/dbus-connection-internal.h
+++ b/dbus/dbus-connection-internal.h
@@ -133,6 +133,9 @@ dbus_bool_t _dbus_connection_remove_message (DBusConnectio
DBusMessage *message);
int _dbus_connection_get_n_incoming (DBusConnection *connection);
+DBUS_PRIVATE_EXPORT
+dbus_bool_t _dbus_connection_is_overflowed (DBusConnection *connection);
+
/* if DBUS_ENABLE_STATS */
DBUS_PRIVATE_EXPORT
void _dbus_connection_get_stats (DBusConnection *connection,
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index 4b87da79..e0105790 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -5317,6 +5317,12 @@ _dbus_connection_get_n_incoming (DBusConnection *connection)
return connection->n_incoming;
}
+dbus_bool_t
+_dbus_connection_is_overflowed (DBusConnection *connection)
+{
+ return _dbus_transport_get_overflowed (connection->transport);
+}
+
/**
* Gets the UNIX user ID of the connection if known. Returns #TRUE if
* the uid is filled in. Always returns #FALSE on non-UNIX platforms
diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h
index 1a02bd2a..17081ca5 100644
--- a/dbus/dbus-transport-protected.h
+++ b/dbus/dbus-transport-protected.h
@@ -130,6 +130,7 @@ struct DBusTransport
unsigned int is_server : 1; /**< #TRUE if on the server side */
unsigned int unused_bytes_recovered : 1; /**< #TRUE if we've recovered unused bytes from auth */
unsigned int allow_anonymous : 1; /**< #TRUE if an anonymous client can connect */
+ unsigned int overflowed : 1; /**< #TRUE if last write didn't write all the data */
};
dbus_bool_t _dbus_transport_init_base (DBusTransport *transport,
diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c
index 73896501..20bb6aa1 100644
--- a/dbus/dbus-transport-socket.c
+++ b/dbus/dbus-transport-socket.c
@@ -528,6 +528,8 @@ do_writing (DBusTransport *transport)
oom = FALSE;
total = 0;
+ transport->overflowed = FALSE;
+
while (!transport->disconnected &&
_dbus_connection_has_messages_to_send_unlocked (transport->connection))
{
@@ -667,7 +669,10 @@ do_writing (DBusTransport *transport)
*/
if (_dbus_get_is_errno_eagain_or_ewouldblock (saved_errno) || _dbus_get_is_errno_epipe (saved_errno))
- goto out;
+ {
+ transport->overflowed = TRUE;
+ goto out;
+ }
/* Since Linux commit 25888e (from 2.6.37-rc4, Nov 2010), sendmsg()
* on Unix sockets returns -1 errno=ETOOMANYREFS when the passfd
diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c
index 5771279a..c51a8d33 100644
--- a/dbus/dbus-transport.c
+++ b/dbus/dbus-transport.c
@@ -273,6 +273,7 @@ _dbus_transport_init_base_with_auth (DBusTransport *transport,
transport->assure_protocol_function = _dbus_message_assure_dbus1;
transport->send_sync_call_function = NULL;
transport->protocol = DBUS_MAJOR_PROTOCOL_VERSION;
+ transport->overflowed = FALSE;
return TRUE;
}
@@ -297,6 +298,12 @@ _dbus_transport_get_protocol (DBusTransport *transport)
return transport->protocol;
}
+dbus_bool_t
+_dbus_transport_get_overflowed (DBusTransport *transport)
+{
+ return transport->overflowed;
+}
+
/**
* Initializes the base class members of DBusTransport. Chained up to
* by subclasses in their constructor. The server GUID is the
diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h
index 55182c5f..4bd01799 100644
--- a/dbus/dbus-transport.h
+++ b/dbus/dbus-transport.h
@@ -110,7 +110,7 @@ dbus_bool_t _dbus_transport_assure_protocol_version (DBusTransport
DBusMessage **message);
DBusMessage* _dbus_transport_send_sync_call (DBusTransport *transport,
DBusMessage *message);
-
+dbus_bool_t _dbus_transport_get_overflowed (DBusTransport *transport);
/* if DBUS_ENABLE_STATS */
void _dbus_transport_get_stats (DBusTransport *transport,