an idle loop so we can block and wait for a response
- This fixes the bug where if you have two GetUpdates in the queue the
second would hang waiting for the first, even though it had already
finished.
107 lines
3.7 KiB
Diff
107 lines
3.7 KiB
Diff
commit 58955c21674e37d43d7353d30ab1da3163699e94
|
|
Author: Richard Hughes <richard@hughsie.com>
|
|
Date: Thu Sep 25 14:32:25 2008 +0100
|
|
|
|
bugfix: finish a cached transaction in an idle loop
|
|
|
|
When returning results from a cache we should always return finished in an idle
|
|
loop so we can block and wait for a response without having to know if we need
|
|
to wait for ::Finished()
|
|
|
|
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
|
|
index db68d4d..73f86dc 100644
|
|
--- a/src/pk-transaction.c
|
|
+++ b/src/pk-transaction.c
|
|
@@ -1093,6 +1093,19 @@ pk_transaction_commit (PkTransaction *transaction)
|
|
}
|
|
|
|
/**
|
|
+ * pk_transaction_finished_idle_cb:
|
|
+ **/
|
|
+static gboolean
|
|
+pk_transaction_finished_idle_cb (PkTransaction *transaction)
|
|
+{
|
|
+ const gchar *exit_text;
|
|
+ exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
|
|
+ egg_debug ("emitting finished '%s'", exit_text);
|
|
+ g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
|
|
+ return FALSE;
|
|
+}
|
|
+
|
|
+/**
|
|
* pk_transaction_search_check:
|
|
**/
|
|
static gboolean
|
|
@@ -1236,7 +1249,6 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
|
|
{
|
|
gboolean ret;
|
|
GError *error;
|
|
- const gchar *exit_text;
|
|
gchar *sender;
|
|
|
|
g_return_if_fail (PK_IS_TRANSACTION (transaction));
|
|
@@ -1275,10 +1287,7 @@ pk_transaction_accept_eula (PkTransaction *transaction, const gchar *eula_id, DB
|
|
return;
|
|
}
|
|
|
|
- exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
|
|
- egg_debug ("emitting finished transaction '%s', %i", exit_text, 0);
|
|
- g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
|
|
-
|
|
+ g_idle_add ((GSourceFunc) pk_transaction_finished_idle_cb, transaction);
|
|
dbus_g_method_return (context);
|
|
}
|
|
|
|
@@ -1746,18 +1755,13 @@ pk_transaction_get_packages (PkTransaction *transaction, const gchar *filter, DB
|
|
gboolean
|
|
pk_transaction_get_old_transactions (PkTransaction *transaction, guint number, GError **error)
|
|
{
|
|
- const gchar *exit_text;
|
|
-
|
|
g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
|
|
g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
|
|
|
|
egg_debug ("GetOldTransactions method called");
|
|
|
|
pk_transaction_db_get_list (transaction->priv->transaction_db, number);
|
|
-
|
|
- exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
|
|
- egg_debug ("emitting finished transaction '%s', %i", exit_text, 0);
|
|
- g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
|
|
+ g_idle_add ((GSourceFunc) pk_transaction_finished_idle_cb, transaction);
|
|
|
|
return TRUE;
|
|
}
|
|
@@ -2071,10 +2075,7 @@ pk_transaction_get_update_detail (PkTransaction *transaction, gchar **package_id
|
|
|
|
/* if we have nothing to do, i.e. everything was in the cache */
|
|
if (array->len == 0) {
|
|
- const gchar *exit_text;
|
|
- exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
|
|
- egg_debug ("emitting finished '%s' as no more to process", exit_text);
|
|
- g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
|
|
+ g_idle_add ((GSourceFunc) pk_transaction_finished_idle_cb, transaction);
|
|
goto out;
|
|
}
|
|
|
|
@@ -2152,7 +2153,6 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
|
|
if (updates_cache != NULL) {
|
|
const PkPackageObj *obj;
|
|
const gchar *info_text;
|
|
- const gchar *exit_text;
|
|
guint i;
|
|
guint length;
|
|
|
|
@@ -2169,10 +2169,7 @@ pk_transaction_get_updates (PkTransaction *transaction, const gchar *filter, DBu
|
|
g_free (package_id);
|
|
}
|
|
|
|
- /* we are done */
|
|
- exit_text = pk_exit_enum_to_text (PK_EXIT_ENUM_SUCCESS);
|
|
- egg_debug ("emitting finished '%s'", exit_text);
|
|
- g_signal_emit (transaction, signals [PK_TRANSACTION_FINISHED], 0, exit_text, 0);
|
|
+ g_idle_add ((GSourceFunc) pk_transaction_finished_idle_cb, transaction);
|
|
|
|
dbus_g_method_return (context);
|
|
return;
|