msghub
msghub copied to clipboard
join() never completes because of outstanding operations
Even on a publish-only channel there will be an extant async_read via hubconnection.
On publishers there will be an accept loop.
Both need cancelling.
Actually this needs bit more work, because one does not by default want to cut operations in the middle of sending output.
I suggest giving do_close
a bool flag forced
to indicate whether pending write operations (operations for which we own the initiative) are to be forcibly interrupted.
Existing locations to invoke do_close
in error conditions shall supply forced = true
. Other cases should default to forced = false
so as to make sure that simple client programs will work as expected:
msghub msghub(io_service);
msghub.connect("localhost", 1334);
msghub.publish("Publish", "new message");
//msghub.join(); // implied
Here the message should be expected to be delivered, regardless of timings. Of course barring connectivity issues, in which case do_close(forced = true)
should happen because of the error condition.