mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
add nodelay option in socketchannel
This commit is contained in:
@@ -129,6 +129,7 @@ function mongo.client( conf )
|
|||||||
response = dispatch_reply,
|
response = dispatch_reply,
|
||||||
auth = mongo_auth(obj),
|
auth = mongo_auth(obj),
|
||||||
backup = backup,
|
backup = backup,
|
||||||
|
nodelay = true,
|
||||||
}
|
}
|
||||||
setmetatable(obj, client_meta)
|
setmetatable(obj, client_meta)
|
||||||
obj.__sock:connect(true) -- try connect only once
|
obj.__sock:connect(true) -- try connect only once
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ function redis.connect(db_conf)
|
|||||||
host = db_conf.host,
|
host = db_conf.host,
|
||||||
port = db_conf.port or 6379,
|
port = db_conf.port or 6379,
|
||||||
auth = redis_login(db_conf.auth, db_conf.db),
|
auth = redis_login(db_conf.auth, db_conf.db),
|
||||||
|
nodelay = true,
|
||||||
}
|
}
|
||||||
-- try connect first only once
|
-- try connect first only once
|
||||||
channel:connect(true)
|
channel:connect(true)
|
||||||
@@ -199,6 +200,7 @@ function redis.watch(db_conf)
|
|||||||
host = db_conf.host,
|
host = db_conf.host,
|
||||||
port = db_conf.port or 6379,
|
port = db_conf.port or 6379,
|
||||||
auth = watch_login(obj, db_conf.auth),
|
auth = watch_login(obj, db_conf.auth),
|
||||||
|
nodelay = true,
|
||||||
}
|
}
|
||||||
obj.__sock = channel
|
obj.__sock = channel
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
local socket = require "socket"
|
local socket = require "socket"
|
||||||
|
local socketdriver = require "socketdriver"
|
||||||
|
|
||||||
-- channel support auto reconnect , and capture socket error in request/response transaction
|
-- channel support auto reconnect , and capture socket error in request/response transaction
|
||||||
-- { host = "", port = , auth = function(so) , response = function(so) session, data }
|
-- { host = "", port = , auth = function(so) , response = function(so) session, data }
|
||||||
@@ -37,6 +38,7 @@ function socket_channel.channel(desc)
|
|||||||
__sock = false,
|
__sock = false,
|
||||||
__closed = false,
|
__closed = false,
|
||||||
__authcoroutine = false,
|
__authcoroutine = false,
|
||||||
|
__nodelay = desc.nodelay,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(c, channel_meta)
|
return setmetatable(c, channel_meta)
|
||||||
@@ -186,6 +188,9 @@ local function connect_once(self)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if self.__nodelay then
|
||||||
|
socketdriver.nodelay(fd)
|
||||||
|
end
|
||||||
|
|
||||||
self.__sock = setmetatable( {fd} , channel_socket_meta )
|
self.__sock = setmetatable( {fd} , channel_socket_meta )
|
||||||
skynet.fork(dispatch_function(self), self)
|
skynet.fork(dispatch_function(self), self)
|
||||||
|
|||||||
Reference in New Issue
Block a user