desktop-data-model r7275 - trunk/ddm
- From: otaylor svn gnome org
- To: svn-commits-list gnome org
- Subject: desktop-data-model r7275 - trunk/ddm
- Date: Mon, 21 Apr 2008 21:57:37 +0100 (BST)
Author: otaylor
Date: Mon Apr 21 20:57:37 2008
New Revision: 7275
URL: http://svn.gnome.org/viewvc/desktop-data-model?rev=7275&view=rev
Log:
Flush out pending responses and notifications when we reset the
data model on reconnection. (Is *not* the fix for #1394, as it
turns out, but a good idea non-the-less.)
Modified:
trunk/ddm/ddm-data-model.c
trunk/ddm/ddm-data-resource.h
trunk/ddm/ddm-work-item.c
trunk/ddm/ddm-work-item.h
Modified: trunk/ddm/ddm-data-model.c
==============================================================================
--- trunk/ddm/ddm-data-model.c (original)
+++ trunk/ddm/ddm-data-model.c Mon Apr 21 20:57:37 2008
@@ -19,6 +19,9 @@
static void ddm_data_model_dispose (GObject *object);
static void ddm_data_model_finalize (GObject *object);
+static void ddm_data_model_flush_internal(DDMDataModel *model,
+ gboolean shutting_down);
+
struct _DDMDataModel {
GObject parent;
@@ -570,6 +573,9 @@
void
ddm_data_model_reset (DDMDataModel *model)
{
+ /* Pending work items might expect the model to be in the pre-reset state */
+ ddm_data_model_flush_internal(model, TRUE);
+
g_hash_table_foreach_remove(model->resources, model_reset_foreach, NULL);
g_hash_table_foreach_remove(model->changed_resources, model_reset_changed_resource_foreach, NULL);
@@ -780,7 +786,8 @@
}
static void
-data_model_flush_work_items(DDMDataModel *model)
+data_model_flush_work_items(DDMDataModel *model,
+ gboolean shutting_down)
{
GList *items;
GList *l;
@@ -820,8 +827,13 @@
for (l = items; l; l = l->next) {
DDMWorkItem *item = l->data;
- if (!_ddm_work_item_process(item))
- _ddm_data_model_add_work_item(model, item);
+ if (!_ddm_work_item_process(item, shutting_down)) {
+ if (shutting_down) {
+ g_critical("Work item return FALSE when shutting down");
+ } else {
+ _ddm_data_model_add_work_item(model, item);
+ }
+ }
_ddm_work_item_unref(item);
}
@@ -829,23 +841,30 @@
g_list_free(items);
}
+static void
+ddm_data_model_flush_internal(DDMDataModel *model,
+ gboolean shutting_down)
+{
+ g_debug("Flushing Data Model, shutting_down = %d", shutting_down);
+
+ if (model->backend->flush)
+ model->backend->flush(model, model->backend_data);
+
+ data_model_flush_rules(model);
+ data_model_flush_notifications(model);
+ data_model_flush_work_items(model, shutting_down);
+}
+
void
ddm_data_model_flush(DDMDataModel *model)
{
if (model->flush_idle == 0)
return;
- g_debug("Flushing Data Model");
-
g_source_remove(model->flush_idle);
model->flush_idle = 0;
- if (model->backend->flush)
- model->backend->flush(model, model->backend_data);
-
- data_model_flush_rules(model);
- data_model_flush_notifications(model);
- data_model_flush_work_items(model);
+ ddm_data_model_flush_internal(model, FALSE);
}
void
Modified: trunk/ddm/ddm-data-resource.h
==============================================================================
--- trunk/ddm/ddm-data-resource.h (original)
+++ trunk/ddm/ddm-data-resource.h Mon Apr 21 20:57:37 2008
@@ -26,6 +26,7 @@
DDM_DATA_ERROR_NO_CONNECTION = -1,
DDM_DATA_ERROR_BAD_REPLY = -2,
DDM_DATA_ERROR_INTERNAL = -3,
+ DDM_DATA_ERROR_SHUTTING_DOWN = -4,
DDM_DATA_ERROR_BAD_REQUEST = 400,
DDM_DATA_ERROR_FORBIDDEN = 403,
DDM_DATA_ERROR_ITEM_NOT_FOUND = 404,
Modified: trunk/ddm/ddm-work-item.c
==============================================================================
--- trunk/ddm/ddm-work-item.c (original)
+++ trunk/ddm/ddm-work-item.c Mon Apr 21 20:57:37 2008
@@ -186,7 +186,8 @@
static gboolean
item_fetch_additional(DDMWorkItem *item,
DDMDataResource *resource,
- DDMDataFetch *fetch)
+ DDMDataFetch *fetch,
+ gboolean shutting_down)
{
DDMDataFetchIter iter;
gboolean all_satisfied = TRUE;
@@ -216,11 +217,11 @@
unrequested_fetch = ddm_data_fetch_ref(unreceived_fetch);
}
- if (unrequested_fetch != NULL) {
- item_fetch_additional_at_resource(item, resource, unrequested_fetch);
- } else {
+ if (unrequested_fetch == NULL) {
gint64 old_serial = _ddm_data_resource_get_requested_serial(resource);
item->min_serial = MAX(item->min_serial, old_serial);
+ } else if (!shutting_down) {
+ item_fetch_additional_at_resource(item, resource, unrequested_fetch);
}
all_satisfied = FALSE;
@@ -250,11 +251,11 @@
GSList *l;
for (l = value.u.list; l; l = l->next) {
- if (!item_fetch_additional(item, l->data, children))
+ if (!item_fetch_additional(item, l->data, children, shutting_down))
all_satisfied = FALSE;
}
} else {
- if (!item_fetch_additional(item, value.u.resource, children))
+ if (!item_fetch_additional(item, value.u.resource, children, shutting_down))
all_satisfied = FALSE;
}
} else if (value.type == DDM_DATA_FEED) {
@@ -264,7 +265,7 @@
ddm_feed_iter_init(&feed_iter, value.u.feed);
while (ddm_feed_iter_next(&feed_iter, &item_resource, NULL)) {
- if (!item_fetch_additional(item, item_resource, children))
+ if (!item_fetch_additional(item, item_resource, children, shutting_down))
all_satisfied = FALSE;
}
}
@@ -290,7 +291,7 @@
WorkItemNotifyResource *notify_resource = value;
NotifyAddAdditionalClosure *closure = data;
- if (!item_fetch_additional(closure->item, notify_resource->resource, notify_resource->fetch))
+ if (!item_fetch_additional(closure->item, notify_resource->resource, notify_resource->fetch, FALSE))
closure->all_satisfied = FALSE;
}
@@ -315,7 +316,8 @@
}
gboolean
-_ddm_work_item_process (DDMWorkItem *item)
+_ddm_work_item_process (DDMWorkItem *item,
+ gboolean shutting_down)
{
GSList *l;
gboolean all_satisfied = TRUE;
@@ -324,7 +326,15 @@
case ITEM_NOTIFY:
{
NotifyAddAdditionalClosure closure;
-
+
+ /* If we are shutting down, and there are pending notifications, we just
+ * want to drop them on the floor.
+ */
+ if (shutting_down) {
+ g_debug("%s: discarding on shutdown", item->id_string);
+ return TRUE;
+ }
+
closure.item = item;
closure.all_satisfied = all_satisfied;
@@ -343,7 +353,8 @@
DDMDataResource *resource = l->data;
if (item_fetch_additional(item, resource,
- ddm_data_query_get_fetch(query))) {
+ ddm_data_query_get_fetch(query),
+ shutting_down)) {
if (ddm_data_resource_get_class_id(resource) == NULL) {
/* This means that we've done everything we can and we still know
* nothing about the resource.
@@ -356,7 +367,15 @@
}
} else {
- all_satisfied = FALSE;
+ if (shutting_down) {
+ _ddm_data_query_mark_error(query,
+ DDM_DATA_ERROR_SHUTTING_DOWN,
+ "Lost connection to server while request still pending");
+ all_satisfied = TRUE;
+ break;
+ } else {
+ all_satisfied = FALSE;
+ }
}
}
}
Modified: trunk/ddm/ddm-work-item.h
==============================================================================
--- trunk/ddm/ddm-work-item.h (original)
+++ trunk/ddm/ddm-work-item.h Mon Apr 21 20:57:37 2008
@@ -41,9 +41,12 @@
/* Try to execute the item; a TRUE return means that it was executed,
* and can be freed; a FALSE return means that additional fetches
* have been sent upstream, item->min_serial has been updated, and
- * the item needs to be requeued.
+ * the item needs to be requeued. If shutting_down is true, then
+ * no further processing is possible, and the method must return
+ * TRUE.
*/
-gboolean _ddm_work_item_process (DDMWorkItem *item);
+gboolean _ddm_work_item_process (DDMWorkItem *item,
+ gboolean shutting_down);
/* The item can't continue until a response has been received for
* this query serial */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]