MCPcopy Index your code
hub / github.com/apache/tomcat / AbstractProcessorLight

Class AbstractProcessorLight

java/org/apache/coyote/AbstractProcessorLight.java:34–234  ·  view source on GitHub ↗

This is a light-weight abstract processor implementation that is intended as a basis for all Processor implementations from the light-weight upgrade processors to the HTTP/AJP processors.

Source from the content-addressed store, hash-verified

32 * implementations from the light-weight upgrade processors to the HTTP/AJP processors.
33 */
34public abstract class AbstractProcessorLight implements Processor {
35
36 /** The set of dispatch types to be processed. */
37 private final Set<DispatchType> dispatches = new CopyOnWriteArraySet<>();
38
39
40 /**
41 * Constructs a new processor.
42 */
43 public AbstractProcessorLight() {
44 }
45
46
47 @Override
48 public SocketState process(SocketWrapperBase<?> socketWrapper, SocketEvent status) throws IOException {
49
50 SocketState state = SocketState.CLOSED;
51 Iterator<DispatchType> dispatches = null;
52 do {
53 if (dispatches != null) {
54 DispatchType nextDispatch = dispatches.next();
55 if (getLog().isTraceEnabled()) {
56 getLog().trace("Processing dispatch type: [" + nextDispatch + "]");
57 }
58 state = dispatch(nextDispatch.getSocketStatus());
59 if (!dispatches.hasNext()) {
60 state = checkForPipelinedData(state, socketWrapper);
61 }
62 } else if (status == SocketEvent.DISCONNECT) {
63 // Do nothing here, just wait for it to get recycled
64 } else if (isAsync() || isUpgrade() || state == SocketState.ASYNC_END) {
65 state = dispatch(status);
66 state = checkForPipelinedData(state, socketWrapper);
67 } else if (status == SocketEvent.OPEN_WRITE) {
68 // Extra write event likely after async, ignore
69 state = SocketState.LONG;
70 } else if (status == SocketEvent.OPEN_READ) {
71 state = service(socketWrapper);
72 } else if (status == SocketEvent.CONNECT_FAIL) {
73 logAccess(socketWrapper);
74 } else {
75 // Default to closing the socket if the SocketEvent passed in
76 // is not consistent with the current state of the Processor
77 state = SocketState.CLOSED;
78 }
79
80 if (getLog().isTraceEnabled()) {
81 getLog().trace(
82 "Socket: [" + socketWrapper + "], Status in: [" + status + "], State out: [" + state + "]");
83 }
84
85 /*
86 * If state is already CLOSED don't call asyncPostProcess() as that will likely change the state to some
87 * other value causing processing to continue when it should cease. The AsyncStateMachine will be recycled
88 * as part of the Processor clean-up on CLOSED so it doesn't matter what state it is left in at this point.
89 */
90 if (isAsync() && state != SocketState.CLOSED) {
91 state = asyncPostProcess();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected