You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem Description:
When Fiber to Socket create fiber, it add an entry in cache map (fiber id -> fiber object), however later it update the fiber id in fiber object and add another duplicate entry in cache map.
This result in accumulation of stale entries in cache map, since key of cache holds stale fiber id.
Also fiber is shared ptr, which means fiber never get released since a reference still exist in those stale entries.
Fix
Iterate through the cache_map to find entries which have same fiber object and prune them during connection reset handling.
Here is my code to fix the issue in file basic_fiber_demux_impl.hpp
void erase_fiber_and_used_ports(const fiber_id& id) { std::unique_lock<std::recursive_mutex> lock1(bound_mutex); std::unique_lock<std::recursive_mutex> lock2(used_ports_mutex); auto it = bound.begin(); while (it != bound.end()) { if (it->second->id == id) { // bound cache key is reverse of fid, that's why // we have to extract remote port which is local port of fiber fiber_id::local_port_type local_port = it->first.remote_port(); it = bound.erase(it); used_ports.erase(local_port); } else { ++it; } } }
Call this function erase_fiber_and_used_ports from
void basic_fiber_demux_service::unbind(implementation_type impl, const fiber_id& id)
The text was updated successfully, but these errors were encountered:
Problem Description:
When Fiber to Socket create fiber, it add an entry in cache map (fiber id -> fiber object), however later it update the fiber id in fiber object and add another duplicate entry in cache map.
This result in accumulation of stale entries in cache map, since key of cache holds stale fiber id.
Also fiber is shared ptr, which means fiber never get released since a reference still exist in those stale entries.
Fix
Iterate through the cache_map to find entries which have same fiber object and prune them during connection reset handling.
Here is my code to fix the issue in file basic_fiber_demux_impl.hpp
void erase_fiber_and_used_ports(const fiber_id& id) { std::unique_lock<std::recursive_mutex> lock1(bound_mutex); std::unique_lock<std::recursive_mutex> lock2(used_ports_mutex); auto it = bound.begin(); while (it != bound.end()) { if (it->second->id == id) { // bound cache key is reverse of fid, that's why // we have to extract remote port which is local port of fiber fiber_id::local_port_type local_port = it->first.remote_port(); it = bound.erase(it); used_ports.erase(local_port); } else { ++it; } } }
Call this function erase_fiber_and_used_ports from
void basic_fiber_demux_service
::unbind(implementation_type impl, const fiber_id& id)The text was updated successfully, but these errors were encountered: