Updates for 2.0.1 on the way.

master
Diego Nehab 2006-03-19 21:22:21 +00:00
parent 09ad4b299c
commit 93806208c7
6 changed files with 26 additions and 62 deletions

48
TODO
View File

@ -1,25 +1,11 @@
ftp send should return server replies?
fix unix.c to return just a function make sure there are no object files in the distribution tarball
get rid of setmetatable(, nil) since packages don't need this anymore in http handling of 100-continue, see DB patch
5.1 DB ftp.lua bug.
test unix.c to return just a function and works with require"unix"
new instalation scheme??? get rid of setmetatable(, nil) since packages don't need this anymore in 5.1
compat-5.1 novo
test empty socket.select no windows. ajeitar pra lua-5.1
bug by mathew percival?
test it on Windows!!!
leave code for losers that don't have nanosleep
ftp.send/recv return bytes transfered?
new scheme to choose family/protocol of object to create
change ltn13 to make sure drawbacks are obvious
- check discussion
use mike's "don't set to blocking before closing unless needed" patch?
take a look at DB's smtp patch (add "extra argument" table)
adicionar exemplos de expansão: pipe, local, named pipe adicionar exemplos de expansão: pipe, local, named pipe
testar os options! testar os options!
@ -27,21 +13,3 @@ testar os options!
- proteger get*by*.* com um mutex GLOBAL! - proteger get*by*.* com um mutex GLOBAL!
- proteger ou atomizar o conjunto (timedout, receive), (timedout, send) - proteger ou atomizar o conjunto (timedout, receive), (timedout, send)
- inet_ntoa também é uma merda. - inet_ntoa também é uma merda.
* protect doesn't catch errors by error and assert
* BUG NO SET DO TINYIRC!!! SINISTRO.
* _VERSION, _DEBUG, etc.
* talk about new create field in HTTP, FTP and SMTP
* talk about the non-blocking connect in the manual
* think about how to extend http, ftp, smtp to use special send and receive
* functions for non-blocking so they can be used in the context of the
* dispatcher!
* adjust manual for new sock:send returns.
* think about a dispatcher.
* - it creates a server and receives a function that will do the work on
* received connections
* - this function is invoked with the client socket
* - it calls special send and receive functions that yield on timeout
* arranjar um jeito de fazer multipart/alternative
* what the hell does __unload do?
* it's there just in case someone wants to use it.

2
config
View File

@ -21,7 +21,7 @@ LUALIB=-Llua-5.0.2/lib
#------ #------
# Compat-5.1 directory # Compat-5.1 directory
# #
COMPAT=compat-5.1r4 COMPAT=compat-5.1r5
#------ #------
# Top of your Lua installation # Top of your Lua installation

View File

@ -5,6 +5,7 @@
-- RCS ID: $$ -- RCS ID: $$
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
local base = _G local base = _G
local table = require("table")
local socket = require("socket") local socket = require("socket")
local coroutine = require("coroutine") local coroutine = require("coroutine")
module("dispatch") module("dispatch")
@ -50,7 +51,7 @@ function socket.protect(f)
return function(...) return function(...)
local co = coroutine.create(f) local co = coroutine.create(f)
while true do while true do
local results = {coroutine.resume(co, unpack(arg))} local results = {coroutine.resume(co, base.unpack(arg))}
local status = table.remove(results, 1) local status = table.remove(results, 1)
if not status then if not status then
if type(results[1]) == 'table' then if type(results[1]) == 'table' then
@ -58,9 +59,9 @@ function socket.protect(f)
else error(results[1]) end else error(results[1]) end
end end
if coroutine.status(co) == "suspended" then if coroutine.status(co) == "suspended" then
arg = {coroutine.yield(unpack(results))} arg = {coroutine.yield(base.unpack(results))}
else else
return unpack(results) return base.unpack(results)
end end
end end
end end
@ -72,7 +73,7 @@ end
local function newset() local function newset()
local reverse = {} local reverse = {}
local set = {} local set = {}
return setmetatable(set, {__index = { return base.setmetatable(set, {__index = {
insert = function(set, value) insert = function(set, value)
if not reverse[value] then if not reverse[value] then
table.insert(set, value) table.insert(set, value)
@ -105,7 +106,7 @@ local function cowrap(dispatcher, tcp, error)
local metat = { __index = function(table, key) local metat = { __index = function(table, key)
table[key] = function(...) table[key] = function(...)
arg[1] = tcp arg[1] = tcp
return tcp[key](unpack(arg)) return tcp[key](base.unpack(arg))
end end
return table[key] return table[key]
end} end}
@ -202,7 +203,7 @@ local function cowrap(dispatcher, tcp, error)
dispatcher.receiving.cortn[tcp] = nil dispatcher.receiving.cortn[tcp] = nil
return tcp:close() return tcp:close()
end end
return setmetatable(wrap, metat) return base.setmetatable(wrap, metat)
end end
@ -253,17 +254,17 @@ function cometat.__index:step()
self.sending.set, 1) self.sending.set, 1)
-- for all readable connections, resume their cortns and reschedule -- for all readable connections, resume their cortns and reschedule
-- when they yield back to us -- when they yield back to us
for _, tcp in ipairs(readable) do for _, tcp in base.ipairs(readable) do
schedule(wakeup(self.receiving, tcp)) schedule(wakeup(self.receiving, tcp))
end end
-- for all writable connections, do the same -- for all writable connections, do the same
for _, tcp in ipairs(writable) do for _, tcp in base.ipairs(writable) do
schedule(wakeup(self.sending, tcp)) schedule(wakeup(self.sending, tcp))
end end
-- politely ask replacement I/O functions in idle cortns to -- politely ask replacement I/O functions in idle cortns to
-- return reporting a timeout -- return reporting a timeout
local now = socket.gettime() local now = socket.gettime()
for tcp, stamp in pairs(self.stamp) do for tcp, stamp in base.pairs(self.stamp) do
if tcp.class == "tcp{client}" and now - stamp > TIMEOUT then if tcp.class == "tcp{client}" and now - stamp > TIMEOUT then
abort(self.sending, tcp) abort(self.sending, tcp)
abort(self.receiving, tcp) abort(self.receiving, tcp)
@ -296,6 +297,6 @@ function handlert.coroutine()
function dispatcher.tcp() function dispatcher.tcp()
return cowrap(dispatcher, socket.tcp()) return cowrap(dispatcher, socket.tcp())
end end
return setmetatable(dispatcher, cometat) return base.setmetatable(dispatcher, cometat)
end end

View File

@ -268,7 +268,7 @@ function tredirect(reqt, location)
headers = reqt.headers, headers = reqt.headers,
proxy = reqt.proxy, proxy = reqt.proxy,
nredirects = (reqt.nredirects or 0) + 1, nredirects = (reqt.nredirects or 0) + 1,
connect = reqt.connect create = reqt.create
} }
-- pass location header back as a hint we redirected -- pass location header back as a hint we redirected
headers.location = headers.location or location headers.location = headers.location or location

View File

@ -1,3 +1,5 @@
local dict = require"socket.dict" local dict = require"socket.dict"
print(dict.get("dict://localhost/d:teste"))
for i,v in pairs(dict.get("dict://localhost/d:teste")) do print(v) end for i,v in pairs(dict.get("dict://localhost/d:teste")) do print(v) end

View File

@ -32,13 +32,6 @@ r, e = smtp.send{
port = 2525 port = 2525
} }
os.exit()
-- creates a source to send a message with two parts. The first part is -- creates a source to send a message with two parts. The first part is
-- plain text, the second part is a PNG image, encoded as base64. -- plain text, the second part is a PNG image, encoded as base64.
source = smtp.message{ source = smtp.message{
@ -67,13 +60,13 @@ source = smtp.message{
-- chunks are loaded into memory and translation happens on the fly. -- chunks are loaded into memory and translation happens on the fly.
[2] = { [2] = {
headers = { headers = {
["content-type"] = 'image/png; name="image.png"', ["content-type"] = 'image/png; name="luasocket.png"',
["content-disposition"] = 'attachment; filename="image.png"', ["content-disposition"] = 'attachment; filename="luasocket.png"',
["content-description"] = 'a beautiful image', ["content-description"] = 'a beautiful image',
["content-transfer-encoding"] = "BASE64" ["content-transfer-encoding"] = "BASE64"
}, },
body = ltn12.source.chain( body = ltn12.source.chain(
ltn12.source.file(io.open("image.png", "rb")), ltn12.source.file(io.open("luasocket.png", "rb")),
ltn12.filter.chain( ltn12.filter.chain(
mime.encode("base64"), mime.encode("base64"),
mime.wrap() mime.wrap()