desktop-data-model r7276 - in trunk: . ddm engine



Author: otaylor
Date: Wed Apr 23 16:40:32 2008
New Revision: 7276
URL: http://svn.gnome.org/viewvc/desktop-data-model?rev=7276&view=rev

Log:
ddm-data-model.c ddm-work-item.[ch]: Do flush-on-shutdown in a simpler
 way: just cancel everything, never respond positively.
configure.ac engine/hippo-cookies.c: Fix some compiler warnings.


Modified:
   trunk/configure.ac
   trunk/ddm/ddm-data-model.c
   trunk/ddm/ddm-work-item.c
   trunk/ddm/ddm-work-item.h
   trunk/engine/hippo-cookies.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Wed Apr 23 16:40:32 2008
@@ -339,10 +339,15 @@
    extra_engine_packages="gnome-desktop-2.0 >= $GNOME_DESKTOP_REQUIRED"
 fi
 
+# These are fixed values for Linux; we are still using 1.0 for our Windows builds
+AC_DEFINE(HAVE_LOUDMOUTH_12, 1, [Define if you have Loudmouth 1.2 or newer])
+if false ; then
+   AC_DEFINE(HIPPO_LOUDMOUTH_IS_10, 0, [Define if Loudmouth is version 1.0 or below])
+fi
+
 PKG_CHECK_MODULES(LIBDDM, gobject-2.0 >= $GLIB2_REQUIRED dbus-glib-1 >= $DBUS_REQUIRED)
 PKG_CHECK_MODULES(LIBHIPPO, gobject-2.0 >= $GLIB2_REQUIRED gthread-2.0)
 PKG_CHECK_MODULES(LIBENGINE, gobject-2.0 >= $GLIB2_REQUIRED gthread-2.0 loudmouth-1.0 >= $LOUDMOUTH_REQUIRED $PCRE_MODULES $SQLITE_MODULES)
-AC_DEFINE(HIPPO_LOUDMOUTH_IS_10, 1, [Define if Loudmouth is version 1.0 or below])
 PKG_CHECK_MODULES(DESKTOP_DATA_ENGINE, gtk+-2.0 >= $GTK2_REQUIRED gthread-2.0 loudmouth-1.0 >= $LOUDMOUTH_REQUIRED dbus-1 >= $DBUS_REQUIRED dbus-glib-1 >= $DBUS_GLIB_REQUIRED gnome-vfs-2.0 $XSCREENSAVER_PACKAGES $extra_engine_packages)
 
 DESKTOP_DATA_ENGINE_LIBS="$DESKTOP_DATA_ENGINE_LIBS $XSCREENSAVER_LIBS $RESOLV_LIBS"

Modified: trunk/ddm/ddm-data-model.c
==============================================================================
--- trunk/ddm/ddm-data-model.c	(original)
+++ trunk/ddm/ddm-data-model.c	Wed Apr 23 16:40:32 2008
@@ -827,13 +827,10 @@
     for (l = items; l; l = l->next) {
         DDMWorkItem *item = l->data;
 
-        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);
-            }
-        }
+        if (shutting_down)
+            _ddm_work_item_cancel(item);
+        else if (!_ddm_work_item_process(item))
+            _ddm_data_model_add_work_item(model, item);
 
         _ddm_work_item_unref(item);
     }

Modified: trunk/ddm/ddm-work-item.c
==============================================================================
--- trunk/ddm/ddm-work-item.c	(original)
+++ trunk/ddm/ddm-work-item.c	Wed Apr 23 16:40:32 2008
@@ -186,8 +186,7 @@
 static gboolean
 item_fetch_additional(DDMWorkItem     *item,
                       DDMDataResource *resource,
-                      DDMDataFetch    *fetch,
-                      gboolean         shutting_down)
+                      DDMDataFetch    *fetch)
 {
     DDMDataFetchIter iter;
     gboolean all_satisfied = TRUE;
@@ -217,11 +216,11 @@
                 unrequested_fetch = ddm_data_fetch_ref(unreceived_fetch);
             }
 
-            if (unrequested_fetch == NULL) {
+            if (unrequested_fetch != NULL) {
+                item_fetch_additional_at_resource(item, resource, unrequested_fetch);
+            } else {
                 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;
@@ -251,11 +250,11 @@
                     GSList *l;
                     
                     for (l = value.u.list; l; l = l->next) {
-                        if (!item_fetch_additional(item, l->data, children, shutting_down))
+                        if (!item_fetch_additional(item, l->data, children))
                             all_satisfied = FALSE;
                     }
                 } else {
-                    if (!item_fetch_additional(item, value.u.resource, children, shutting_down))
+                    if (!item_fetch_additional(item, value.u.resource, children))
                         all_satisfied = FALSE;
                 }
             } else if (value.type == DDM_DATA_FEED) {
@@ -265,7 +264,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, shutting_down))
+                        if (!item_fetch_additional(item, item_resource, children))
                             all_satisfied = FALSE;
                     }
                 }
@@ -291,7 +290,7 @@
     WorkItemNotifyResource *notify_resource = value;
     NotifyAddAdditionalClosure *closure = data;
 
-    if (!item_fetch_additional(closure->item, notify_resource->resource, notify_resource->fetch, FALSE))
+    if (!item_fetch_additional(closure->item, notify_resource->resource, notify_resource->fetch))
         closure->all_satisfied = FALSE;
 }
 
@@ -316,8 +315,7 @@
 }
 
 gboolean
-_ddm_work_item_process (DDMWorkItem *item,
-                        gboolean     shutting_down)
+_ddm_work_item_process (DDMWorkItem *item)
 {
     GSList *l;
     gboolean all_satisfied = TRUE;
@@ -326,15 +324,7 @@
     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;
             
@@ -353,8 +343,7 @@
                     DDMDataResource *resource = l->data;
                     
                     if (item_fetch_additional(item, resource,
-                                              ddm_data_query_get_fetch(query),
-                                              shutting_down)) {
+                                              ddm_data_query_get_fetch(query))) {
                         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.
@@ -367,15 +356,7 @@
 
                         }
                     } else {
-                        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;
-                        }
+                        all_satisfied = FALSE;
                     }
                 }
             }
@@ -414,6 +395,25 @@
     return all_satisfied;
 }
 
+void
+_ddm_work_item_cancel (DDMWorkItem *item)
+{
+    switch (item->type) {
+    case ITEM_NOTIFY:
+        /* Nothing to do */
+        break;
+    case ITEM_QUERY_RESPONSE:
+        {
+            DDMDataQuery *query = item->u.query_response.query;
+            _ddm_data_query_mark_error(query,
+                                       DDM_DATA_ERROR_SHUTTING_DOWN,
+                                       "Lost connection to server while request still pending");
+            _ddm_data_query_run_response(item->u.query_response.query);
+            break;
+        }
+    }
+}
+
 gint64
 _ddm_work_item_get_min_serial (const DDMWorkItem *item)
 {

Modified: trunk/ddm/ddm-work-item.h
==============================================================================
--- trunk/ddm/ddm-work-item.h	(original)
+++ trunk/ddm/ddm-work-item.h	Wed Apr 23 16:40:32 2008
@@ -41,12 +41,15 @@
 /* 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. If shutting_down is true, then
- * no further processing is possible, and the method must return
- * TRUE.
+ * the item needs to be requeued.
  */
-gboolean _ddm_work_item_process (DDMWorkItem *item,
-                                 gboolean     shutting_down);
+gboolean _ddm_work_item_process (DDMWorkItem *item);
+
+/* Cancel the work item; generates an error response with
+ * the DDM_DATA_ERROR_SHUTTING_DOWN code if the work item is for
+ * a query.
+ */
+void _ddm_work_item_cancel  (DDMWorkItem *item);
 
 /* The item can't continue until a response has been received for
  * this query serial */

Modified: trunk/engine/hippo-cookies.c
==============================================================================
--- trunk/engine/hippo-cookies.c	(original)
+++ trunk/engine/hippo-cookies.c	Wed Apr 23 16:40:32 2008
@@ -411,16 +411,6 @@
     return g_slist_reverse(cookies);
 }
 
-#ifdef HAVE_SQLITE
-static int 
-read_cookie_cb(void *data, int argc, char **argv, char **azColName){
-  GSList **listptr = data;
-  
-  *listptr = g_slist_prepend(*listptr, argv[0]);
-  return 0;
-}
-#endif
-
 /* Sigh. */
 static GString *
 join_gstring(GSList *strs, const char *sep)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]