Skip to content

Commit

Permalink
Simplify read and write registration for non-blocking I/O.
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1655292 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Jan 28, 2015
1 parent e80a0ae commit c43ae24
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 35 deletions.
6 changes: 3 additions & 3 deletions java/org/apache/coyote/ajp/AjpProcessor.java
Expand Up @@ -582,7 +582,7 @@ public final void action(ActionCode actionCode, Object param) {
}
case NB_READ_INTEREST: {
if (!endOfStream) {
socketWrapper.regsiterForEvent(true, false);
socketWrapper.registerReadInterest();
}
break;
}
Expand Down Expand Up @@ -644,7 +644,7 @@ public SocketState asyncDispatch(SocketStatus status) {
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
} catch (IllegalStateException x) {
socketWrapper.regsiterForEvent(false, true);
socketWrapper.registerWriteInterest();
}
} else if (status == SocketStatus.OPEN_READ &&
request.getReadListener() != null) {
Expand All @@ -653,7 +653,7 @@ public SocketState asyncDispatch(SocketStatus status) {
asyncStateMachine.asyncOperation();
}
} catch (IllegalStateException x) {
socketWrapper.regsiterForEvent(true, false);
socketWrapper.registerReadInterest();
}
}

Expand Down
11 changes: 3 additions & 8 deletions java/org/apache/tomcat/util/net/AprEndpoint.java
Expand Up @@ -2629,20 +2629,15 @@ public boolean isReadPending() {

@Override
public void registerReadInterest() {
regsiterForEvent(true, false);
((AprEndpoint) getEndpoint()).getPoller().add(
getSocket().longValue(), -1, true, false);
}


@Override
public void registerWriteInterest() {
regsiterForEvent(false, true);
}


@Override
public void regsiterForEvent(boolean read, boolean write) {
((AprEndpoint) getEndpoint()).getPoller().add(
getSocket().longValue(), -1, read, write);
getSocket().longValue(), -1, false, true);
}


Expand Down
6 changes: 0 additions & 6 deletions java/org/apache/tomcat/util/net/Nio2Endpoint.java
Expand Up @@ -1284,12 +1284,6 @@ public void registerWriteInterest() {
}


@Override
public void regsiterForEvent(boolean read, boolean write) {
// NO-OP. Appropriate handlers will already have been registered.
}


public void awaitBytes() {
if (getSocket() == null) {
return;
Expand Down
16 changes: 0 additions & 16 deletions java/org/apache/tomcat/util/net/NioEndpoint.java
Expand Up @@ -1570,22 +1570,6 @@ public void registerWriteInterest() {
}


@Override
public void regsiterForEvent(boolean read, boolean write) {
SelectionKey key = getSocket().getIOChannel().keyFor(
getSocket().getPoller().getSelector());
if (read) {
this.interestOps(this.interestOps() | SelectionKey.OP_READ);
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
}
if (write) {
this.interestOps(this.interestOps() | SelectionKey.OP_WRITE);
key.interestOps(key.interestOps() | SelectionKey.OP_READ);
}
}



@Override
public SendfileDataBase createSendfileData(String filename, long pos, long length) {
return new SendfileData(filename, pos, length);
Expand Down
2 changes: 0 additions & 2 deletions java/org/apache/tomcat/util/net/SocketWrapperBase.java
Expand Up @@ -509,8 +509,6 @@ protected void addToBuffers(byte[] buf, int offset, int length) {

public abstract void registerWriteInterest();

public abstract void regsiterForEvent(boolean read, boolean write);

public abstract SendfileDataBase createSendfileData(String filename, long pos, long length);

/**
Expand Down

0 comments on commit c43ae24

Please sign in to comment.