[vlma-devel] commit: Fix deadlock. (Adrien Grand )

git version control git at videolan.org
Wed Feb 4 05:19:58 CET 2009


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Wed Feb  4 05:19:24 2009 +0100| [15f5f58dd806c79670d44aef0d3087881f7256eb] | committer: Adrien Grand 

Fix deadlock.

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

 .../vlma/order/management/OrderManager.java        |   38 ++++++++++---------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/order/management/OrderManager.java b/vlma-core/src/main/java/org/videolan/vlma/order/management/OrderManager.java
index e7cf833..647d2c3 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/order/management/OrderManager.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/order/management/OrderManager.java
@@ -175,26 +175,28 @@ public class OrderManager {
     /**
      * Give orders.
      */
-    public synchronized void giveOrders() {
+    public void giveOrders() {
         Map<Server, SendOrder> sendThreads = new HashMap<Server, SendOrder>();
-        for (Map.Entry<String, Map.Entry<Order, State>> entry : orders.entrySet()) {
-            Order order = entry.getValue().getKey();
-            SendOrder sendThread = sendThreads.get(order.getAdapter().getServer());
-            if(sendThread == null) {
-                sendThread = new SendOrder();
-                sendThreads.put(order.getAdapter().getServer(), sendThread);
-            }
-            switch(entry.getValue().getValue()) {
-            case TO_START:
-                sendThread.addOrder(order);
-                break;
-            case TO_STOP:
-                if (order.getAdapter().getServer().isUp()) {
-                    sendThread.removeOrder(order);
+        synchronized (this) {
+            for (Map.Entry<String, Map.Entry<Order, State>> entry : orders.entrySet()) {
+                Order order = entry.getValue().getKey();
+                SendOrder sendThread = sendThreads.get(order.getAdapter().getServer());
+                if(sendThread == null) {
+                    sendThread = new SendOrder();
+                    sendThreads.put(order.getAdapter().getServer(), sendThread);
+                }
+                switch(entry.getValue().getValue()) {
+                case TO_START:
+                    sendThread.addOrder(order);
+                    break;
+                case TO_STOP:
+                    if (order.getAdapter().getServer().isUp()) {
+                        sendThread.removeOrder(order);
+                    }
+                    break;
+                default:
+                    break;
                 }
-                break;
-            default:
-                break;
             }
         }
         // Start threads, one per server



More information about the vlma-devel mailing list