In my application (and a separate test program) it seems as though the cancel() function on the resolver does not work as intended. For async resolves, the cancel functionality should abort them immediately and pass an 'operation aborted' error code to the callback handler. In my tests, I will resolve an invalid domain (this causes the resolve to take a few seconds, to demonstrate the problem), sleep for 100ms, then call cancel on the resolver object. No cancelling actually occurs, and the callback is simply triggered after a few seconds with a "No host found" error code, not the expected operation aborted. Has anyone experienced this before, or know how I might be using the resolver incorrectly?
Matthew Edwards wrote:
In my tests, I will resolve an invalid domain (this causes the resolve to take a few seconds, to demonstrate the problem), sleep for 100ms, then call cancel on the resolver object. No cancelling actually occurs, and the callback is simply triggered after a few seconds with a "No host found" error code, not the expected operation aborted.
Has anyone experienced this before, or know how I might be using the resolver incorrectly?
It's behaving correctly according to the design of the implementation. If the resolve operation you're trying to cancel is the currently executing one on the hidden thread it waits for it to finish. It's only able to cancel queued resolve operations immediately. In general, cancellation is only a best effort thing. Strictly speaking it only really guarantees that the operation will not be indefinite. You may not be able to cancel all operations because they may have already entered an un-cancellable state, but they will finish within some bounded period of time. Cheers, Chris
I have the same problem. According to my backtrace you use getaddrinfo function under Linux. Why do you not use getaddrinfo_a function? -- View this message in context: http://boost.2283326.n4.nabble.com/asio-resolver-cancel-problem-tp2568434p46... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (3)
-
Christopher Kohlhoff
-
Matthew Edwards
-
sudakov_ivan@mai .ru