You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Alex Shtof <sh...@visionmap.com> on 2013/08/29 09:39:21 UTC

Cancellation of a blocking read operation

Hi all.
I would like to ask for your help with cancellation of a blocking read operation that is in progress. The read operation (for example – TProtocol::readByte) is blocked until the data is received. When I close the transport from another thread, I get a failed assertion about a null pointer.

Is there any other way to cancel a blocked read operation?

Alex.

This email and any files transmitted with it are confidential and contain proprietary information belonging to VisionMap Ltd. VisionMap Ltd. asserts in respect of this email and any files transmitted with it all rights for confidentiality and proprietary interests to the fullest extent permitted by law. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Thank you. 

RE: Cancellation of a blocking read operation

Posted by Alex Shtof <sh...@visionmap.com>.
I am more concerned about client-side cancellation. For example, I would like to be able to hit "Cancel" in the UI of my application and all communications with the server will cease. I believe I am not the first to encounter the need to cancel thrift-based communications. Is there any other solution you might think of? I haven't seen any support for cancellation thrift/async headers either.

Alex.

-----Original Message-----
From: Ben Craig [mailto:ben.craig@ni.com] 
Sent: Thursday, August 29, 2013 5:09 PM
To: user@thrift.apache.org
Subject: Re: Cancellation of a blocking read operation

There is not a safe, portable way to do that as far as I know.

One common way that this is mitigated is by using a framed transport. Most transports just send data as soon as it is available.  The framed transport puts the size of a message as the first four bytes.

On the server side, the framed transport is used by TNonBlockingServer to set up a state machine, such that you can call interrupt() on the server to tear things down.

There is a good reason that Thrift doesn't support cancellation of individual transport.  The typical way to implement cancellation is to change every "read()" call into both a "select()" and a "read()".  This double the number of system calls that need to be made, and does horrible things to performance.



From:   Alex Shtof <sh...@visionmap.com>
To:     "user@thrift.apache.org" <us...@thrift.apache.org>, 
Date:   08/29/2013 02:39 AM
Subject:        Cancellation of a blocking read operation



Hi all.
I would like to ask for your help with cancellation of a blocking read operation that is in progress. The read operation (for example –
TProtocol::readByte) is blocked until the data is received. When I close the transport from another thread, I get a failed assertion about a null pointer.

Is there any other way to cancel a blocked read operation?

Alex.

This email and any files transmitted with it are confidential and contain proprietary information belonging to VisionMap Ltd. VisionMap Ltd. asserts in respect of this email and any files transmitted with it all rights for confidentiality and proprietary interests to the fullest extent permitted by law. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Thank you. 



This email and any files transmitted with it are confidential and contain proprietary information belonging to VisionMap Ltd. VisionMap Ltd. asserts in respect of this email and any files transmitted with it all rights for confidentiality and proprietary interests to the fullest extent permitted by law. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Thank you. 

Re: Cancellation of a blocking read operation

Posted by Ben Craig <be...@ni.com>.
There is not a safe, portable way to do that as far as I know.

One common way that this is mitigated is by using a framed transport. Most 
transports just send data as soon as it is available.  The framed 
transport puts the size of a message as the first four bytes.

On the server side, the framed transport is used by TNonBlockingServer to 
set up a state machine, such that you can call interrupt() on the server 
to tear things down.

There is a good reason that Thrift doesn't support cancellation of 
individual transport.  The typical way to implement cancellation is to 
change every "read()" call into both a "select()" and a "read()".  This 
double the number of system calls that need to be made, and does horrible 
things to performance.



From:   Alex Shtof <sh...@visionmap.com>
To:     "user@thrift.apache.org" <us...@thrift.apache.org>, 
Date:   08/29/2013 02:39 AM
Subject:        Cancellation of a blocking read operation



Hi all.
I would like to ask for your help with cancellation of a blocking read 
operation that is in progress. The read operation (for example – 
TProtocol::readByte) is blocked until the data is received. When I close 
the transport from another thread, I get a failed assertion about a null 
pointer.

Is there any other way to cancel a blocked read operation?

Alex.

This email and any files transmitted with it are confidential and contain 
proprietary information belonging to VisionMap Ltd. VisionMap Ltd. asserts 
in respect of this email and any files transmitted with it all rights for 
confidentiality and proprietary interests to the fullest extent permitted 
by law. If you are not the intended recipient you are notified that 
disclosing, copying, distributing or taking any action in reliance on the 
contents of this information is strictly prohibited. Thank you.