ctf: make StreamInputPacketIndex more thread safe
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 21 Aug 2015 21:03:38 +0000 (17:03 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Wed, 26 Aug 2015 19:57:44 +0000 (15:57 -0400)
This patch makes append synchronized. The SIPI can only grow and elements,
once in the index, cannot be changed. Therefore synchronization on reading
does not seem essential. If the same packet is written twice, the second
time, it will fail gracefully. The packet will still be there. This
should help "CtfTmfContextTest.testTooManyTraces".

Change-Id: Ic4dfcdda71fc1ebb58039066dab836e67458506f
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/54344
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/trace/StreamInputPacketIndex.java

index 0a49f431d777862edb11531f1c53271d0bc294a7..85322216722f91dc50fe159e9fea2bb91b6e1b5a 100644 (file)
@@ -96,7 +96,7 @@ public class StreamInputPacketIndex {
      * @throws CTFException
      *             If there was a problem reading the entry
      */
-    public boolean append(@NonNull ICTFPacketDescriptor entry)
+    public synchronized boolean append(@NonNull ICTFPacketDescriptor entry)
             throws CTFException {
 
         /* Validate consistent entry. */
@@ -109,7 +109,7 @@ public class StreamInputPacketIndex {
          * order.
          */
         if (!fEntries.isEmpty() && (entry.getTimestampBegin() < lastElement().getTimestampBegin())) {
-            throw new CTFException("Packets begin timestamp decreasing"); //$NON-NLS-1$
+            return false;
         }
 
         fEntries.add(entry);
This page took 0.029171 seconds and 5 git commands to generate.