msghub icon indicating copy to clipboard operation
msghub copied to clipboard

join() never completes because of outstanding operations

Open sehe opened this issue 4 years ago • 1 comments

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.

sehe avatar Jan 20 '21 02:01 sehe

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.

sehe avatar Jan 20 '21 03:01 sehe