[vlma-devel] commit: Ensure to never cancel a valid order. (Adrien Grand )

git version control git at videolan.org
Tue Sep 2 21:32:22 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Tue Sep  2 21:34:32 2008 +0200| [4d90612c47feac469235238bdc49f941e437dab7] | committer: Adrien Grand 

Ensure to never cancel a valid order.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=4d90612c47feac469235238bdc49f941e437dab7
---

 .../main/java/org/videolan/vlma/OrderGiver.java    |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java b/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
index c42ed59..7e62a3a 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/OrderGiver.java
@@ -293,7 +293,8 @@ public class OrderGiver {
             if (logger.isDebugEnabled())
                 logger.debug(newOrders.size() + " orders have been computed");
             Set<Order> oldOrders = new HashSet<Order>();
-            synchronized(vlmaService.getOrders()) {
+            Set<Order> orders = vlmaService.getOrders();
+            synchronized(orders) {
                 oldOrders.addAll(vlmaService.getOrders());
 
                 // Remove former orders
@@ -335,8 +336,12 @@ public class OrderGiver {
                     } catch (InterruptedException e) { }
                 }
 
-                vlmaService.getOrders().removeAll(oldOrders);
-                vlmaService.getOrders().addAll(newOrders);
+                orders.removeAll(oldOrders);
+                orders.addAll(newOrders);
+                Set<Order> ordersToCancel = vlmaService.getOrders();
+                synchronized (ordersToCancel) {
+                    ordersToCancel.removeAll(orders);
+                }
             }
             logger.info("Orders sent in " + (System.currentTimeMillis() - start) + "ms");
         }



More information about the vlma-devel mailing list