MCPcopy Create free account
hub / github.com/BaseXdb/basex / run

Method run

basex-core/src/main/java/org/basex/BaseXServer.java:134–175  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 12

closeMethod · 0.95
closeMethod · 0.95
debugMethod · 0.95
errlnMethod · 0.95
messageMethod · 0.95
writeServerMethod · 0.80
acceptMethod · 0.65
getMethod · 0.65
closeMethod · 0.65
addMethod · 0.65
existsMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected