end
end
+function cosend(socket, chunk, i, ...)
+ threadi[socket] = true
+ i = i or 1
+
+ while true do
+ local stat, err, sent = socket:send(chunk, i, ...)
+
+ if err ~= "timeout" then
+ threadi[socket] = false
+ return stat, err, sent
+ else
+ i = sent and (sent + 1) or 1
+ end
+
+ coroutine.yield()
+ end
+end
+
function register(socket, s_clhandler, s_errhandler)
table.insert(reading, socket)
clhandler[socket] = s_clhandler
-- Setup sockets and sources
local thread = {
- receive = function(self, ...) return luci.httpd.corecv(client, ...) end
+ receive = function(self, ...) return luci.httpd.corecv(client, ...) end,
+ send = function(self, ...) return luci.httpd.cosend(client, ...) end
}
client:settimeout( 0 )
end
- local sinkout = socket.sink(sinkmode, client)
+ local sinkout = socket.sink(sinkmode, thread)
local header =
message.env.SERVER_PROTOCOL .. " " ..