summaryrefslogtreecommitdiff
path: root/community-testing/dee/fix-crash.patch
blob: 9ce664e10e37926bb8d23ea9ad691e68c961b00a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
=== modified file 'src/dee-shared-model.c'
--- src/dee-shared-model.c	2012-03-12 11:49:53 +0000
+++ src/dee-shared-model.c	2012-03-29 12:04:44 +0000
@@ -1183,6 +1183,7 @@
   guint32                pos;
   guchar                 change_type;
   gint                   i, j;
+  gboolean               transaction_error;
 
   g_return_if_fail (DEE_IS_SHARED_MODEL (self));
   g_return_if_fail (transaction != NULL);
@@ -1249,48 +1250,56 @@
   g_variant_get (tt, "(tt)", &seqnum_before, &seqnum_after);
   g_variant_unref (tt);
 
+  transaction_error = FALSE;
   /* If this is our first transaction we accept anything, if not the
    * incoming seqnums must align with our own records */
   current_seqnum = dee_serializable_model_get_seqnum (DEE_MODEL (self));
-  if (current_seqnum != 0 &&
-      current_seqnum != seqnum_before)
-  {
+
+  if (current_seqnum != 0 && current_seqnum != seqnum_before)
+    {
       g_warning ("Transaction from %s is in the %s. Expected seqnum %"G_GUINT64_FORMAT
                  ", but got %"G_GUINT64_FORMAT". Ignoring transaction.",
                  sender_name,
                  current_seqnum < seqnum_before ? "future" : "past",
                  current_seqnum, seqnum_before);
-      if (dee_shared_model_is_leader (self))
-        {
-          g_warning ("Invalidating %s", sender_name);
-          invalidate_peer (self, sender_name, NULL);
-        }
-
-      g_variant_unref (transaction);
-      g_variant_unref (aav);
-      g_variant_unref (au);
-      g_variant_unref (ay);
-      return;
-  }
+      transaction_error = TRUE;
+    }
 
   /* Check that the lengths of all the arrays match up */
   n_rows = g_variant_n_children (aav);
+
   if (n_rows != g_variant_n_children (au))
     {
       g_warning ("Commit from %s has illegal position vector",
                  sender_name);
-      // FIXME cleanup
+      transaction_error = TRUE;
     }
   if (n_rows != g_variant_n_children (ay))
     {
       g_warning ("Commit from %s has illegal change type vector",
                  sender_name);
-      // FIXME cleanup
+      transaction_error = TRUE;
     }
   if (n_rows > (seqnum_after - seqnum_before))
     {
       g_warning ("Commit from %s has illegal seqnum count.",
                  sender_name);
+      transaction_error = TRUE;
+    }
+
+  if (transaction_error)
+    {
+      if (dee_shared_model_is_leader (self))
+        {
+          g_warning ("Invalidating %s", sender_name);
+          invalidate_peer (self, sender_name, NULL);
+        }
+
+      g_variant_unref (transaction);
+      g_variant_unref (aav);
+      g_variant_unref (au);
+      g_variant_unref (ay);
+      return;
     }
   
   /* Allocate an array on the stack as a temporary row data buffer */