一些OVERLAPS使用WSASend不能及时返回使用GetQueuedCompletionStatus? [英] some OVERLAPS using WSASend not returning in a timely manner using GetQueuedCompletionStatus?

查看:125
本文介绍了一些OVERLAPS使用WSASend不能及时返回使用GetQueuedCompletionStatus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景:我使用CreateIoCompletionPort,WSASend / Recv和GetQueuedCompletionStatus在我的服务器上做重叠套接字io。对于流控制,当发送到客户端时,我只允许在所有挂起的OVERLAP从IOCP弹出时调用几个WSASend()。

Background: I'm using CreateIoCompletionPort, WSASend/Recv, and GetQueuedCompletionStatus to do overlapped socket io on my server. For flow control, when sending to the client, I only allow several WSASend() to be called when all pending OVERLAPs have popped off the IOCP.

问题:最近,当OVERLAP没有返回到IOCP时,有一些情况。线程调用GetQueuedCompletionStatus不会得到它们,它们仍然在我的本地挂起队列。我已经验证,客户端从接收数据关闭套接字和套接字连接。在WSASend()调用时没有返回错误。 OVERLAP只是从不没有外部刺激,如下所示:

Problem: Recently, there are occassions when the OVERLAPs do not get returned to the IOCP. The thread calling GetQueuedCompletionStatus does not get them and they remain in my local pending queue. I've verified that the client DOES receive the data off the socket and the socket is connected. No errors were returned when the WSASend() calls were made. The OVERLAPs simply "never" come back without an external stimulus like the following:


  1. 断开套接字与客户端或服务器的连接,立即允许GetQueuedCompletionStatus线程检索OVERLAP

  2. 在所有OVERLAP突然弹出队列之前,有时需要多次调用WSASend()。



    问题:有没有人看到这种行为?任何想法是什么导致这一点?

Question: Has anyone seen this type of behavior? Any ideas on what is causing this?

感谢您,
Geoffrey

Thanks, Geoffrey

推荐答案

如果TCP窗口已满,WSASend()可能无法及时完成。在这种情况下,堆栈不能再发送任何数据,所以你的 WSASend()等待,你的完成不会发生,直到TCP堆栈CAN发送更多的数据。

WSASend() can fail to complete in a timely manner if the TCP window is full. In this case the stack can't send any more data so your WSASend() waits and your completion doesn't occur until the TCP stack CAN send more data.

如果您碰巧在您的客户端和服务器之间有一个没有内置在协议本身中的流控制的协议,并且您没有根据写完成自己执行任何流控制,只是以服务器可以发送的速度发送数据,那么您可能会遇到网络或客户端无法跟上并且TCP流控制启动(当TCP窗口已满时)的点。如果你继续只是触发数据异步与额外的调用 WSASend(),然后最终你会嚼你的方式通过机器上的所有非分页内存和这一点所有的赌注都关闭(机会是高的驱动程序可能会导致框蓝屏)。

If you happen to have a protocol between your client and server that has no flow control built into the protocol itself AND you aren't doing any flow control yourself based on write completions and are just sending data as fast as your server can send then you may get to a point where either the network or your client can't keep up and TCP flow control kicks in (when the TCP window gets full). If you continue to just fire off data asynchronously with additional calls to WSASend() then eventually you'll chew your way through all of the non-paged memory on the machine and at that point all bets are off (chances are high that a driver may cause the box to bluescreen).

所以,总之,重叠套接字写入的完成可以,需要更长的时间回来比你可能期望。在你的例子中,我期望你关闭套接字时获得的完成都是失败的?

So, in summary, completions from overlapped socket writes can and will sometimes take longer to come back than you may expect. In your example, I expect that the completions that you get when you close the socket are all failures?

我在我的博客上谈论这个更多;这里: http://www.lenholgate.com/blog /2008/07/write-completion-flow-control.html 和此处: http://www.serverframework.com/asynchronousevents/2011/06/tcp-flow-control-and-asynchronous-writes.html

I talk about this some more on my blog; here: http://www.lenholgate.com/blog/2008/07/write-completion-flow-control.html and here: http://www.serverframework.com/asynchronousevents/2011/06/tcp-flow-control-and-asynchronous-writes.html

这篇关于一些OVERLAPS使用WSASend不能及时返回使用GetQueuedCompletionStatus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆