Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] Acceptor Threads and _acceptChannel config

Hi All,
I had a question about the acceptors created in AbstractConnector when creating a ServerConnector for general use.  I'm starting the server as follows:

        Server server = new Server();

        HttpConfiguration httpConfigOff = new HttpConfiguration();
        httpConfigOff.setSendDateHeader(false);
        httpConfigOff.setSendServerVersion(false);
        httpConfigOff.setSendXPoweredBy(false);

        ServerConnector connectorOff = new ServerConnector(server, new HttpConnectionFactory(httpConfigOff));
        connectorOff.setPort(9090);
        server.addConnector(connectorOff);

        HttpConfiguration httpConfigDefault = new HttpConfiguration();

        ServerConnector connectorDefault = new ServerConnector(server, new HttpConnectionFactory(httpConfigDefault));
        connectorDefault.setPort(9191);
        server.addConnector(connectorDefault);

        server.setHandler(new Handler.Abstract()
        {
            @Override
            public boolean handle(Request request, Response response, Callback callback)
            {
                response.getHeaders().put(HttpHeader.CONTENT_TYPE, "text/plain; charset=utf-8");
                response.write(true, BufferUtil.toBuffer("Greetings.", StandardCharsets.UTF_8), callback);
                return true;
            }
        });

server.start();

From the comments and code (https://github.com/jetty/jetty.project/blob/47959d983523118e1c9cb63935112b0a29db99cd/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java#L320), it seems an AbstractConnector should block when waiting on accepts. 

But the _acceptChannel is configured to be non-blocking down the line (https://github.com/jetty/jetty.project/blob/47959d983523118e1c9cb63935112b0a29db99cd/jetty-core/jetty-server/src/main/java/org/eclipse/jetty/server/ServerConnector.java#L235) . This is consistent with creating and blocking on selectors, accepting in a non-blocking fashion, etc.

Do the acceptor threads created with AbstractConnector simply run busy without blocking ? 

Any resources for a better understanding of the code are also welcome.

Regards,


Back to the top