mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-30 13:08:24 +00:00
6714797: InitialContext.close does not close NIO socket connections
Reviewed-by: asaha
This commit is contained in:
parent
4ae2fc83cf
commit
f91d0d4e60
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,7 @@ import com.sun.corba.se.pept.transport.ConnectionCache;
|
||||
|
||||
import com.sun.corba.se.spi.logging.CORBALogDomains;
|
||||
import com.sun.corba.se.spi.orb.ORB;
|
||||
import com.sun.corba.se.spi.transport.CorbaConnection;
|
||||
import com.sun.corba.se.spi.transport.CorbaConnectionCache;
|
||||
|
||||
import com.sun.corba.se.impl.logging.ORBUtilSystemException;
|
||||
@ -87,6 +88,14 @@ public abstract class CorbaConnectionCacheBase
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
synchronized (backingStore()) {
|
||||
for (Object obj : values()) {
|
||||
((CorbaConnection)obj).closeConnectionResources() ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long numberOfIdleConnections()
|
||||
{
|
||||
long count = 0;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2010 Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -38,6 +38,7 @@ import org.omg.CORBA.INTERNAL;
|
||||
import org.omg.CORBA.CompletionStatus;
|
||||
|
||||
import com.sun.corba.se.pept.transport.Acceptor;
|
||||
import com.sun.corba.se.pept.transport.ConnectionCache;
|
||||
import com.sun.corba.se.pept.transport.ByteBufferPool;
|
||||
import com.sun.corba.se.pept.transport.ContactInfo;
|
||||
import com.sun.corba.se.pept.transport.InboundConnectionCache;
|
||||
@ -49,6 +50,8 @@ import com.sun.corba.se.spi.ior.ObjectAdapterId;
|
||||
import com.sun.corba.se.spi.orb.ORB;
|
||||
import com.sun.corba.se.spi.transport.CorbaAcceptor;
|
||||
import com.sun.corba.se.spi.transport.CorbaTransportManager;
|
||||
import com.sun.corba.se.pept.transport.Connection;
|
||||
import com.sun.corba.se.pept.transport.ConnectionCache;
|
||||
|
||||
// REVISIT - impl/poa specific:
|
||||
import com.sun.corba.se.impl.oa.poa.Policies;
|
||||
@ -182,6 +185,12 @@ public class CorbaTransportManagerImpl
|
||||
if (orb.transportDebugFlag) {
|
||||
dprint(".close->");
|
||||
}
|
||||
for (Object cc : outboundConnectionCaches.values()) {
|
||||
((ConnectionCache)cc).close() ;
|
||||
}
|
||||
for (Object cc : inboundConnectionCaches.values()) {
|
||||
((ConnectionCache)cc).close() ;
|
||||
}
|
||||
getSelector(0).close();
|
||||
} finally {
|
||||
if (orb.transportDebugFlag) {
|
||||
|
||||
@ -811,6 +811,7 @@ public class SocketOrChannelConnectionImpl
|
||||
dprint(".close: " + this, e);
|
||||
}
|
||||
}
|
||||
closeConnectionResources();
|
||||
} finally {
|
||||
if (orb.transportDebugFlag) {
|
||||
dprint(".close<-: " + this);
|
||||
@ -818,6 +819,28 @@ public class SocketOrChannelConnectionImpl
|
||||
}
|
||||
}
|
||||
|
||||
public void closeConnectionResources() {
|
||||
if (orb.transportDebugFlag) {
|
||||
dprint(".closeConnectionResources->: " + this);
|
||||
}
|
||||
Selector selector = orb.getTransportManager().getSelector(0);
|
||||
selector.unregisterForEvent(this);
|
||||
try {
|
||||
if (socketChannel != null)
|
||||
socketChannel.close() ;
|
||||
if (socket != null && !socket.isClosed())
|
||||
socket.close() ;
|
||||
} catch (IOException e) {
|
||||
if (orb.transportDebugFlag) {
|
||||
dprint( ".closeConnectionResources: " + this, e ) ;
|
||||
}
|
||||
}
|
||||
if (orb.transportDebugFlag) {
|
||||
dprint(".closeConnectionResources<-: " + this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Acceptor getAcceptor()
|
||||
{
|
||||
return acceptor;
|
||||
|
||||
@ -41,6 +41,12 @@ public interface ConnectionCache
|
||||
public long numberOfBusyConnections();
|
||||
|
||||
public boolean reclaim();
|
||||
|
||||
/** Close all connections in the connection cache.
|
||||
* This is used as a final cleanup, and will result
|
||||
* in abrupt termination of any pending communications.
|
||||
*/
|
||||
public void close();
|
||||
}
|
||||
|
||||
// End of file.
|
||||
|
||||
@ -163,6 +163,10 @@ public interface CorbaConnection
|
||||
// REVISIT - MessageMediator parameter?
|
||||
public void serverRequestProcessingBegins();
|
||||
public void serverRequestProcessingEnds();
|
||||
|
||||
/** Clean up all connection resources. Used when shutting down an ORB.
|
||||
*/
|
||||
public void closeConnectionResources();
|
||||
}
|
||||
|
||||
// End of file.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user