![]() |
Boost : |
From: McCabe, David (david.mccabe_at_[hidden])
Date: 2008-02-05 06:37:34
I'm going to go out on a limb here, because I don't have asio's source
to hand, but...
CancelIo (per
<<http://msdn2.microsoft.com/en-us/library/aa363791(VS.85).aspx>>
cancels "all pending input and output (I/O) operations that are issued
by the calling thread for the specified file." Since you're cancelling
on a different thread, I assume asio calls CancelIo on that thread and
thus doesn't cancel the operation. See Larry Osterman's blog
<<http://blogs.msdn.com/larryosterman/archive/2004/03/19/92857.aspx>>
for background.
Vista offers CancelIoEx and CancelSynchronousIo for these situations,
but on previous versions of Windows there's no way to cancel I/O going
on in a different thread.
David
-----Original Message-----
From: Roland Schwarz [mailto:roland.schwarz_at_[hidden]]
Sent: Monday, 4 February 2008 7:46 AM
To: asio-users_at_[hidden]; boost_at_[hidden]; Christopher
Kohlhoff
Subject: Re: [boost] [asio-users] Cancelation not working on windows?
This is my second attempt, since there was no
meaningful answer on the first.
I again apologize for cross-posting but I still
have no idea which is the correct list to post asio
related questions.
Roland Schwarz wrote:
> One of my objectives is getting cancellation in a
> platform independent way. Since on windows blocking
> io cannot be canceled I tried to use asio to emulate
> the required behavior.
>
> This works well on linux, but the same code fails
> on windows. During a debug session it appeared to me
> as if the CancelIO call is not being honored (WindowsXP).
>
> Is this a bug in asio or am I doing something wrong.
>
> I put together a stripped down example to show
> the "erroneous" behavior.
>
> The examples main thread connects to localhost port 80 and
> then schedules an async read call.
>
> A second polling thread checks for ctrl-c beeing pressed
> and invokes the sockets cancel function.
>
> On linux this causes the read handler to terminate with
> Oeration Cancelled
> as expected, but on windows the cancel request is simply
> swallowed.
>
> Any help appreciated!
>
-- _________________________________________ _ _ | Roland Schwarz |_)(_ | aka. speedsnail | \__) | mailto:roland.schwarz_at_[hidden] ________| http://www.blackspace.at This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk