提交 09776ba3 编写于 作者: L lana

Merge

/* /*
* Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,7 +25,10 @@ ...@@ -25,7 +25,10 @@
package com.sun.corba.se.impl.transport; package com.sun.corba.se.impl.transport;
import java.util.Hashtable; import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.SystemException; import org.omg.CORBA.SystemException;
...@@ -68,7 +71,7 @@ public class CorbaResponseWaitingRoomImpl ...@@ -68,7 +71,7 @@ public class CorbaResponseWaitingRoomImpl
private CorbaConnection connection; private CorbaConnection connection;
// Maps requestId to an OutCallDesc. // Maps requestId to an OutCallDesc.
private Hashtable out_calls = null; // REVISIT - use int hastable/map final private Map<Integer, OutCallDesc> out_calls;
public CorbaResponseWaitingRoomImpl(ORB orb, CorbaConnection connection) public CorbaResponseWaitingRoomImpl(ORB orb, CorbaConnection connection)
{ {
...@@ -76,7 +79,8 @@ public class CorbaResponseWaitingRoomImpl ...@@ -76,7 +79,8 @@ public class CorbaResponseWaitingRoomImpl
wrapper = ORBUtilSystemException.get( orb, wrapper = ORBUtilSystemException.get( orb,
CORBALogDomains.RPC_TRANSPORT ) ; CORBALogDomains.RPC_TRANSPORT ) ;
this.connection = connection; this.connection = connection;
out_calls = new Hashtable(); out_calls =
Collections.synchronizedMap(new HashMap<Integer, OutCallDesc>());
} }
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
...@@ -139,7 +143,7 @@ public class CorbaResponseWaitingRoomImpl ...@@ -139,7 +143,7 @@ public class CorbaResponseWaitingRoomImpl
return null; return null;
} }
OutCallDesc call = (OutCallDesc)out_calls.get(requestId); OutCallDesc call = out_calls.get(requestId);
if (call == null) { if (call == null) {
throw wrapper.nullOutCall(CompletionStatus.COMPLETED_MAYBE); throw wrapper.nullOutCall(CompletionStatus.COMPLETED_MAYBE);
} }
...@@ -197,7 +201,7 @@ public class CorbaResponseWaitingRoomImpl ...@@ -197,7 +201,7 @@ public class CorbaResponseWaitingRoomImpl
LocateReplyOrReplyMessage header = (LocateReplyOrReplyMessage) LocateReplyOrReplyMessage header = (LocateReplyOrReplyMessage)
inputObject.getMessageHeader(); inputObject.getMessageHeader();
Integer requestId = new Integer(header.getRequestId()); Integer requestId = new Integer(header.getRequestId());
OutCallDesc call = (OutCallDesc) out_calls.get(requestId); OutCallDesc call = out_calls.get(requestId);
if (orb.transportDebugFlag) { if (orb.transportDebugFlag) {
dprint(".responseReceived: id/" dprint(".responseReceived: id/"
...@@ -248,7 +252,6 @@ public class CorbaResponseWaitingRoomImpl ...@@ -248,7 +252,6 @@ public class CorbaResponseWaitingRoomImpl
public int numberRegistered() public int numberRegistered()
{ {
// Note: Hashtable.size() is not synchronized
return out_calls.size(); return out_calls.size();
} }
...@@ -264,29 +267,41 @@ public class CorbaResponseWaitingRoomImpl ...@@ -264,29 +267,41 @@ public class CorbaResponseWaitingRoomImpl
dprint(".signalExceptionToAllWaiters: " + systemException); dprint(".signalExceptionToAllWaiters: " + systemException);
} }
OutCallDesc call; synchronized (out_calls) {
java.util.Enumeration e = out_calls.elements(); if (orb.transportDebugFlag) {
while(e.hasMoreElements()) { dprint(".signalExceptionToAllWaiters: out_calls size :" +
call = (OutCallDesc) e.nextElement(); out_calls.size());
}
synchronized(call.done){
// anything waiting for BufferManagerRead's fragment queue for (OutCallDesc call : out_calls.values()) {
// needs to be cancelled if (orb.transportDebugFlag) {
CorbaMessageMediator corbaMsgMediator = dprint(".signalExceptionToAllWaiters: signaling " +
(CorbaMessageMediator)call.messageMediator; call);
CDRInputObject inputObject = }
(CDRInputObject)corbaMsgMediator.getInputObject(); synchronized(call.done) {
// IMPORTANT: If inputObject is null, then no need to tell try {
// BufferManagerRead to cancel request processing. // anything waiting for BufferManagerRead's fragment queue
if (inputObject != null) { // needs to be cancelled
BufferManagerReadStream bufferManager = CorbaMessageMediator corbaMsgMediator =
(BufferManagerReadStream)inputObject.getBufferManager(); (CorbaMessageMediator)call.messageMediator;
int requestId = corbaMsgMediator.getRequestId(); CDRInputObject inputObject =
bufferManager.cancelProcessing(requestId); (CDRInputObject)corbaMsgMediator.getInputObject();
// IMPORTANT: If inputObject is null, then no need to tell
// BufferManagerRead to cancel request processing.
if (inputObject != null) {
BufferManagerReadStream bufferManager =
(BufferManagerReadStream)inputObject.getBufferManager();
int requestId = corbaMsgMediator.getRequestId();
bufferManager.cancelProcessing(requestId);
}
} catch (Exception e) {
} finally {
// attempt to wake up waiting threads in all cases
call.inputObject = null;
call.exception = systemException;
call.done.notifyAll();
}
} }
call.inputObject = null;
call.exception = systemException;
call.done.notify();
} }
} }
} }
...@@ -294,7 +309,7 @@ public class CorbaResponseWaitingRoomImpl ...@@ -294,7 +309,7 @@ public class CorbaResponseWaitingRoomImpl
public MessageMediator getMessageMediator(int requestId) public MessageMediator getMessageMediator(int requestId)
{ {
Integer id = new Integer(requestId); Integer id = new Integer(requestId);
OutCallDesc call = (OutCallDesc) out_calls.get(id); OutCallDesc call = out_calls.get(id);
if (call == null) { if (call == null) {
// This can happen when getting early reply fragments for a // This can happen when getting early reply fragments for a
// request which has completed (e.g., client marshaling error). // request which has completed (e.g., client marshaling error).
......
/* /*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -1521,7 +1521,7 @@ public class SocketOrChannelConnectionImpl ...@@ -1521,7 +1521,7 @@ public class SocketOrChannelConnectionImpl
// connection and give them the SystemException; // connection and give them the SystemException;
responseWaitingRoom.signalExceptionToAllWaiters(systemException); responseWaitingRoom.signalExceptionToAllWaiters(systemException);
} finally {
if (contactInfo != null) { if (contactInfo != null) {
((OutboundConnectionCache)getConnectionCache()).remove(contactInfo); ((OutboundConnectionCache)getConnectionCache()).remove(contactInfo);
} else if (acceptor != null) { } else if (acceptor != null) {
...@@ -1542,7 +1542,6 @@ public class SocketOrChannelConnectionImpl ...@@ -1542,7 +1542,6 @@ public class SocketOrChannelConnectionImpl
writeUnlock(); writeUnlock();
} finally {
if (orb.transportDebugFlag) { if (orb.transportDebugFlag) {
dprint(".purgeCalls<-: " dprint(".purgeCalls<-: "
+ minor_code + "/" + die + "/" + lockHeld + minor_code + "/" + die + "/" + lockHeld
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册