JETTY-1237 Save local/remote address to be available after close
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2004 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
871f73d409
commit
6a9bbd673b
|
@ -3,6 +3,7 @@ jetty-7.1.5-SNAPSHOT
|
||||||
+ 316449 Websocket disconnect fix
|
+ 316449 Websocket disconnect fix
|
||||||
+ 316584 Exception on startup if temp path has spaces and extractWAR=false
|
+ 316584 Exception on startup if temp path has spaces and extractWAR=false
|
||||||
+ 316597 Removed null check and fixed name in Resource#hrefEncodeURI
|
+ 316597 Removed null check and fixed name in Resource#hrefEncodeURI
|
||||||
|
+ JETTY-1237 Save local/remote address to be available after close
|
||||||
|
|
||||||
jetty-7.1.4.v20100610
|
jetty-7.1.4.v20100610
|
||||||
+ 298551 SslSocketConnector does not need keystore stream
|
+ 298551 SslSocketConnector does not need keystore stream
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// ========================================================================
|
// ========================================================================
|
||||||
// Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
|
// Copyright (c) 2004-2010 Mort Bay Consulting Pty. Ltd.
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// All rights reserved. This program and the accompanying materials
|
// All rights reserved. This program and the accompanying materials
|
||||||
// are made available under the terms of the Eclipse Public License v1.0
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -29,9 +29,9 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
*/
|
*/
|
||||||
public class SocketEndPoint extends StreamEndPoint
|
public class SocketEndPoint extends StreamEndPoint
|
||||||
{
|
{
|
||||||
Socket _socket;
|
final Socket _socket;
|
||||||
InetSocketAddress _local;
|
final InetSocketAddress _local;
|
||||||
InetSocketAddress _remote;
|
final InetSocketAddress _remote;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -41,6 +41,8 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
{
|
{
|
||||||
super(socket.getInputStream(),socket.getOutputStream());
|
super(socket.getInputStream(),socket.getOutputStream());
|
||||||
_socket=socket;
|
_socket=socket;
|
||||||
|
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
||||||
|
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
||||||
super.setMaxIdleTime(_socket.getSoTimeout());
|
super.setMaxIdleTime(_socket.getSoTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +54,8 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
{
|
{
|
||||||
super(socket.getInputStream(),socket.getOutputStream());
|
super(socket.getInputStream(),socket.getOutputStream());
|
||||||
_socket=socket;
|
_socket=socket;
|
||||||
|
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
||||||
|
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
||||||
_socket.setSoTimeout(maxIdleTime>0?maxIdleTime:0);
|
_socket.setSoTimeout(maxIdleTime>0?maxIdleTime:0);
|
||||||
super.setMaxIdleTime(maxIdleTime);
|
super.setMaxIdleTime(maxIdleTime);
|
||||||
}
|
}
|
||||||
|
@ -97,9 +101,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public String getLocalAddr()
|
public String getLocalAddr()
|
||||||
{
|
{
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
|
|
||||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||||
return StringUtil.ALL_INTERFACES;
|
return StringUtil.ALL_INTERFACES;
|
||||||
|
|
||||||
|
@ -113,9 +114,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public String getLocalHost()
|
public String getLocalHost()
|
||||||
{
|
{
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
|
|
||||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||||
return StringUtil.ALL_INTERFACES;
|
return StringUtil.ALL_INTERFACES;
|
||||||
|
|
||||||
|
@ -129,8 +127,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public int getLocalPort()
|
public int getLocalPort()
|
||||||
{
|
{
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
if (_local==null)
|
if (_local==null)
|
||||||
return -1;
|
return -1;
|
||||||
return _local.getPort();
|
return _local.getPort();
|
||||||
|
@ -143,8 +139,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public String getRemoteAddr()
|
public String getRemoteAddr()
|
||||||
{
|
{
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
if (_remote==null)
|
if (_remote==null)
|
||||||
return null;
|
return null;
|
||||||
InetAddress addr = _remote.getAddress();
|
InetAddress addr = _remote.getAddress();
|
||||||
|
@ -158,8 +152,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public String getRemoteHost()
|
public String getRemoteHost()
|
||||||
{
|
{
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
if (_remote==null)
|
if (_remote==null)
|
||||||
return null;
|
return null;
|
||||||
return _remote.getAddress().getCanonicalHostName();
|
return _remote.getAddress().getCanonicalHostName();
|
||||||
|
@ -172,8 +164,6 @@ public class SocketEndPoint extends StreamEndPoint
|
||||||
@Override
|
@Override
|
||||||
public int getRemotePort()
|
public int getRemotePort()
|
||||||
{
|
{
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
if (_remote==null)
|
if (_remote==null)
|
||||||
return -1;
|
return -1;
|
||||||
return _remote.getPort();
|
return _remote.getPort();
|
||||||
|
|
|
@ -29,18 +29,17 @@ import org.eclipse.jetty.util.log.Log;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Channel End Point.
|
||||||
|
* <p>Holds the channel and socket for an NIO endpoint.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* To change the template for this generated type comment go to
|
|
||||||
* Window - Preferences - Java - Code Generation - Code and Comments
|
|
||||||
*/
|
*/
|
||||||
public class ChannelEndPoint implements EndPoint
|
public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
protected final ByteChannel _channel;
|
protected final ByteChannel _channel;
|
||||||
protected final ByteBuffer[] _gather2=new ByteBuffer[2];
|
protected final ByteBuffer[] _gather2=new ByteBuffer[2];
|
||||||
protected final Socket _socket;
|
protected final Socket _socket;
|
||||||
protected InetSocketAddress _local;
|
protected final InetSocketAddress _local;
|
||||||
protected InetSocketAddress _remote;
|
protected final InetSocketAddress _remote;
|
||||||
protected int _maxIdleTime;
|
protected int _maxIdleTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +51,15 @@ public class ChannelEndPoint implements EndPoint
|
||||||
this._channel = channel;
|
this._channel = channel;
|
||||||
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
|
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
|
||||||
if (_socket!=null)
|
if (_socket!=null)
|
||||||
|
{
|
||||||
|
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
||||||
|
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
||||||
_maxIdleTime=_socket.getSoTimeout();
|
_maxIdleTime=_socket.getSoTimeout();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_local=_remote=null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,7 +71,16 @@ public class ChannelEndPoint implements EndPoint
|
||||||
_maxIdleTime=maxIdleTime;
|
_maxIdleTime=maxIdleTime;
|
||||||
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
|
_socket=(channel instanceof SocketChannel)?((SocketChannel)channel).socket():null;
|
||||||
if (_socket!=null)
|
if (_socket!=null)
|
||||||
|
{
|
||||||
|
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
||||||
|
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
||||||
_socket.setSoTimeout(_maxIdleTime);
|
_socket.setSoTimeout(_maxIdleTime);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_local=_remote=null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlocking()
|
public boolean isBlocking()
|
||||||
|
@ -321,13 +337,8 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
|
|
||||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||||
return StringUtil.ALL_INTERFACES;
|
return StringUtil.ALL_INTERFACES;
|
||||||
|
|
||||||
return _local.getAddress().getHostAddress();
|
return _local.getAddress().getHostAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,13 +350,8 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
|
|
||||||
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
if (_local==null || _local.getAddress()==null || _local.getAddress().isAnyLocalAddress())
|
||||||
return StringUtil.ALL_INTERFACES;
|
return StringUtil.ALL_INTERFACES;
|
||||||
|
|
||||||
return _local.getAddress().getCanonicalHostName();
|
return _local.getAddress().getCanonicalHostName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,9 +363,6 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (_local==null)
|
|
||||||
_local=(InetSocketAddress)_socket.getLocalSocketAddress();
|
|
||||||
if (_local==null)
|
if (_local==null)
|
||||||
return -1;
|
return -1;
|
||||||
return _local.getPort();
|
return _local.getPort();
|
||||||
|
@ -373,10 +376,6 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
|
|
||||||
if (_remote==null)
|
if (_remote==null)
|
||||||
return null;
|
return null;
|
||||||
return _remote.getAddress().getHostAddress();
|
return _remote.getAddress().getHostAddress();
|
||||||
|
@ -390,10 +389,6 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
|
|
||||||
if (_remote==null)
|
if (_remote==null)
|
||||||
return null;
|
return null;
|
||||||
return _remote.getAddress().getCanonicalHostName();
|
return _remote.getAddress().getCanonicalHostName();
|
||||||
|
@ -407,10 +402,6 @@ public class ChannelEndPoint implements EndPoint
|
||||||
{
|
{
|
||||||
if (_socket==null)
|
if (_socket==null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (_remote==null)
|
|
||||||
_remote=(InetSocketAddress)_socket.getRemoteSocketAddress();
|
|
||||||
|
|
||||||
return _remote==null?-1:_remote.getPort();
|
return _remote==null?-1:_remote.getPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue