This document describes how a device driver cancels an asynchronous request.
Any outstanding asynchronous request can be cancelled. DoCancel() is implemented to handle cancel requests. Cancel requests are either explicitly made by the user or made when there is a close message. Any pending requests and queued DFCs are cancelled and the request is completed with KErrCancel.
/** Cancel Asynchronous Requests. This is called from HandleMsg() to cancel pending asynchronous requests. This function determines which operation is to be cancelled and tidies up the resources specific to the request being cancelled, any outstanding DFCs, and timers, and signals the client that the operation is completed. @param aMask Mask containing the request number that has to be cancelled */ void DExDriverLogicalChannel::DoCancel(TUint aMask) { ... // Any pending asynchronous operation can be // cancelled. Check a valid asynchronous request // to cancel has been specified. // if(aMask&(1<<RExDriverChannel::ERequestTransmitData)) { if (iTxDataStatus) { // If it is a Transmit request, cancel the Transmit DFC. // TDfc::Cancel() cancels the DFC if it is already // queued. It does nothing if the DFC is not queued. // iTxDfc.Cancel(); // Notify the client (iClient) that the request is // completed. The TRequestStatus object is updated with the // status and the completion code is provided to the // client. KErrCancel indicates that the request has been // cancelled. Typically, a client thread, waiting on // User::WaitForRequest(TRequestStatus &aStatus) or using // the active object framework, is unblocked and notified. // Then the client may read the request status from the // TRequestStatus object. // Kern::RequestComplete(iClient,iTxDataStatus,KErrCancel); } } ... }
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.