synchronized void process(SelectionKey sk) { if(!sk.isValid()) { SocketInputStream sis = (SocketInputStream)ep.getNote(isNote); sis.closeIt(); return; } if(sk.isReadable()) { SocketInputStream sis = (SocketInputStream)ep.getNote(isNote); boolean isok = sis.readAvailable(); if(!inProgress) { if(isok) { if(sis.available() > 0 || !nioIsBroken){ inProgress = true; tp.runIt(this); } } else { unregister(ep); return; } } } if(sk.isWritable()) { Object os = ep.getNote(osNote); synchronized(os) { os.notify(); } } }
public void runIt(Object perThrData[]) { // Create per-thread cache if (endpoint.isRunning()) { // Loop if endpoint is paused while (endpoint.isPaused()) { try { Thread.sleep(1000); } catch (InterruptedException e) { // Ignore } } // Accept a new connection Socket s = null; try { s = endpoint.acceptSocket(); } finally { // Continue accepting on another thread... if (endpoint.isRunning()) { endpoint.tp.runIt(this); } } // Process the connection if (null != s) { endpoint.processSocket(s, (TcpConnection) perThrData[0], (Object[]) perThrData[1]); } } }
public void startEndpoint() throws IOException, InstantiationException { if (!initialized) { initEndpoint(); } if (lf) { tp.start(); } running = true; paused = false; if (lf) { listener = new LeaderFollowerWorkerThread(this); tp.runIt(listener); } else { maxThreads = getMaxThreads(); threadStart(); } }
/** Accept incoming connections, dispatch to the thread pool */ void acceptConnections() { if( apr==null ) return; if( log.isDebugEnabled() ) log.debug("Accepting ajp connections on " + file); while( running ) { try { MsgContext ep=this.createMsgContext(); // blocking - opening a server connection. int status=this.open(ep); if( status != 0 && status != 2 ) { log.error( "Error acceptin connection on " + file ); break; } // if( log.isDebugEnabled() ) // log.debug("Accepted ajp connections "); AprConnection ajpConn= new AprConnection(this, ep); tp.runIt( ajpConn ); } catch( Exception ex ) { ex.printStackTrace(); } } }
tp.runIt(pollAjp);
tp.runIt( acceptAjp); log.info("JK: listening on unix socket: " + file );
/** Accept incoming connections, dispatch to the thread pool */ void acceptConnections() { if( log.isDebugEnabled() ) log.debug("Accepting ajp connections on " + port); while( running ) { try{ MsgContext ep=createMsgContext(packetSize); ep.setSource(this); ep.setWorkerEnv( wEnv ); this.accept(ep); if( !running ) break; // Since this is a long-running connection, we don't care // about the small GC SocketConnection ajpConn= new SocketConnection(this, ep); tp.runIt( ajpConn ); }catch(Exception ex) { if (running) log.warn("Exception executing accept" ,ex); } } }