[vlma-devel] commit: vlc.telnet.delay is the minimum time to wait. (Adrien Grand )

git version control git at videolan.org
Sun Sep 14 01:59:17 CEST 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Sep 13 19:01:18 2008 +0200| [8d3df223064442621714877b5224ac5b52c60ecd] | committer: Adrien Grand 

vlc.telnet.delay is the minimum time to wait.

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

 .../java/org/videolan/vlma/order/OrderSender.java  |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/order/OrderSender.java b/vlma-core/src/main/java/org/videolan/vlma/order/OrderSender.java
index c07e1c0..8559fbb 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/order/OrderSender.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/order/OrderSender.java
@@ -47,7 +47,8 @@ public abstract class OrderSender {
     /**
      * Time to wait for during telnet connections.
      */
-    private static final int DEFAULT_TELNET_WAIT = 100;
+    private static final int TELNET_WAIT_INTERVAL = 100;
+    private static final int TELNET_WAIT_MAX = 5000;
 
     protected CommandLogger commandLogger;
 
@@ -101,10 +102,16 @@ public abstract class OrderSender {
         synchronized (adapter.getServer()) {
             logger.debug("Send command " + command + " to " + adapter.getServer().getName());
             telnetOut.println(command);
-            int d = configuration.getInt("vlc.telnet.delay");
-            while (!telnetIn.ready() && (d -= DEFAULT_TELNET_WAIT) > 0) {
+            try {
+                Thread.sleep(configuration.getInt("vlc.telnet.delay"));
+            } catch (InterruptedException e) {
+            }
+            int timeSleeped = 0;
+            // Continue to wait if the telnet interface is not ready yet, but
+            // not more than TELNET_WAIT_MAX ms.
+            while (!telnetIn.ready() && (timeSleeped += TELNET_WAIT_INTERVAL) <= TELNET_WAIT_MAX) {
                 try {
-                    Thread.sleep(DEFAULT_TELNET_WAIT);
+                    Thread.sleep(TELNET_WAIT_INTERVAL);
                 } catch (InterruptedException e) {
                 }
             }



More information about the vlma-devel mailing list