mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
set nodelay, see issue #763
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
local socket = require "skynet.socket"
|
local socket = require "skynet.socket"
|
||||||
|
local socketdriver = require "skynet.socketdriver"
|
||||||
require "skynet.manager" -- import skynet.launch, ...
|
require "skynet.manager" -- import skynet.launch, ...
|
||||||
local table = table
|
local table = table
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ local function connect_slave(slave_id, address)
|
|||||||
local ok, err = pcall(function()
|
local ok, err = pcall(function()
|
||||||
if slaves[slave_id] == nil then
|
if slaves[slave_id] == nil then
|
||||||
local fd = assert(socket.open(address), "Can't connect to "..address)
|
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))
|
skynet.error(string.format("Connect to harbor %d (fd=%d), %s", slave_id, fd, address))
|
||||||
slaves[slave_id] = fd
|
slaves[slave_id] = fd
|
||||||
monitor_clear(slave_id)
|
monitor_clear(slave_id)
|
||||||
@@ -249,6 +251,7 @@ skynet.start(function()
|
|||||||
local co = coroutine.running()
|
local co = coroutine.running()
|
||||||
socket.start(slave_fd, function(fd, addr)
|
socket.start(slave_fd, function(fd, addr)
|
||||||
skynet.error(string.format("New connection (fd = %d, %s)",fd, addr))
|
skynet.error(string.format("New connection (fd = %d, %s)",fd, addr))
|
||||||
|
socketdriver.nodelay(fd)
|
||||||
if pcall(accept_slave,fd) then
|
if pcall(accept_slave,fd) then
|
||||||
local s = 0
|
local s = 0
|
||||||
for k,v in pairs(slaves) do
|
for k,v in pairs(slaves) do
|
||||||
|
|||||||
Reference in New Issue
Block a user