[Laszlo-checkins] r13004 - in openlaszlo/trunk/WEB-INF/lps/lfc: data services

bargull@openlaszlo.org bargull at openlaszlo.org
Sun Feb 22 13:42:02 PST 2009


Author: bargull
Date: 2009-02-22 13:41:59 -0800 (Sun, 22 Feb 2009)
New Revision: 13004

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/services/LzInstantiator.lzs
Log:
Change 20090118-bargull-14S by bargull at dell--p4--2-53 on 2009-01-18 19:31:00
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: fix replication order

New Features:

Bugs Fixed: LPP-495 "datapath's replication create the object out of order"

Technical Reviewer: ptw
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
This is an attempt to fix a subtle bug in replication init-order, I've sketched out why init-order is wrong in that case in my first comment on the bugreport. 
While I was working on that issue, I've found another possible bug (see testcase from 16th Dec 2008), which is easier to fix:
- "enableDataReplicationQueuing" didn't handle the case when two different replication-managers start replication
- so I added "dataQ" to save the current "datareplQ" and later restore it in "clearDataReplicationQueue"
LPP-495 requires to find the right insertion point in the "makeQ", so iterate through all entries and when match was found, add all entries before that index, so the nodes will be initiated as expected.
Also changed "traceQ" so it will only be compiled in for debug-mode, and updated it to provide some useful info again. 
Lz(Lazy)ReplicationManager: pass `this`-ptr to lz.Instantiator functions

    

Tests:
tests at bugreport



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs	2009-02-22 18:52:47 UTC (rev 13003)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzLazyReplicationManager.lzs	2009-02-22 21:41:59 UTC (rev 13004)
@@ -271,7 +271,7 @@
     //no change
     if ( offset == 0 && newlength == oldlength ) return;
 
-    lz.Instantiator.enableDataReplicationQueuing( );
+    lz.Instantiator.enableDataReplicationQueuing(this);
     var oldclones:Array = this.clones;
     this.clones = [];
 
@@ -324,7 +324,7 @@
     }
 
     this.__LZdataoffset = newstart;
-    lz.Instantiator.clearDataReplicationQueue( );
+    lz.Instantiator.clearDataReplicationQueue(this);
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2009-02-22 18:52:47 UTC (rev 13003)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2009-02-22 21:41:59 UTC (rev 13004)
@@ -1,6 +1,6 @@
 /**
   *
-  * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
+  * @copyright Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.
   *            Use is subject to license terms.
   *
   * @access public
@@ -527,7 +527,7 @@
 
     //this makes sure that children created as a result of data replication
     //init in order
-    lz.Instantiator.enableDataReplicationQueuing( );
+    lz.Instantiator.enableDataReplicationQueuing(this);
 
     while ( this.nodes && this.nodes.length > this.clones.length ){
         var cl:LzNode = this.getNewClone();
@@ -536,9 +536,8 @@
         this.clones.push( cl );
     }
 
-    lz.Instantiator.clearDataReplicationQueue( );
+    lz.Instantiator.clearDataReplicationQueue(this);
 
-
     while ( this.nodes && this.nodes.length < this.clones.length ){
         //this condition can only be reached if pooling is turned on
         this.poolClone();

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/LzInstantiator.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/LzInstantiator.lzs	2009-02-22 18:52:47 UTC (rev 13003)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/LzInstantiator.lzs	2009-02-22 21:41:59 UTC (rev 13004)
@@ -1,5 +1,5 @@
 /**
- * @copyright Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.
+ * @copyright Copyright 2001-2009 Laszlo Systems, Inc.  All Rights Reserved.
  *            Use is subject to license terms.
  *
  * @affects lzinstantiator
@@ -89,8 +89,10 @@
     /** @access private */
     var tricklingQ :Array = [];
     /** @access private */
-    var datareplQ :Array;
+    var datareplQ :Array = null;
     /** @access private */
+    var dataQ :Array = [];
+    /** @access private */
     var syncNew :Boolean = true;
     /**
      * The length of time to spend creating initstage=
@@ -126,7 +128,8 @@
         } else {
             var c:Array = this.newReverseArray( children );
             if (this.isdatareplicating) {
-                this.datareplQ.push( v, c );
+                // add in reversed order
+                this.datareplQ.push( c, v );
             } else if (this.istrickling) {
                 this.tricklingQ.push( v, c );
             } else {
@@ -139,21 +142,63 @@
     /**
      * @access private
      */
-    function enableDataReplicationQueuing () :void {
-        this.isdatareplicating = true;
+    function enableDataReplicationQueuing (rman:* /*LzReplicationManager*/) :void {
+        if (this.isdatareplicating) {
+            this.dataQ.push(this.datareplQ);
+        } else {
+            this.isdatareplicating = true;
+        }
         this.datareplQ = [];
+        if ($debug) {
+            // add replication-manager
+            this.datareplQ.push(rman);
+        }
     }
+
     /**
      * @access private
      */
-    function clearDataReplicationQueue () :void {
-        this.isdatareplicating = false;
+    function clearDataReplicationQueue (rman:* /*LzReplicationManager*/) :void {
         var drq:Array = this.datareplQ;
-        //now add them on backwards
-        for (var i:int = drq.length - 1; i > 0; i -= 2) {
-            this.makeQ.push( drq[ i-1 ], drq[ i ] );
+        if (this.dataQ.length > 0) {
+            this.datareplQ = this.dataQ.pop();
+        } else {
+            this.isdatareplicating = false;
+            this.datareplQ = null;
         }
-        this.datareplQ = null;
+
+        if ($debug) {
+            // check integrity in debug-mode
+            if (drq.shift() !== rman) {
+                Debug.error("%w.clearDataReplicationQueue: expected %w", this, rman);
+            }
+        }
+
+        // if ($debug) this.traceQ();
+
+        // Find offset where to add new nodes. This is only important
+        // when there are already pending nodes (of the same replication manager)
+        // in the makeQueue, or the new nodes will be initiated in the
+        // wrong order (LPP-495).
+        var cpar:LzNode = rman.cloneParent;
+        var mq:Array = this.makeQ;
+        var mqlen:int = mq.length;
+        var offset:int = mqlen;
+        for (var i:int = 0; i < mqlen; i += 2) {
+            if (mq[i].parent === cpar) {
+                // found match, add all nodes before this entry
+                offset = i;
+                break;
+            }
+        }
+        // (0, offset) are already the first two args of splice
+        drq.push(0, offset);
+        // datareplQ is a FIFO, but makeQ is a LIFO struct, so reverse
+        drq.reverse();
+        // NOTE: [20081226 anba] don't use Array.prototype.splice,
+        // the context will be wrong, see flash player bug (FP-1250)
+        mq.splice.apply(mq, drq);
+
         this.checkUpdate();
     }
 
@@ -169,6 +214,7 @@
         }
         return a;
     }
+
     /**
      * @access private
      */
@@ -315,21 +361,25 @@
         }
     }
 
+  if ($debug) {
     /**
      * @access private
      */
     function traceQ () :void {
-        var mql:int = this.makeQ.length;
-        trace( "****start trace" );
-        for (var i:int = 0; i < mql; i += 2) {
+        Debug.info( "****start trace" );
+        var mq:Array = this.makeQ;
+        for (var i:int = 0; i < mq.length; i += 2) {
+            var par:LzNode = mq[i];
+            var larr:Array = mq[i + 1];
             var s:String = "";
-            for (var k:int = 0; k < this.makeQ[ i + 1 ].length; k++) {
-                s += this.makeQ[ i + 1 ][ k ].name + " |";
+            for (var k:int = 0; k < larr.length; k++) {
+                s += larr[ k ]['class'].tagname + " |";
             }
-            trace( this.makeQ[ i ] + " : |" + s  + " >>> " + this.makeQ[ i ].getUID() );
+            Debug.write( "%w : |%s >>> %s", par, s, par.getUID() );
         }
-        trace( "****trace done" );
+        Debug.info( "****trace done" );
     }
+  }
 
     /**
      * Stops the instantiatior until <code>resume</code> is called.



More information about the Laszlo-checkins mailing list