synchronized (socket) { if (waitingRequests.remove(socket)) { SocketProcessor proc = new SocketProcessor(socket, status); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try {
synchronized (socket) { if (waitingRequests.remove(socket)) { SocketProcessor proc = new SocketProcessor(socket, status); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try {
synchronized (socket) { if (waitingRequests.remove(socket)) { SocketProcessor proc = new SocketProcessor(socket, status); ClassLoader loader = Thread.currentThread().getContextClassLoader(); try {
@Override public void run() { synchronized (socket) { // Process the request from this socket SocketState state = SocketState.OPEN; if (status == null) { state = handler.process(socket,SocketStatus.OPEN); } else { state = handler.process(socket, status); } if (state == Handler.SocketState.CLOSED) { // Close socket and pool destroySocket(socket.getSocket().longValue()); socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.async) { waitingRequests.add(socket); } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN); getExecutor().execute(proc); } } } }
/** * Process given socket. Called in non-comet mode, typically keep alive * or upgraded protocol. */ public boolean processSocket(long socket, SocketStatus status) { try { Executor executor = getExecutor(); if (executor == null) { log.warn(sm.getString("endpoint.warn.noExector", Long.valueOf(socket), null)); } else { SocketWrapper<Long> wrapper = connections.get(Long.valueOf(socket)); // Make sure connection hasn't been closed if (wrapper != null) { executor.execute(new SocketProcessor(wrapper, status)); } } } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); return false; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
@Override public void processSocket(SocketWrapper<Long> socket, SocketStatus status, boolean dispatch) { try { // Synchronisation is required here as this code may be called as a // result of calling AsyncContext.dispatch() from a non-container // thread synchronized (socket) { if (waitingRequests.remove(socket)) { SocketProcessor proc = new SocketProcessor(socket, status); Executor executor = getExecutor(); if (dispatch && executor != null) { executor.execute(proc); } else { proc.run(); } } } } catch (RejectedExecutionException ree) { log.warn(sm.getString("endpoint.executor.fail", socket) , ree); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); } }
@Override public void run() { synchronized (socket) { // Process the request from this socket SocketState state = SocketState.OPEN; if (status == null) { state = handler.process(socket,SocketStatus.OPEN); } else { state = handler.process(socket, status); } if (state == Handler.SocketState.CLOSED) { // Close socket and pool destroySocket(socket.getSocket().longValue()); socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.async) { waitingRequests.add(socket); } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN); getExecutor().execute(proc); } } } }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { Executor executor = getExecutor(); if (executor == null) { log.warn(sm.getString("endpoint.warn.noExector", Long.valueOf(socket), null)); } else { SocketWrapper<Long> wrapper = new SocketWrapper<Long>(Long.valueOf(socket)); executor.execute(new SocketProcessor(wrapper, null)); } } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); return false; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
private void doRun() { // Process the request from this socket if (socket.getSocket() == null) { // Closed in another thread return; } SocketState state = handler.process(socket, status); if (state == Handler.SocketState.CLOSED) { // Close socket and pool closeSocket(socket.getSocket().longValue()); socket.reset(null, 1); } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.isAsync()) { waitingRequests.add(socket); } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN_READ); getExecutor().execute(proc); } } }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { if (executor == null) { Worker worker = getWorkerThread(); if (worker != null) { worker.assign(socket); } else { return false; } } else { executor.execute(new SocketProcessor(socket)); } } catch (Throwable t) { // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full CoyoteLogger.NET_LOGGER.errorProcessingSocket(t); return false; } return true; }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { SocketWrapper<Long> wrapper = new SocketWrapper<Long>(Long.valueOf(socket)); getExecutor().execute(new SocketProcessor(wrapper, null)); } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); return false; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { SocketWrapper<Long> wrapper = new SocketWrapper<Long>(Long.valueOf(socket)); getExecutor().execute(new SocketProcessor(wrapper, null)); } catch (RejectedExecutionException x) { log.warn("Socket processing request was rejected for:"+socket,x); return false; } catch (Throwable t) { ExceptionUtils.handleThrowable(t); // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
@Override public void run() { synchronized (socket) { // Process the request from this socket Handler.SocketState state = (status==null)?handler.process(socket):handler.asyncDispatch(socket, status); if (state == Handler.SocketState.CLOSED) { // Close socket and pool destroySocket(socket.getSocket().longValue()); socket = null; } else if (state == Handler.SocketState.LONG) { socket.access(); if (socket.async) { waitingRequests.add(socket); } } else if (state == Handler.SocketState.ASYNC_END) { socket.access(); SocketProcessor proc = new SocketProcessor(socket, SocketStatus.OPEN); getExecutor().execute(proc); } } } }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { if (executor == null) { getWorkerThread().assign(socket); } else { executor.execute(new SocketProcessor(socket)); } } catch (Throwable t) { // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
/** * Process given socket. */ protected boolean processSocket(long socket) { try { if (executor == null) { getWorkerThread().assign(socket); } else { executor.execute(new SocketProcessor(socket)); } } catch (Throwable t) { // This means we got an OOM or similar creating a thread, or that // the pool and its queue are full log.error(sm.getString("endpoint.process.fail"), t); return false; } return true; }
@Override protected SocketProcessorBase<Long> createSocketProcessor( SocketWrapperBase<Long> socketWrapper, SocketEvent event) { return new SocketProcessor(socketWrapper, event); }