use of jnr.unixsocket.UnixServerSocketChannel in project jetty.project by eclipse.
the class UnixSocketConnector method accept.
@Override
public void accept(int acceptorID) throws IOException {
LOG.warn("Blocking UnixSocket accept used. Cannot be interrupted!");
UnixServerSocketChannel serverChannel = _acceptChannel;
if (serverChannel != null && serverChannel.isOpen()) {
LOG.debug("accept {}", serverChannel);
UnixSocketChannel channel = serverChannel.accept();
LOG.debug("accepted {}", channel);
accepted(channel);
}
}
use of jnr.unixsocket.UnixServerSocketChannel in project jetty.project by eclipse.
the class UnixSocketConnector method close.
public void close() {
UnixServerSocketChannel serverChannel = _acceptChannel;
_acceptChannel = null;
if (serverChannel != null) {
removeBean(serverChannel);
// If the interrupt did not close it, we should close it
if (serverChannel.isOpen()) {
try {
serverChannel.close();
} catch (IOException e) {
LOG.warn(e);
}
}
new File(_unixSocket).delete();
}
}
use of jnr.unixsocket.UnixServerSocketChannel in project acceptance-test-harness by jenkinsci.
the class UnixDomainSocketTestServer method main.
public static void main(String[] args) throws Exception {
File path = new File("./jenkins.sock");
path.deleteOnExit();
UnixServerSocketChannel channel = UnixServerSocketChannel.open();
channel.configureBlocking(true);
channel.socket().bind(new UnixSocketAddress(path));
while (true) {
UnixSocketChannel c = channel.accept();
System.out.println("Accepted");
InputStream in = Channels.newInputStream(c);
OutputStream out = Channels.newOutputStream(c);
IOUtils.copy(in, out);
System.out.println("Closed");
c.close();
}
}
use of jnr.unixsocket.UnixServerSocketChannel in project jetty.project by eclipse.
the class UnixSocketConnector method open.
public void open() throws IOException {
if (_acceptChannel == null) {
UnixServerSocketChannel serverChannel = UnixServerSocketChannel.open();
SocketAddress bindAddress = new UnixSocketAddress(new File(_unixSocket));
serverChannel.socket().bind(bindAddress, getAcceptQueueSize());
serverChannel.configureBlocking(getAcceptors() > 0);
addBean(serverChannel);
LOG.debug("opened {}", serverChannel);
_acceptChannel = serverChannel;
}
}
use of jnr.unixsocket.UnixServerSocketChannel in project acceptance-test-harness by jenkinsci.
the class JenkinsControllerPoolProcess method processServerSocket.
/**
* Accepts connection to Unix domain socket and hand it off to a connection handling thread.
*/
private void processServerSocket() throws IOException, InterruptedException {
socket.deleteOnExit();
socket.delete();
try (UnixServerSocketChannel channel = UnixServerSocketChannel.open()) {
channel.configureBlocking(true);
channel.socket().bind(new UnixSocketAddress(socket));
System.out.println("JUT Server is ready and listening at " + socket.getAbsolutePath());
while (true) {
final UnixSocketChannel c = channel.accept();
System.out.println("Accepted");
final QueueItem qi = queue.take();
final JenkinsController j = qi.controller;
System.out.println("Handed out " + j.getUrl());
new Thread("Connection handling thread") {
@Override
public void run() {
lifecycle.import_(qi.testScope);
try {
processConnection(c, j);
} finally {
TestCleaner scope = injector.getInstance(TestCleaner.class);
if (scope != null)
scope.performCleanUp();
lifecycle.endTestScope();
}
}
}.start();
}
}
}
Aggregations