Comments (4)
Email reply:
Hi Edwin,
Thanks for reaching out to me and for the detailed explanation!
Technically, when the tcp_client is destroyed, it will call .disconnect(true) internally.
Note that we pass true as a parameter, which enables the option wait_for_removal.
This option blocks the thread until all pending callbacks are processed.
Considering your case, it seems that this waiting process does not occur.
In such case, when going through the code of the tcp_client, the only possibility would be:
disconnect() is called after a read or a write failure. In such case, wait_for_removal is not set to true, which means the function returns right away.
when the tcp_client is destroyed, the destructor is called, leading to disconnect to be called. But because the client is already marked as disconnected, the function returns right away.
This would match your current context where the client fails to read from the remote server.
Even though the .disconnect prevents the insertion of new write requests and clear the write requests, it is indeed true that there may be a thread notifying the tcp_client about a write event on the socket because we started to watch before the disconnection.
However, the fix is not as trivial as it may sound:
Calling disconnect(true) from the read or write callback will block indefinitely: it would wait for the callbacks to be executed, but the callback is waiting for itself to complete
Always waiting for callback cleanup in the destructor can also be an issue: if the client is disconnected, and the socket closed as it is right now, the socket file descriptor might be reused by the operating system when initiating a new socket. Then, when trying to wait for a cleanup, we will actually wait for the cleanup of another socket.
I guess the best solution at the moment would be:
Always check for callback cleanup when the destructor is called, even if the client has been marked as disconnected
Do not close the socket until the client is destroyed. That would avoid the operating system to reuse the same socket identifier.
I'm gonna have a fix and will try to release that ASAP, will keep you up to date :)
Best and thanks a lot for reporting that, really appreciate!
from tacopie.
Status of this issue is on-going, fix should be release soon, sorry for the delay.
from tacopie.
Fixed in 9c9b9d4
from tacopie.
The implementation had some issues, I rollback the change and reopen the issue.
from tacopie.
Related Issues (20)
- Inconsistent async_read behaviour after 2.4.3 HOT 6
- if obj outputs to same path,will make error on the link. HOT 2
- Wiki possibly out of date for newest VS15 (2017) HOT 1
- Windows dynamic port range HOT 2
- when connect timeout is 0, connnect fail on same operating systems. HOT 2
- Build dynamic library failed on Windows HOT 10
- Conan package HOT 1
- How to make a broadcast on tcp server? HOT 2
- BAD HOT 1
- How can I use the tacopie server to send a lot of messages? HOT 2
- Does this library support unicode?
- Tacopie client: UDP? HOT 1
- change select with poll or epoll HOT 1
- Hello, may I ask how to handle network packets in the program?
- Running on vis. std. 2017
- How can I compile tacopie with Qt Creator? HOT 1
- tacopie thread_pool class variable m_nb_running_threads should lock to avoid race condition? HOT 3
- Branch on a garbage value
- smembers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tacopie.