Mercurial Hosting > luan
comparison src/org/eclipse/jetty/server/nio/SelectChannelConnector.java @ 906:eaf271fb747f
minor
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 07 Oct 2016 03:59:44 -0600 |
| parents | 94f5d8a62385 |
| children | bc4e299de953 |
comparison
equal
deleted
inserted
replaced
| 905:e7175965e6cf | 906:eaf271fb747f |
|---|---|
| 64 * | 64 * |
| 65 * @org.apache.xbean.XBean element="nioConnector" description="Creates an NIO based socket connector" | 65 * @org.apache.xbean.XBean element="nioConnector" description="Creates an NIO based socket connector" |
| 66 */ | 66 */ |
| 67 public class SelectChannelConnector extends AbstractNIOConnector | 67 public class SelectChannelConnector extends AbstractNIOConnector |
| 68 { | 68 { |
| 69 protected ServerSocketChannel _acceptChannel; | 69 private transient ServerSocketChannel _acceptChannel; |
| 70 private int _lowResourcesConnections; | 70 private int _lowResourcesConnections; |
| 71 private int _lowResourcesMaxIdleTime; | 71 private int _lowResourcesMaxIdleTime; |
| 72 private int _localPort=-1; | 72 private int _localPort=-1; |
| 73 | 73 |
| 74 private final SelectorManager _manager = new ConnectorSelectorManager(); | 74 private final SelectorManager _manager = new ConnectorSelectorManager(); |
| 86 setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4)); | 86 setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4)); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /* ------------------------------------------------------------ */ | 89 /* ------------------------------------------------------------ */ |
| 90 @Override | 90 @Override |
| 91 public void accept(int acceptorID) throws IOException | 91 public final void accept() throws IOException |
| 92 { | 92 { |
| 93 ServerSocketChannel server; | 93 ServerSocketChannel server = _acceptChannel; |
| 94 synchronized(this) | |
| 95 { | |
| 96 server = _acceptChannel; | |
| 97 } | |
| 98 | 94 |
| 99 if (server!=null && server.isOpen() && _manager.isStarted()) | 95 if (server!=null && server.isOpen() && _manager.isStarted()) |
| 100 { | 96 { |
| 101 SocketChannel channel = server.accept(); | 97 SocketChannel channel = server.accept(); |
| 102 channel.configureBlocking(false); | 98 channel.configureBlocking(false); |
| 174 _acceptChannel.configureBlocking(true); | 170 _acceptChannel.configureBlocking(true); |
| 175 | 171 |
| 176 // Bind the server socket to the local host and port | 172 // Bind the server socket to the local host and port |
| 177 _acceptChannel.socket().setReuseAddress(true); | 173 _acceptChannel.socket().setReuseAddress(true); |
| 178 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); | 174 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); |
| 179 _acceptChannel.socket().bind(addr,0); | 175 _acceptChannel.socket().bind(addr); |
| 180 | 176 |
| 181 _localPort=_acceptChannel.socket().getLocalPort(); | 177 _localPort=_acceptChannel.socket().getLocalPort(); |
| 182 if (_localPort<=0) | 178 if (_localPort<=0) |
| 183 throw new IOException("Server channel not bound"); | 179 throw new IOException("Server channel not bound"); |
| 184 | 180 |
