[英]boost::asio::deadline_timer not expiring after async_read() and async_write() is done in timer handler
I have an async_connected() client, single threaded, and my deadline_timer
is persisted as a member of some connection class. 我有一个async_connected()客户端,单线程,我的
deadline_timer
作为某个连接类的成员持久化。 My deadline_timer
only goes off once and I'm trying to do 3 things when my deadline_timer expires: 我的
deadline_timer
只有一次,我在deadline_timer到期时尝试做3件事:
The send and read work, the problem is the timer never expires again. 发送和读取工作,问题是计时器永远不会再过期。
io_service.run()
didn't not stop as the line right after it is not printed... Why is my deadline_timer
not expiring again? io_service.run()
并没有因为没有打印后的行而停止...为什么我的deadline_timer
不会再次到期?
I figured out what I was doing wrong, not sure why it resulted in the symptoms that I saw, but when I read with async_read()
in the deadline_timer
handler, after I was done I cleared out my boost::asio::buffer
receive buffer with memset()
after every read. 我弄清楚我做错了什么,不知道为什么它会导致我看到的症状,但是当我在
deadline_timer
处理程序中使用async_read()
读取时,在我完成后我清除了我的boost::asio::buffer
receive每次读取后用memset()
缓冲。 I know I probably do not need this memory cleanup. 我知道我可能不需要这种内存清理。 The problem was that I was clearing more memory than I gave
async_read()
with the receive buffer, so I was memsetting invalid locations. 问题是我清理了比使用接收缓冲区的
async_read()
更多的内存,所以我设置了无效的位置。 I am not sure why that resulted in the deadline_timer
never firing again and also async_read()
didn't work again after that either. 我不确定为什么导致
deadline_timer
再也没有触发,并且async_read()
也没有再次工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.