// socket associated with the processor. Exact requirements
// depend on type of long poll
longPoll(socket, processor);
- } else if (state == SocketState.OPEN){
+ } else if (state == SocketState.OPEN) {
// In keep-alive but between requests. OK to recycle
// processor. Continue to poll for the next request.
release(socket, processor, false, true);
+ } else if (state == SocketState.SENDFILE) {
+ // Sendfile in progress. If it fails, the socket will be
+ // closed. If it works, the socket will be re-added to the
+ // poller
+ release(socket, processor, false, false);
} else {
// Connection closed. OK to recycle the processor.
release(socket, processor, true, false);
boolean keptAlive = false;
boolean openSocket = false;
+ boolean sendfileInProgress = false;
while (!error && keepAlive && !comet && !isAsync() && !endpoint.isPaused()) {
sendfileData.socket = socketRef;
sendfileData.keepAlive = keepAlive;
if (!((AprEndpoint)endpoint).getSendfile().add(sendfileData)) {
+ // Didn't send all of the data to sendfile.
if (sendfileData.socket == 0) {
- // Didn't send all the data but the socket is no longer
- // set. Something went wrong. Close the connection.
- // Too late to set status code.
+ // The socket is no longer set. Something went wrong.
+ // Close the connection. Too late to set status code.
if (log.isDebugEnabled()) {
log.debug(sm.getString(
"http11processor.sendfile.error"));
}
error = true;
} else {
- openSocket = true;
+ // The sendfile Poller will add the socket to the main
+ // Poller once sendfile processing is complete
+ sendfileInProgress = true;
}
break;
}
} else if (comet || isAsync()) {
return SocketState.LONG;
} else {
- return (openSocket) ? SocketState.OPEN : SocketState.CLOSED;
+ if (sendfileInProgress) {
+ return SocketState.SENDFILE;
+ } else {
+ return (openSocket) ? SocketState.OPEN : SocketState.CLOSED;
+ }
}
}
public enum SocketState {
// TODO Add a new state to the AsyncStateMachine and remove
// ASYNC_END (if possible)
- OPEN, CLOSED, LONG, ASYNC_END
+ OPEN, CLOSED, LONG, ASYNC_END, SENDFILE
}
Improve error handling for HTTP APR if an error occurs while using
sendfile. (markt)
</add>
+ <fix>
+ Ensure that when using sendfile, HTTP APR sockets are not added to
+ multiple pollers. This may cause errors during shutdown. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">