Golang实现windows两个应用程序进程间通信之二Winio的Bug

warning: 这篇文章距离上次修改已过267天,其中的内容可能已经有所变动。

Golang实现windows两个应用程序进程间通信之二Winio的Bug

上回提到源码能正常跑起来了,但多次测试后发现有个很严重的问题。在win7下,客户端首次dial时成功连接上后write就阻塞了,而且服务端并没有收到新的请求,一直阻塞在Accept。刚开始还以为自己的代码有问题,试了很多次,才发现这个Bug。网上的代码其实没问题,只是我这Win7系统,直接触发Bug了。

github https://github.com/microsoft/go-winio/issues/173 上有提到这个问题,但官方并没有修复,有人判断是因为微软不再更新Win7了。

I was trying go-winio in my project, but I noticed that the same code had different results in Win 7 and Win 10. In Win 7, the client was hanged on first connecting after server restarted, and worked correctly after the second time. After debugged and found that server's syscall.getQueuedCompletionStatus couldn't be triggered when the client first connected. Then I tried to find the reason and noticed that win32PipeListener.firstHandle's access was syscall.SYNCHRONIZE. I found they created named pipe with full access in the loop in this example, so I tried to modify code and the bellow is the diff block.

我的解决方法很粗爆,首次连接后直接close,然后再次连接,有精力的还是老老实实啃代码改好吧!

image-20230815141350232

none
最后修改于:2023年08月15日 14:15

评论已关闭