summaryrefslogtreecommitdiff
path: root/nopsyncd/tcpserver.lua
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-03-08 18:07:24 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-03-08 18:07:24 (GMT)
commitaa50ae92057db36e033b157bbe393d6c7df9fc05 (patch)
tree1c1d9469d625784f7e038d4c445eaf72055a2587 /nopsyncd/tcpserver.lua
parent914ee9d782bdd514058bf90ed118523a252bcc02 (diff)
added pipe between worker threads
Diffstat (limited to 'nopsyncd/tcpserver.lua')
-rwxr-xr-xnopsyncd/tcpserver.lua25
1 files changed, 24 insertions, 1 deletions
diff --git a/nopsyncd/tcpserver.lua b/nopsyncd/tcpserver.lua
index e7df4e5..ff338ac 100755
--- a/nopsyncd/tcpserver.lua
+++ b/nopsyncd/tcpserver.lua
@@ -22,5 +22,28 @@ require "socket"
function main_loop()
- socket.select(nil, nil, 10)
+ local pipefd = pipe.getreadfd()
+
+ while true do
+ local readable, _, err = socket.select({ pipefd } , nil)
+ if(err) then
+ print("select returned with error: " .. err)
+ return -1
+ else
+ for _, input in ipairs(readable) do
+ if(input == pipefd) then
+ local ret = pipe.consume()
+ if ret == 1 then
+ print("pipe was signaled")
+ else
+ return ret
+ end
+ else
+ print("select returned unknown file descriptor!?")
+ end
+ end
+ end
+ end
+
+ return 0
end \ No newline at end of file