socket clsoe 是否从epoll set 中删除

man epoll

   Q6  Will closing a file descriptor cause it to be removed from all epoll sets automatically?

   A6  Yes,  but  be  aware of the following point.  A file descriptor is a reference to an open file description (see open(2)).  Whenever a descriptor is
       duplicated via dup(2), dup2(2), fcntl(2) F_DUPFD, or fork(2), a new file descriptor referring to the same open file  description  is  created.   An
       open  file  description continues to exist until all file descriptors referring to it have been closed.  A file descriptor is removed from an epoll
       set only after all the file descriptors referring to the underlying open file description have been closed (or before if the descriptor is  explic-
       itly  removed using epoll_ctl(2) EPOLL_CTL_DEL).  This means that even after a file descriptor that is part of an epoll set has been closed, events
       may be reported for that file descriptor if other file descriptors referring to the same underlying file description remain open.

只要这个socket没有被dup fcntl fork等函数拷贝,就会自动删除。言外之意就是,当close是真的释放了文件描述符资源,而不是减少文件描述的引用计数的话,就会自动从epoll set 中删除

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值