org.apache.tomcat.jni.Poll Java Examples
The following examples show how to use
org.apache.tomcat.jni.Poll.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Displays the list of sockets in the pollers. */ @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("Poller"); long[] res = new long[actualPollerSize * 2]; for (int i = 0; i < pollers.length; i++) { int count = Poll.pollset(pollers[i], res); buf.append(" [ "); for (int j = 0; j < count; j++) { buf.append(desc[2*j+1]).append(" "); } buf.append("]"); } return buf.toString(); }
Example #2
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Remove specified socket from the pollers. Must only be called from * {@link Poller#run()}. */ private boolean removeFromPoller(long socket) { if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemove", Long.valueOf(socket))); } int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] < actualPollerSize) { rv = Poll.remove(pollers[i], socket); if (rv != Status.APR_NOTFOUND) { pollerSpace[i]++; connectionCount.decrementAndGet(); if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemoved", Long.valueOf(socket))); } break; } } } timeouts.remove(socket); return (rv == Status.APR_SUCCESS); }
Example #3
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Remove specified socket from the pollers. Must only be called from * {@link Poller#run()}. */ private void removeFromPoller(long socket) { if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemove", Long.valueOf(socket))); } int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] < actualPollerSize) { rv = Poll.remove(pollers[i], socket); if (rv != Status.APR_NOTFOUND) { pollerSpace[i]++; connectionCount.decrementAndGet(); if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemoved", Long.valueOf(socket))); } break; } } } timeouts.remove(socket); }
Example #4
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * Displays the list of sockets in the pollers. */ @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("Poller"); long[] res = new long[actualPollerSize * 2]; for (int i = 0; i < pollers.length; i++) { int count = Poll.pollset(pollers[i], res); buf.append(" [ "); for (int j = 0; j < count; j++) { buf.append(desc[2*j+1]).append(" "); } buf.append("]"); } return buf.toString(); }
Example #5
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Displays the list of sockets in the pollers. */ @Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append("Poller"); long[] res = new long[actualPollerSize * 2]; for (int i = 0; i < pollers.length; i++) { int count = Poll.pollset(pollers[i], res); buf.append(" [ "); for (int j = 0; j < count; j++) { buf.append(desc[2*j+1]).append(" "); } buf.append("]"); } return buf.toString(); }
Example #6
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Remove specified socket from the pollers. Must only be called from * {@link Poller#run()}. */ private boolean removeFromPoller(long socket) { if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemove", Long.valueOf(socket))); } int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] < actualPollerSize) { rv = Poll.remove(pollers[i], socket); if (rv != Status.APR_NOTFOUND) { pollerSpace[i]++; connectionCount.decrementAndGet(); if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.pollerRemoved", Long.valueOf(socket))); } break; } } } timeouts.remove(socket); return (rv == Status.APR_SUCCESS); }
Example #7
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public void registerReadInterest() { // Make sure an already closed socket is not added to the poller synchronized (closedLock) { if (closed) { return; } if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.registerRead", this)); } Poller p = ((AprEndpoint) getEndpoint()).getPoller(); if (p != null) { p.add(getSocket().longValue(), getReadTimeout(), Poll.APR_POLLIN); } } }
Example #8
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void registerWriteInterest() { // Make sure an already closed socket is not added to the poller synchronized (closedLock) { if (closed) { return; } if (log.isDebugEnabled()) { log.debug(sm.getString("endpoint.debug.registerWrite", this)); } ((AprEndpoint) getEndpoint()).getPoller().add( getSocket().longValue(), getWriteTimeout(), Poll.APR_POLLOUT); } }
Example #9
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Allocate a new poller of the specified size. */ protected long allocatePoller(int size, long pool, int timeout) { try { return Poll.create(size, pool, 0, timeout * 1000); } catch (Error e) { if (Status.APR_STATUS_IS_EINVAL(e.getError())) { log.info(sm.getString("endpoint.poll.limitedpollsize", "" + size)); return 0; } else { log.error(sm.getString("endpoint.poll.initfail"), e); return -1; } } }
Example #10
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Remove socket from the poller. * * @param data the sendfile data which should be removed */ protected void remove(SendfileData data) { int rv = Poll.remove(sendfilePollset, data.socket); if (rv == Status.APR_SUCCESS) { sendfileCount--; } sendfileData.remove(Long.valueOf(data.socket)); }
Example #11
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Destroy the poller. */ protected void destroy() { sendfileRunning = false; // Wait for polltime before doing anything, so that the poller threads // exit, otherwise parallel destruction of sockets which are still // in the poller can cause problems try { synchronized (this) { this.notify(); this.wait(pollTime / 1000); } } catch (InterruptedException e) { // Ignore } // Close any socket remaining in the add queue for (int i = (addS.size() - 1); i >= 0; i--) { SendfileData data = addS.get(i); closeSocket(data.socket); } // Close all sockets still in the poller int rv = Poll.pollset(sendfilePollset, desc); if (rv > 0) { for (int n = 0; n < rv; n++) { closeSocket(desc[n*2+1]); } } Pool.destroy(pool); sendfileData.clear(); }
Example #12
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Add specified socket to one of the pollers. Must only be called from * {@link Poller#run()}. */ protected boolean addToPoller(long socket, int events) { int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] > 0) { rv = Poll.add(pollers[i], socket, events); if (rv == Status.APR_SUCCESS) { pollerSpace[i]--; connectionCount.incrementAndGet(); return true; } } } return false; }
Example #13
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Allocate a new poller of the specified size. * @param size The size * @param pool The pool from which the poller will be allocated * @param timeout The timeout * @return the poller pointer */ protected long allocatePoller(int size, long pool, int timeout) { try { return Poll.create(size, pool, 0, timeout * 1000); } catch (Error e) { if (Status.APR_STATUS_IS_EINVAL(e.getError())) { log.info(sm.getString("endpoint.poll.limitedpollsize", "" + size)); return 0; } else { log.error(sm.getString("endpoint.poll.initfail"), e); return -1; } } }
Example #14
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Add specified socket to one of the pollers. Must only be called from * {@link Poller#run()}. */ protected boolean addToPoller(long socket, int events) { int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] > 0) { rv = Poll.add(pollers[i], socket, events); if (rv == Status.APR_SUCCESS) { pollerSpace[i]--; connectionCount.incrementAndGet(); return true; } } } return false; }
Example #15
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * Allocate a new poller of the specified size. */ protected long allocatePoller(int size, long pool, int timeout) { try { return Poll.create(size, pool, 0, timeout * 1000); } catch (Error e) { if (Status.APR_STATUS_IS_EINVAL(e.getError())) { log.info(sm.getString("endpoint.poll.limitedpollsize", "" + size)); return 0; } else { log.error(sm.getString("endpoint.poll.initfail"), e); return -1; } } }
Example #16
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override public void run() { synchronized (socket) { if (!deferAccept) { if (setSocketOptions(socket)) { getPoller().add(socket.getSocket().longValue(), getConnectionTimeout(), Poll.APR_POLLIN); } else { // Close socket and pool getHandler().process(socket, SocketEvent.CONNECT_FAIL); closeSocket(socket.getSocket().longValue()); socket = null; } } else { // Process the request from this socket if (!setSocketOptions(socket)) { // Close socket and pool getHandler().process(socket, SocketEvent.CONNECT_FAIL); closeSocket(socket.getSocket().longValue()); socket = null; return; } // Process the request from this socket Handler.SocketState state = getHandler().process(socket, SocketEvent.OPEN_READ); if (state == Handler.SocketState.CLOSED) { // Close socket and pool closeSocket(socket.getSocket().longValue()); socket = null; } } } }
Example #17
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Remove socket from the poller. * * @param data the sendfile data which should be removed */ protected void remove(SendfileData data) { int rv = Poll.remove(sendfilePollset, data.socket); if (rv == Status.APR_SUCCESS) { sendfileCount--; } sendfileData.remove(Long.valueOf(data.socket)); }
Example #18
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Destroy the poller. */ protected void destroy() { sendfileRunning = false; // Wait for polltime before doing anything, so that the poller threads // exit, otherwise parallel destruction of sockets which are still // in the poller can cause problems try { synchronized (this) { this.notify(); this.wait(pollTime / 1000); } } catch (InterruptedException e) { // Ignore } // Close any socket remaining in the add queue for (int i = (addS.size() - 1); i >= 0; i--) { SendfileData data = addS.get(i); closeSocket(data.socket); } // Close all sockets still in the poller int rv = Poll.pollset(sendfilePollset, desc); if (rv > 0) { for (int n = 0; n < rv; n++) { closeSocket(desc[n*2+1]); } } Pool.destroy(pool); sendfileData.clear(); }
Example #19
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Add specified socket to one of the pollers. Must only be called from * {@link Poller#run()}. */ private boolean addToPoller(long socket, int events) { int rv = -1; for (int i = 0; i < pollers.length; i++) { if (pollerSpace[i] > 0) { rv = Poll.add(pollers[i], socket, events); if (rv == Status.APR_SUCCESS) { pollerSpace[i]--; connectionCount.incrementAndGet(); return true; } } } return false; }
Example #20
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Destroy the poller. */ protected void destroy() { sendfileRunning = false; // Wait for polltime before doing anything, so that the poller threads // exit, otherwise parallel destruction of sockets which are still // in the poller can cause problems try { synchronized (this) { this.notify(); this.wait(pollTime / 1000); } } catch (InterruptedException e) { // Ignore } // Close any socket remaining in the add queue for (int i = (addS.size() - 1); i >= 0; i--) { SendfileData data = addS.get(i); closeSocket(data.socket); } // Close all sockets still in the poller int rv = Poll.pollset(sendfilePollset, desc); if (rv > 0) { for (int n = 0; n < rv; n++) { closeSocket(desc[n*2+1]); } } Pool.destroy(pool); sendfileData.clear(); }
Example #21
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * Remove socket from the poller. * * @param data the sendfile data which should be removed */ protected void remove(SendfileData data) { int rv = Poll.remove(sendfilePollset, data.socket); if (rv == Status.APR_SUCCESS) { sendfileCount--; } sendfileData.remove(Long.valueOf(data.socket)); }
Example #22
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 4 votes |
public static int merge(int flag1, int flag2) { return ((flag1 & Poll.APR_POLLIN) | (flag2 & Poll.APR_POLLIN)) | ((flag1 & Poll.APR_POLLOUT) | (flag2 & Poll.APR_POLLOUT)); }
Example #23
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public static int merge(int flag1, int flag2) { return ((flag1 & Poll.APR_POLLIN) | (flag2 & Poll.APR_POLLIN)) | ((flag1 & Poll.APR_POLLOUT) | (flag2 & Poll.APR_POLLOUT)); }
Example #24
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 4 votes |
public boolean write() { return (flags & Poll.APR_POLLOUT) == Poll.APR_POLLOUT; }
Example #25
Source File: AprEndpoint.java From tomcatsrc with Apache License 2.0 | 4 votes |
public boolean read() { return (flags & Poll.APR_POLLIN) == Poll.APR_POLLIN; }
Example #26
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public boolean write() { return (flags & Poll.APR_POLLOUT) == Poll.APR_POLLOUT; }
Example #27
Source File: AprEndpoint.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
public boolean read() { return (flags & Poll.APR_POLLIN) == Poll.APR_POLLIN; }
Example #28
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Destroy the poller. */ protected synchronized void destroy() { // Wait for pollerTime before doing anything, so that the poller // threads exit, otherwise parallel destruction of sockets which are // still in the poller can cause problems try { this.notify(); this.wait(pollerCount * pollTime / 1000); } catch (InterruptedException e) { // Ignore } // Close all sockets in the close queue SocketInfo info = closeList.get(); while (info != null) { // Make sure we aren't trying add the socket as well as close it addList.remove(info.socket); // Make sure the socket isn't in the poller before we close it removeFromPoller(info.socket); // Poller isn't running at this point so use destroySocket() // directly destroySocket(info.socket); info = closeList.get(); } closeList.clear(); // Close all sockets in the add queue info = addList.get(); while (info != null) { // Make sure the socket isn't in the poller before we close it removeFromPoller(info.socket); // Poller isn't running at this point so use destroySocket() // directly destroySocket(info.socket); info = addList.get(); } addList.clear(); // Close all sockets still in the poller for (int i = 0; i < pollerCount; i++) { int rv = Poll.pollset(pollers[i], desc); if (rv > 0) { for (int n = 0; n < rv; n++) { destroySocket(desc[n*2+1]); } } } Pool.destroy(pool); connectionCount.set(0); }
Example #29
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 4 votes |
public static int merge(int flag1, int flag2) { return ((flag1 & Poll.APR_POLLIN) | (flag2 & Poll.APR_POLLIN)) | ((flag1 & Poll.APR_POLLOUT) | (flag2 & Poll.APR_POLLOUT)); }
Example #30
Source File: AprEndpoint.java From Tomcat8-Source-Read with MIT License | 4 votes |
public boolean write() { return (flags & Poll.APR_POLLOUT) == Poll.APR_POLLOUT; }