bugfix: socket read

This commit is contained in:
云风
2013-06-24 12:11:00 +08:00
parent 682f5c0eb6
commit f51e043dd6
2 changed files with 18 additions and 2 deletions

View File

@@ -33,7 +33,8 @@ skynet.register_protocol {
buf,bsz = buffer.push(buf, msg, sz)
end
READBUF[fd] = buf
if qsz == nil then
local session = READSESSION[fd]
if qsz == nil or session == nil then
return
end
if type(qsz) == "number" then
@@ -47,7 +48,8 @@ skynet.register_protocol {
end
end
response(READSESSION[fd])
response(session)
READSESSION[fd] = nil
end
}

View File

@@ -5,6 +5,7 @@ skynet.start(function()
local db = redis.connect "main"
print(db:select(0))
db:batch "write" -- ignore results
db:del "C"
db:set("A", "hello")
db:set("B", "world")
db:sadd("C", "one")
@@ -17,6 +18,19 @@ skynet.start(function()
for k,v in pairs(r) do
print(k,v)
end
db:batch "write"
db:del "D"
for i=1,1000 do
db:hset("D",i,i)
end
db:batch "end"
local r = db:hvals "D"
for k,v in pairs(r) do
print(k,v)
end
print(db:exists "A")
print(db:get "A")
print(db:set("A","hello world"))