()
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public void run() { |
| 136 | running = true; |
| 137 | while(running) { |
| 138 | try { |
| 139 | final Socket s = socket.accept(); |
| 140 | s.setTcpNoDelay(true); |
| 141 | if(stopFile.exists()) { |
| 142 | close(); |
| 143 | } else { |
| 144 | // drop inactive connections |
| 145 | final long ka = context.soptions.get(StaticOptions.KEEPALIVE) * 1000L; |
| 146 | if(ka > 0) { |
| 147 | final long ms = System.currentTimeMillis(); |
| 148 | for(final ClientListener cl : context.sessions) { |
| 149 | if(ms - cl.last > ka) cl.close(); |
| 150 | } |
| 151 | } |
| 152 | // create client listener, stop authentication after timeout |
| 153 | final ClientListener cl = new ClientListener(s, context, this); |
| 154 | if(ka > 0) { |
| 155 | cl.timeout.schedule(new TimerTask() { |
| 156 | @Override |
| 157 | public void run() { |
| 158 | cl.close(); |
| 159 | } |
| 160 | }, ka); |
| 161 | authorizing.add(cl); |
| 162 | } |
| 163 | cl.start(); |
| 164 | } |
| 165 | } catch(final SocketException ex) { |
| 166 | Util.debug(ex); |
| 167 | break; |
| 168 | } catch(final Throwable ex) { |
| 169 | // socket may have been unexpectedly closed |
| 170 | Util.errln(ex); |
| 171 | context.log.writeServer(LogType.ERROR, Util.message(ex)); |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Stops the server. |
nothing calls this directly
no test coverage detected