// Try to get hold of the InputStream buffer.
// In the case of 1.0 requests there is no way to get hold of
// InputStream. Try out the 1.1 and 1.2 cases.
// was the request 1.2 ?
MessageMediator mediator = connection.serverRequestMapGet(cancelReqId);
int requestId ;
if (mediator == null) {
// was the request 1.1 ?
mediator = connection.serverRequest_1_1_Get();
if (mediator == null) {
// XXX log this!
// either the request was 1.0
// or an early reply has already been sent
// or request processing is over
// or its a spurious CancelRequest
return; // do nothing.
}
requestId = ((CorbaMessageMediator) mediator).getRequestId();
if (requestId != cancelReqId) {
// A spurious 1.1 CancelRequest has been received.
// XXX log this!
return; // do nothing
}
if (requestId == 0) { // special case
// XXX log this
// this means that
// 1. the 1.1 requests' requestId has not been received
// i.e., a CancelRequest was received even before the
// 1.1 request was received. The spec disallows this.
// 2. or the 1.1 request has a requestId 0.
//
// It is a little tricky to distinguish these two. So, be
// conservative and do not cancel the request. Downside is that
// 1.1 requests with requestId of 0 will never be cancelled.
return; // do nothing
}
} else {
requestId = ((CorbaMessageMediator) mediator).getRequestId();
}
Message msg = ((CorbaMessageMediator)mediator).getRequestHeader();
if (msg.getType() != Message.GIOPRequest) {
// Any mediator obtained here should only ever be for a GIOP
// request.
wrapper.badMessageTypeForCancel() ;
}
// At this point we have a valid message mediator that contains
// a valid requestId.
// at this point we have chosen a request to be cancelled. But we
// do not know if the target object's method has been invoked or not.
// Request input stream being available simply means that the request
// processing is not over yet. simply set the abort flag in the
// BMRS and hope that the worker thread would notice it (this can
// happen only if the request stream is being unmarshalled and the
// target's method has not been invoked yet). This guarantees
// that the requests which have been dispatched to the
// target's method will never be cancelled.
BufferManagerReadStream bufferManager = (BufferManagerReadStream)
((CDRInputObject)mediator.getInputObject()).getBufferManager();
bufferManager.cancelProcessing(cancelReqId);
}