set nodelay, see issue #763

This commit is contained in:
Cloud Wu
2017-11-14 18:01:08 +08:00
parent badfab8561
commit b51e28a3e0

View File

@@ -1,5 +1,6 @@
local skynet = require "skynet"
local socket = require "skynet.socket"
local socketdriver = require "skynet.socketdriver"
require "skynet.manager" -- import skynet.launch, ...
local table = table
@@ -41,6 +42,7 @@ local function connect_slave(slave_id, address)
local ok, err = pcall(function()
if slaves[slave_id] == nil then
local fd = assert(socket.open(address), "Can't connect to "..address)
socketdriver.nodelay(fd)
skynet.error(string.format("Connect to harbor %d (fd=%d), %s", slave_id, fd, address))
slaves[slave_id] = fd
monitor_clear(slave_id)
@@ -249,6 +251,7 @@ skynet.start(function()
local co = coroutine.running()
socket.start(slave_fd, function(fd, addr)
skynet.error(string.format("New connection (fd = %d, %s)",fd, addr))
socketdriver.nodelay(fd)
if pcall(accept_slave,fd) then
local s = 0
for k,v in pairs(slaves) do