summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Shaw <joeshaw@novell.com>2005-02-10 23:01:28 +0000
committerJoe Shaw <joeshaw@novell.com>2005-02-10 23:01:28 +0000
commitfd146b370dd2e014838c08ce0bfc8854ca93928b (patch)
treedf200b603d67e486edf2a50bb763e4343c1a9f9d
parent8fda602e991990d21f196e65d917a481c6ec1360 (diff)
2005-02-10 Joe Shaw <joeshaw@novell.com>
* dbus/dbus-connection.c (_dbus_connection_queue_received_message_link, _dbus_connection_message_sent): Add the path to the verbose output. (_dbus_connection_send_preallocated_and_unlock): Added. Calls _dbus_connection_send_preallocated_unlocked(), updated the dispatch status, and unlocks. Fixes a bug where certain situations (like a broken pipe) could cause a Disconnect message to not be sent, tricking the bus into thinking a service was still there when the process had quit. (_dbus_connection_send_preallocated): Call _dbus_connection_send_preallocated_and_unlock(). (_dbus_connection_send_and_unlock): Added. Calls _dbus_connection_send_preallocated_and_unlock(). (dbus_connection_send): Call _dbus_connection_send_and_unlock(). (dbus_connection_send_with_reply): Update the dispatch status and unlock. * mono/Service.cs (~Service): Added. Removes the filter so that we don't get unmanaged code calling back into a GCed delegate. (RemoveFilter); Added.
-rw-r--r--ChangeLog24
-rw-r--r--dbus/dbus-connection.c79
-rw-r--r--mono/Service.cs33
3 files changed, 114 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 25093157..84a46bf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2005-02-10 Joe Shaw <joeshaw@novell.com>
+
+ * dbus/dbus-connection.c
+ (_dbus_connection_queue_received_message_link,
+ _dbus_connection_message_sent): Add the path to
+ the verbose output.
+ (_dbus_connection_send_preallocated_and_unlock): Added. Calls
+ _dbus_connection_send_preallocated_unlocked(), updated the
+ dispatch status, and unlocks. Fixes a bug where certain
+ situations (like a broken pipe) could cause a Disconnect message
+ to not be sent, tricking the bus into thinking a service was still
+ there when the process had quit.
+ (_dbus_connection_send_preallocated): Call
+ _dbus_connection_send_preallocated_and_unlock().
+ (_dbus_connection_send_and_unlock): Added. Calls
+ _dbus_connection_send_preallocated_and_unlock().
+ (dbus_connection_send): Call _dbus_connection_send_and_unlock().
+ (dbus_connection_send_with_reply): Update the dispatch status and
+ unlock.
+
+ * mono/Service.cs (~Service): Added. Removes the filter so that
+ we don't get unmanaged code calling back into a GCed delegate.
+ (RemoveFilter); Added.
+
2005-02-09 John (J5) Palmieri <johnp@redhat.com>
* dbus/dbus-message.c (dbus_message_iter_open_container):
diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
index f01133c5..9e60aa27 100644
--- a/dbus/dbus-connection.c
+++ b/dbus/dbus-connection.c
@@ -357,9 +357,10 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection,
_dbus_connection_wakeup_mainloop (connection);
- _dbus_verbose ("Message %p (%d %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n",
+ _dbus_verbose ("Message %p (%d %s %s %s '%s' reply to %u) added to incoming queue %p, %d incoming\n",
message,
dbus_message_get_type (message),
+ dbus_message_get_path (message),
dbus_message_get_interface (message) ?
dbus_message_get_interface (message) :
"no interface",
@@ -473,9 +474,10 @@ _dbus_connection_message_sent (DBusConnection *connection,
connection->n_outgoing -= 1;
- _dbus_verbose ("Message %p (%d %s %s '%s') removed from outgoing queue %p, %d left to send\n",
+ _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from outgoing queue %p, %d left to send\n",
message,
dbus_message_get_type (message),
+ dbus_message_get_path (message),
dbus_message_get_interface (message) ?
dbus_message_get_interface (message) :
"no interface",
@@ -1563,9 +1565,10 @@ _dbus_connection_send_preallocated_unlocked (DBusConnection *connection,
sig = dbus_message_get_signature (message);
- _dbus_verbose ("Message %p (%d %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n",
+ _dbus_verbose ("Message %p (%d %s %s %s '%s') for %s added to outgoing queue %p, %d pending to send\n",
message,
dbus_message_get_type (message),
+ dbus_message_get_path (message),
dbus_message_get_interface (message) ?
dbus_message_get_interface (message) :
"no interface",
@@ -1603,12 +1606,30 @@ _dbus_connection_send_preallocated_unlocked (DBusConnection *connection,
_dbus_connection_do_iteration (connection,
DBUS_ITERATION_DO_WRITING,
-1);
-
+
/* If stuff is still queued up, be sure we wake up the main loop */
if (connection->n_outgoing > 0)
_dbus_connection_wakeup_mainloop (connection);
}
+static void
+_dbus_connection_send_preallocated_and_unlock (DBusConnection *connection,
+ DBusPreallocatedSend *preallocated,
+ DBusMessage *message,
+ dbus_uint32_t *client_serial)
+{
+ DBusDispatchStatus status;
+
+ _dbus_connection_send_preallocated_unlocked (connection,
+ preallocated,
+ message, client_serial);
+
+ status = _dbus_connection_get_dispatch_status_unlocked (connection);
+
+ /* this calls out to user code */
+ _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+}
+
/**
* Sends a message using preallocated resources. This function cannot fail.
* It works identically to dbus_connection_send() in other respects.
@@ -1639,10 +1660,9 @@ dbus_connection_send_preallocated (DBusConnection *connection,
dbus_message_get_member (message) != NULL));
CONNECTION_LOCK (connection);
- _dbus_connection_send_preallocated_unlocked (connection,
- preallocated,
- message, client_serial);
- CONNECTION_UNLOCK (connection);
+ _dbus_connection_send_preallocated_and_unlock (connection,
+ preallocated,
+ message, client_serial);
}
dbus_bool_t
@@ -1667,6 +1687,27 @@ _dbus_connection_send_unlocked (DBusConnection *connection,
return TRUE;
}
+static dbus_bool_t
+_dbus_connection_send_and_unlock (DBusConnection *connection,
+ DBusMessage *message,
+ dbus_uint32_t *client_serial)
+{
+ DBusPreallocatedSend *preallocated;
+
+ _dbus_assert (connection != NULL);
+ _dbus_assert (message != NULL);
+
+ preallocated = _dbus_connection_preallocate_send_unlocked (connection);
+ if (preallocated == NULL)
+ return FALSE;
+
+ _dbus_connection_send_preallocated_and_unlock (connection,
+ preallocated,
+ message,
+ client_serial);
+ return TRUE;
+}
+
/**
* Adds a message to the outgoing message queue. Does not block to
* write the message to the network; that happens asynchronously. To
@@ -1695,14 +1736,9 @@ dbus_connection_send (DBusConnection *connection,
CONNECTION_LOCK (connection);
- if (!_dbus_connection_send_unlocked (connection, message, client_serial))
- {
- CONNECTION_UNLOCK (connection);
- return FALSE;
- }
-
- CONNECTION_UNLOCK (connection);
- return TRUE;
+ return _dbus_connection_send_and_unlock (connection,
+ message,
+ client_serial);
}
static dbus_bool_t
@@ -1781,6 +1817,7 @@ dbus_connection_send_with_reply (DBusConnection *connection,
DBusMessage *reply;
DBusList *reply_link;
dbus_int32_t serial = -1;
+ DBusDispatchStatus status;
_dbus_return_val_if_fail (connection != NULL, FALSE);
_dbus_return_val_if_fail (message != NULL, FALSE);
@@ -1842,8 +1879,11 @@ dbus_connection_send_with_reply (DBusConnection *connection,
else
dbus_pending_call_unref (pending);
- CONNECTION_UNLOCK (connection);
-
+ status = _dbus_connection_get_dispatch_status_unlocked (connection);
+
+ /* this calls out to user code */
+ _dbus_connection_update_dispatch_status_and_unlock (connection, status);
+
return TRUE;
error:
@@ -2253,9 +2293,10 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection)
link = _dbus_list_pop_first_link (&connection->incoming_messages);
connection->n_incoming -= 1;
- _dbus_verbose ("Message %p (%d %s %s '%s') removed from incoming queue %p, %d incoming\n",
+ _dbus_verbose ("Message %p (%d %s %s %s '%s') removed from incoming queue %p, %d incoming\n",
link->data,
dbus_message_get_type (link->data),
+ dbus_message_get_path (link->data),
dbus_message_get_interface (link->data) ?
dbus_message_get_interface (link->data) :
"no interface",
diff --git a/mono/Service.cs b/mono/Service.cs
index 5f6ff4c4..b5547961 100644
--- a/mono/Service.cs
+++ b/mono/Service.cs
@@ -23,6 +23,9 @@ namespace DBus
private static AssemblyBuilder proxyAssembly;
private ModuleBuilder module = null;
+ // Add a match for signals. FIXME: Can we filter the service?
+ private const string MatchRule = "type='signal'";
+
internal Service(string name, Connection connection)
{
this.name = name;
@@ -47,6 +50,12 @@ namespace DBus
this.local = true;
}
+ ~Service ()
+ {
+ if (this.filterCalled != null)
+ RemoveFilter ();
+ }
+
public static bool HasOwner(Connection connection, string name)
{
Error error = new Error();
@@ -113,9 +122,17 @@ namespace DBus
IntPtr.Zero))
throw new OutOfMemoryException();
- // Add a match for signals. FIXME: Can we filter the service?
- string rule = "type='signal'";
- dbus_bus_add_match(connection.RawConnection, rule, IntPtr.Zero);
+ dbus_bus_add_match(connection.RawConnection, MatchRule, IntPtr.Zero);
+ }
+
+ private void RemoveFilter()
+ {
+ dbus_connection_remove_filter (Connection.RawConnection,
+ this.filterCalled,
+ IntPtr.Zero);
+ this.filterCalled = null;
+
+ dbus_bus_remove_match (connection.RawConnection, MatchRule, IntPtr.Zero);
}
private int Service_FilterCalled(IntPtr rawConnection,
@@ -200,9 +217,19 @@ namespace DBus
IntPtr freeData);
[DllImport("dbus-1")]
+ private extern static void dbus_connection_remove_filter(IntPtr rawConnection,
+ DBusHandleMessageFunction filter,
+ IntPtr userData);
+
+ [DllImport("dbus-1")]
private extern static void dbus_bus_add_match(IntPtr rawConnection,
string rule,
IntPtr erro);
+ [DllImport("dbus-1")]
+ private extern static void dbus_bus_remove_match(IntPtr rawConnection,
+ string rule,
+ IntPtr erro);
+
}
}