int getSSLInfoI(int id) { synchronized (closedLock) { if (closed) { return 0; } try { return SSLSocket.getInfoI(getSocket().longValue(), id); } catch (Exception e) { throw new IllegalStateException(e); } } }
String getSSLInfoS(int id) { synchronized (closedLock) { if (closed) { return null; } try { return SSLSocket.getInfoS(getSocket().longValue(), id); } catch (Exception e) { throw new IllegalStateException(e); } } }
byte[] getSSLInfoB(int id) { synchronized (closedLock) { if (closed) { return null; } try { return SSLSocket.getInfoB(getSocket().longValue(), id); } catch (Exception e) { throw new IllegalStateException(e); } } } }
private int fillReadBuffer(boolean block, ByteBuffer to) throws IOException { if (closed) { throw new IOException(sm.getString("socket.apr.closed", getSocket())); if (getBlockingStatus() == block) { if (block) { Socket.timeoutSet(getSocket().longValue(), getReadTimeout() * 1000); result = Socket.recvb(getSocket().longValue(), to, to.position(), to.remaining()); readDone = true; Socket.timeoutSet(getSocket().longValue(), getReadTimeout() * 1000); } else { Socket.timeoutSet(getSocket().longValue(), 0); try { writeLock.unlock(); result = Socket.recvb(getSocket().longValue(), to, to.position(), to.remaining()); } finally { } else { throw new IOException(sm.getString("socket.apr.read.error", Integer.valueOf(-result), getSocket(), this));
@Override protected void doWrite(boolean block, ByteBuffer from) throws IOException { if (closed) { throw new IOException(sm.getString("socket.apr.closed", getSocket())); if (getBlockingStatus() == block) { if (block) { Socket.timeoutSet(getSocket().longValue(), getWriteTimeout() * 1000); Socket.timeoutSet(getSocket().longValue(), getWriteTimeout() * 1000); } else { Socket.timeoutSet(getSocket().longValue(), 0);
thisTime = Socket.sendb(getSocket().longValue(), sslOutputBuffer, sslOutputBuffer.position(), sslOutputBuffer.limit()); if (thisTime > 0) { thisTime = Socket.sendb(getSocket().longValue(), from, from.position(), from.remaining()); if (thisTime > 0) { } else if (thisTime < 0) { throw new IOException(sm.getString("socket.apr.write.error", Integer.valueOf(-thisTime), getSocket(), this));
@Override protected void populateRemoteHost() { if (closed) { return; } try { long socket = getSocket().longValue(); long sa = Address.get(Socket.APR_REMOTE, socket); remoteHost = Address.getnameinfo(sa, 0); if (remoteAddr == null) { remoteAddr = Address.getip(sa); } } catch (Exception e) { log.warn(sm.getString("endpoint.warn.noRemoteHost", getSocket()), e); } }
@Override public void close() { getEndpoint().getHandler().release(this); synchronized (closedLock) { // APR typically crashes if the same socket is closed twice so // make sure that doesn't happen. if (closed) { return; } closed = true; if (sslOutputBuffer != null) { ByteBufferUtils.cleanDirectBuffer(sslOutputBuffer); } ((AprEndpoint) getEndpoint()).getPoller().close(getSocket().longValue()); } }
@Override protected void populateRemotePort() { if (closed) { return; } try { long socket = getSocket().longValue(); long sa = Address.get(Socket.APR_REMOTE, socket); Sockaddr addr = Address.getInfo(sa); remotePort = addr.port; } catch (Exception e) { log.warn(sm.getString("endpoint.warn.noRemotePort", getSocket()), e); } }
@Override protected void populateLocalName() { if (closed) { return; } try { long socket = getSocket().longValue(); long sa = Address.get(Socket.APR_LOCAL, socket); localName =Address.getnameinfo(sa, 0); } catch (Exception e) { log.warn(sm.getString("endpoint.warn.noLocalName"), e); } }
@Override protected void populateLocalAddr() { if (closed) { return; } try { long socket = getSocket().longValue(); long sa = Address.get(Socket.APR_LOCAL, socket); localAddr = Address.getip(sa); } catch (Exception e) { log.warn(sm.getString("endpoint.warn.noLocalAddr"), e); } }
@Override public void registerReadInterest() { // Make sure an already closed socket is not added to the poller synchronized (closedLock) { if (closed) { return; } Poller p = ((AprEndpoint) getEndpoint()).getPoller(); if (p != null) { p.add(getSocket().longValue(), getReadTimeout(), Poll.APR_POLLIN); } } }
@Override protected void populateLocalPort() { if (closed) { return; } try { long socket = getSocket().longValue(); long sa = Address.get(Socket.APR_LOCAL, socket); Sockaddr addr = Address.getInfo(sa); localPort = addr.port; } catch (Exception e) { log.warn(sm.getString("endpoint.warn.noLocalPort"), e); } }
@Override public SendfileState processSendfile(SendfileDataBase sendfileData) { ((SendfileData) sendfileData).socket = getSocket().longValue(); return ((AprEndpoint) getEndpoint()).getSendfile().add((SendfileData) sendfileData); }
@Override public void registerWriteInterest() { // Make sure an already closed socket is not added to the poller synchronized (closedLock) { if (closed) { return; } ((AprEndpoint) getEndpoint()).getPoller().add( getSocket().longValue(), getWriteTimeout(), Poll.APR_POLLOUT); } }