]> git.sesse.net Git - vlc/blobdiff - share/lua/intf/telnet.lua
Lua_telnet: if the telnet client program quit, close the connection correctly.
[vlc] / share / lua / intf / telnet.lua
index 2f7bd3f12576b77d25b84f1a7b16d6354badc744..89a478669ca50ccc74e19ea5b9f90f7b4c4d5243 100644 (file)
@@ -172,8 +172,7 @@ end
 
 --[[ The main loop ]]
 while not vlc.misc.should_die() do
-    h:accept()
-    local w, r = h:select( 0.1 )
+    local w, r = h:accept_and_select()
 
     -- Handle writes
     for _, client in pairs(w) do
@@ -186,7 +185,10 @@ while not vlc.misc.should_die() do
     for _, client in pairs(r) do
         local str = client:recv(1000)
         local done = false
-        if string.match(str,"\n$") then
+        if not str then -- the telnet client program has leave
+            client.buffer = "quit"
+            done = true
+        elseif string.match(str,"\n$") then
             client.buffer = string.gsub(client.buffer..str,"\r?\n$","")
             done = true
         elseif client.buffer == ""