epoll socket,strace跟踪发现有时卡在close(12处

leinx5 2010-06-11 05:02:34
epoll et模式的socket服务,用strace跟踪,经常发现strace出来的信息卡在

close(n

显示一个close(123后面没有输出,然后半天才出来后面的)括号,

以前我只close(fd_id);现在先shut_down(fd_id,2),再close(fd_id);

问题没有解决

请谈谈你知道的,谢谢!
...全文
249 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
leinx5 2010-06-12
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 do_fork 的回复:]

C/C++ code
SO_LINGER
Sets or gets the SO_LINGER option. The argument is a linger
structure.

struct linger {
int l_ono……
[/Quote]

nnd,我就是为了解决问题,才加了那么一条,没想到起了反作用啊
do_fork 2010-06-12
  • 打赏
  • 举报
回复
所以要多看man阿,epoll和socket的manpages很详细
delphiwcdj 2010-06-11
  • 打赏
  • 举报
回复
UP!
AlanBruce 2010-06-11
  • 打赏
  • 举报
回复
为什么你要频繁调用close(fd_id);
liutengfeigo 2010-06-11
  • 打赏
  • 举报
回复
ForestDB 2010-06-11
  • 打赏
  • 举报
回复
帮顶。
cattycat 2010-06-11
  • 打赏
  • 举报
回复
从7楼给的资料看来真是阻塞操作或延时的操作。
明天再查下相关的资料,这块我也不是很熟悉。
do_fork 2010-06-11
  • 打赏
  • 举报
回复
       SO_LINGER
Sets or gets the SO_LINGER option. The argument is a linger
structure.

struct linger {
int l_onoff; /* linger active */
int l_linger; /* how many seconds to linger for */
};

When enabled, a close(2) or shutdown(2) will not return until
all queued messages for the socket have been successfully sent
or the linger timeout has been reached. Otherwise, the call
returns immediately and the closing is done in the background.
When the socket is closed as part of exit(2), it always lingers
in the background.
2010-06-11
  • 打赏
  • 举报
回复
我猜的:会不会是在等待 close 返回?
leinx5 2010-06-11
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhoutanliang 的回复:]
为什么你要频繁调用close(fd_id);
[/Quote]

不是频繁,而是需要时

69,369

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧