more bugs
authorbdemsky <bdemsky@uci.edu>
Sun, 24 Jul 2016 05:09:36 +0000 (22:09 -0700)
committerbdemsky <bdemsky@uci.edu>
Sun, 24 Jul 2016 05:09:36 +0000 (22:09 -0700)
src/java/iotcloud/SlotBuffer.java
src/java/iotcloud/Table.java

index e3ababf7666a3e3d29b315f1bb5e6ba27844d1f2..054d4fc396bc4b4fca1410d51439492858e11d9a 100644 (file)
@@ -43,11 +43,17 @@ class SlotBuffer {
        void putSlot(Slot s) {
                array[head]=s;
                head++;
        void putSlot(Slot s) {
                array[head]=s;
                head++;
+               if (head >= array.length)
+                       head=0;
+               
                if (oldestseqn==0)
                        oldestseqn = s.getSequenceNumber();
 
                if (head==tail) {
                        tail++;
                if (oldestseqn==0)
                        oldestseqn = s.getSequenceNumber();
 
                if (head==tail) {
                        tail++;
+                       if (tail >= array.length)
+                               tail=0;
+                       
                        oldestseqn++;
                }
        }
                        oldestseqn++;
                }
        }
@@ -64,7 +70,15 @@ class SlotBuffer {
                if (index >= array.length ||
                                index >= head)
                        return null;
                if (index >= array.length ||
                                index >= head)
                        return null;
+               if (index < 0) {
+                       System.out.println("seqnum="+seqnum);
+                       System.out.println("olestseqn="+oldestseqn);
+                       System.out.println("diff="+diff);
+                       System.out.println("tail="+tail);
 
 
+
+               }
+               
                return array[index];
        }
 
                return array[index];
        }
 
index d3bac3dd40a913a6f71c47495c53e8174991d13a..72b4927ef245ff965af19884d4e677353a41212a 100644 (file)
@@ -109,7 +109,8 @@ final public class Table {
                
     if ((numslots - buffer.size()) < FREE_SLOTS) {
       //have to check whether we have enough free slots
                
     if ((numslots - buffer.size()) < FREE_SLOTS) {
       //have to check whether we have enough free slots
-      seqn = buffer.getNewestSeqNum() + 1 - numslots;
+      long fullfirstseqn = buffer.getNewestSeqNum() + 1 - numslots;
+                       seqn = fullfirstseqn < 1 ? 1: fullfirstseqn;
       for(int i=0; i < FREE_SLOTS; i++, seqn++) {
         Slot prevslot=buffer.getSlot(seqn);
         if (!prevslot.isLive())
       for(int i=0; i < FREE_SLOTS; i++, seqn++) {
         Slot prevslot=buffer.getSlot(seqn);
         if (!prevslot.isLive())