Author: titmuss
Date: Mon May 12 06:26:26 2008
New Revision: 2436

URL: http://svn.slimdevices.com?rev=2436&root=Jive&view=rev
Log:
Bug: 7120
Description:
Fix windows arp lookup on windows. This was causing an infinite loop when 
starting squeezeplay on windows.

Async processes do not work on windows, so any Process call is blocking, and 
the results return immediately.

Modified:
    7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
    7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Process.lua

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua?rev=2436&root=Jive&r1=2435&r2=2436&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua 
(original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua Mon 
May 12 06:26:26 2008
@@ -32,6 +32,7 @@
 local _assert, tostring, table, ipairs, pairs, pcall, select, type  = _assert, 
tostring, table, ipairs, pairs, pcall, select, type
 
 local io                = require("io")
+local os                = require("os")
 local socket            = require("socket")
 local string            = require("string")
 local table             = require("jive.utils.table")
@@ -339,20 +340,28 @@
 function arp(self, host, sink)
        local arp = ""
 
-       -- XXXX this won't work on windows
-
-       local proc = Process(self, "arp " .. host)
+       local cmd = "arp " .. host
+       if string.match(os.getenv("OS"), "Windows") then
+                       cmd = "arp -a " .. host
+       end
+       
+       local proc = Process(self, cmd)
        proc:read(function(chunk, err)
-                         if err then
-                                 return sink(err)
-                         end
-
-                         if chunk then
-                                 arp = arp .. chunk
-                         else
-                                 sink(string.match(arp, 
"%x%x:%x%x:%x%x:%x%x:%x%x:%x%x"))
-                         end
-                 end)
+                       if err then
+                                       return sink(err)
+                       end
+
+                       if chunk then
+                                       arp = arp .. chunk
+                       else
+                                       local mac = string.match(arp, 
"%x%x[:-]%x%x[:-]%x%x[:-]%x%x[:-]%x%x[:-]%x%x")
+                                       if mac then
+                                                       mac = string.gsub(mac, 
"-", ":")
+                                       end
+                                       
+                                       sink(mac)
+                       end
+       end)
 end
 
 

Modified: 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Process.lua
URL: 
http://svn.slimdevices.com/7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Process.lua?rev=2436&root=Jive&r1=2435&r2=2436&view=diff
==============================================================================
--- 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Process.lua (original)
+++ 7.1/trunk/squeezeplay/src/squeezeplay/share/jive/net/Process.lua Mon May 12 
06:26:26 2008
@@ -2,7 +2,9 @@
 
 local oo              = require("loop.base")
 local io              = require("io")
+local os              = require("os")
 local coroutine       = require("coroutine")
+local string          = require("string")
 
 local Task            = require("jive.ui.Task")
 
@@ -32,6 +34,16 @@
 
                self._status = "dead"
                return
+       end
+
+       if string.match(os.getenv("OS"), "Windows") then
+                       -- blocking on Windows!
+                       local chunk = self.fh:read("*a")
+                       self.fh:close()
+                       
+                       sink(chunk)
+                       sink(nil)
+                       return
        end
 
        local task = Task("prog:" .. self.prog,

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to