return true;
}
+ private void destroySocket(long socket)
+ {
+ if (running && socket != 0) {
+ // If not running the socket will be destroyed by
+ // parent pool or acceptor socket.
+ // In any case disable double free which would cause JVM core.
+ Socket.destroy(socket);
+ }
+ }
// --------------------------------------------------- Acceptor Inner Class
* socket and don't process it.
*/
if (deferAccept && (paused || !running)) {
- Socket.destroy(socket);
+ destroySocket(socket);
continue;
}
// Hand this socket off to an appropriate processor
if (!processSocketWithOptions(socket)) {
// Close socket and pool right away
- Socket.destroy(socket);
+ destroySocket(socket);
}
} catch (Throwable t) {
if (running) log.error(sm.getString("endpoint.accept.fail"), t);
if (comet) {
processSocket(addS[i], SocketStatus.STOP);
} else {
- Socket.destroy(addS[i]);
+ destroySocket(addS[i]);
}
}
// Close all sockets still in the poller
if (comet) {
processSocket(desc[n*2+1], SocketStatus.STOP);
} else {
- Socket.destroy(desc[n*2+1]);
+ destroySocket(desc[n*2+1]);
}
}
}
if (comet) {
processSocket(socket, SocketStatus.ERROR);
} else {
- Socket.destroy(socket);
+ destroySocket(socket);
}
return;
}
if (comet) {
processSocket(addS[i], SocketStatus.ERROR);
} else {
- Socket.destroy(addS[i]);
+ destroySocket(addS[i]);
}
}
}
if (comet) {
processSocket(desc[n*2+1], SocketStatus.DISCONNECT);
} else {
- Socket.destroy(desc[n*2+1]);
+ destroySocket(desc[n*2+1]);
}
continue;
}
if (comet) {
processSocket(desc[n], SocketStatus.TIMEOUT);
} else {
- Socket.destroy(desc[n]);
+ destroySocket(desc[n]);
}
}
}
addCount = 0;
for (int i = (addS.size() - 1); i >= 0; i--) {
SendfileData data = addS.get(i);
- Socket.destroy(data.socket);
+ destroySocket(data.socket);
}
addS.clear();
// Close all sockets still in the poller
int rv = Poll.pollset(sendfilePollset, desc);
if (rv > 0) {
for (int n = 0; n < rv; n++) {
- Socket.destroy(desc[n*2+1]);
+ destroySocket(desc[n*2+1]);
}
}
Pool.destroy(pool);
data.pos, data.end - data.pos, 0);
if (nw < 0) {
if (!(-nw == Status.EAGAIN)) {
- Socket.destroy(data.socket);
+ destroySocket(data.socket);
data.socket = 0;
return false;
} else {
} else {
log.warn(sm.getString("endpoint.sendfile.addfail", "" + rv, Error.strerror(rv)));
// Can't do anything: close the socket right away
- Socket.destroy(data.socket);
+ destroySocket(data.socket);
}
}
} finally {
remove(state);
// Destroy file descriptor pool, which should close the file
// Close the socket, as the response would be incomplete
- Socket.destroy(state.socket);
+ destroySocket(state.socket);
continue;
}
// Write some data using sendfile
remove(state);
// Close the socket, as the response would be incomplete
// This will close the file too.
- Socket.destroy(state.socket);
+ destroySocket(state.socket);
continue;
}
} else {
// Close the socket since this is
// the end of not keep-alive request.
- Socket.destroy(state.socket);
+ destroySocket(state.socket);
}
}
}
remove(state);
// Destroy file descriptor pool, which should close the file
// Close the socket, as the response would be incomplete
- Socket.destroy(state.socket);
+ destroySocket(state.socket);
}
}
}
getPoller().add(socket);
} else {
// Close socket and pool
- Socket.destroy(socket);
+ destroySocket(socket);
socket = 0;
}
} else {
if (!setSocketOptions(socket)
|| handler.process(socket) == Handler.SocketState.CLOSED) {
// Close socket and pool
- Socket.destroy(socket);
+ destroySocket(socket);
socket = 0;
}
}
Handler.SocketState state = async?handler.asyncDispatch(socket, status):handler.process(socket);
if (state == Handler.SocketState.CLOSED) {
// Close socket and pool
- Socket.destroy(socket);
+ destroySocket(socket);
socket = 0;
}
// Process the request from this socket
if (handler.event(socket, status) == Handler.SocketState.CLOSED) {
// Close socket and pool
- Socket.destroy(socket);
+ destroySocket(socket);
socket = 0;
}