Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

网络层的优雅关闭和强制关闭 #13

Closed
name5566 opened this issue Feb 24, 2016 · 2 comments
Closed

网络层的优雅关闭和强制关闭 #13

name5566 opened this issue Feb 24, 2016 · 2 comments
Milestone

Comments

@name5566
Copy link
Owner

socket 可以通过 LINGER 选项设置关闭时(close 和 shutdown)的行为(http://man7.org/linux/man-pages/man7/socket.7.html ),如果开启了 LINGER 则会尽可能的发送已经进入队列中的消息:

  1. 要么队列中的消息被全部发送完成
  2. 要么 LINGER 超时

在 Leaf 的网络层中,有一个类似的机制,但是和 socket 的行为有一些细微的差别:没有超时机制,在一些情况可能导致无限制的等待队列中的消息被发送。换而言之:

  1. Leaf 网络层连接的 Close 方法不能保证一定释放连接,但是它能保证一定尽可能的发送调用 Close 之前发送的消息(避免消息丢失)
  2. Leaf 网络层连接的 Destroy 方法不能保证调用 Destroy 之前发送的消息一定被发送,但是它能保证连接一定被释放
@name5566 name5566 added this to the 1.1.2 milestone Feb 24, 2016
@name5566
Copy link
Owner Author

在代码上,Leaf 会做一些细微调整,相关调整将放到 1.1.2 版本中。

@TongxiJi
Copy link

net.Conn setDeadTime(time.Now()) , 自带的这样关闭可以的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants