-
Notifications
You must be signed in to change notification settings - Fork 370
AMQP::LibBoostAsioHandler::Watcher "memory leak" #238
Description
The Watcher code uses 2 boolean flags, _read_pending and _write_pending, to attempt to prevent more than one read and write ASIO operation from being posted at a time. Unfortunately, the existing implementation is not thread-safe, since changes in the boolean values are not necessarily visible to all threads at the same time. The net result is that the ASIO queues end up with requests that are never processed, and it appears like a slow but always growing memory leak that will eventually consume all available memory.
I've attached my changes to these flags (std::atomic ...) that require C++11 support. compare_exchange_strong() is used to prevent more than one thread from posting a read or write operation at a time. This version of libboostasio.h has also been modified for using asio in standalone mode (and all other boost support has been removed through the use of lambdas everywhere). This code has been tested and verified. There are other ways of addressing this issue, of course, so your mileage may vary...