src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java

changeset 323
052dda3b5ce3
parent 231
ff0f02a67881
child 561
b083590cb088
equal deleted inserted replaced
322:0289a94d653b 323:052dda3b5ce3
1 /* 1 /*
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
111 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr; 111 import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr;
112 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr; 112 import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr;
113 import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl; 113 import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl;
114 import com.sun.corba.se.impl.util.JDKBridge; 114 import com.sun.corba.se.impl.util.JDKBridge;
115 115
116 import java.util.concurrent.ConcurrentMap;
117 import java.util.concurrent.ConcurrentHashMap;
118
116 /** 119 /**
117 * ClientDelegate is the RMI client-side subcontract or representation 120 * ClientDelegate is the RMI client-side subcontract or representation
118 * It implements RMI delegate as well as our internal ClientRequestDispatcher 121 * It implements RMI delegate as well as our internal ClientRequestDispatcher
119 * interface. 122 * interface.
120 */ 123 */
121 public class CorbaClientRequestDispatcherImpl 124 public class CorbaClientRequestDispatcherImpl
122 implements 125 implements
123 ClientRequestDispatcher 126 ClientRequestDispatcher
124 { 127 {
128 private ConcurrentMap<ContactInfo, Object> locks =
129 new ConcurrentHashMap<ContactInfo, Object>();
130
125 public OutputObject beginRequest(Object self, String opName, 131 public OutputObject beginRequest(Object self, String opName,
126 boolean isOneWay, ContactInfo contactInfo) 132 boolean isOneWay, ContactInfo contactInfo)
127 { 133 {
128 ORB orb = null; 134 ORB orb = null;
129 try { 135 try {
146 152
147 CorbaConnection connection = null; 153 CorbaConnection connection = null;
148 154
149 // This locking is done so that multiple connections are not created 155 // This locking is done so that multiple connections are not created
150 // for the same endpoint 156 // for the same endpoint
151 //6929137 - Synchronized on contactInfo to avoid blocking across multiple endpoints 157 // 7046238 - Synchronization on a single monitor for contactInfo parameters
152 synchronized (contactInfo) { 158 // with identical hashCode(), so we lock on same monitor for equal parameters
159 // (which can refer to equal (in terms of equals()) but not the same objects)
160
161 Object lock = locks.get(contactInfo);
162
163 if (lock == null) {
164 Object newLock = new Object();
165 lock = locks.putIfAbsent(contactInfo, newLock);
166 if (lock == null) {
167 lock = newLock;
168 }
169 }
170
171 synchronized (lock) {
153 if (contactInfo.isConnectionBased()) { 172 if (contactInfo.isConnectionBased()) {
154 if (contactInfo.shouldCacheConnection()) { 173 if (contactInfo.shouldCacheConnection()) {
155 connection = (CorbaConnection) 174 connection = (CorbaConnection)
156 orb.getTransportManager() 175 orb.getTransportManager()
157 .getOutboundConnectionCache(contactInfo).get(contactInfo); 176 .getOutboundConnectionCache(contactInfo).get(contactInfo);
252 // This must be done BEFORE message initialization since fragments 271 // This must be done BEFORE message initialization since fragments
253 // may be sent at that time. 272 // may be sent at that time.
254 registerWaiter(messageMediator); 273 registerWaiter(messageMediator);
255 274
256 // Do connection reclaim now 275 // Do connection reclaim now
257 synchronized (contactInfo) { 276 synchronized (lock) {
258 if (contactInfo.isConnectionBased()) { 277 if (contactInfo.isConnectionBased()) {
259 if (contactInfo.shouldCacheConnection()) { 278 if (contactInfo.shouldCacheConnection()) {
260 OutboundConnectionCache connectionCache = 279 OutboundConnectionCache connectionCache =
261 orb.getTransportManager() 280 orb.getTransportManager()
262 .getOutboundConnectionCache(contactInfo); 281 .getOutboundConnectionCache(contactInfo);

mercurial