Skip to content

4.4.5 why the httpcore-nio release conn is before the request future is done, this may trigger request be canceled, this lead to request future don't get the result but really the response is return. #44

Closed
gavenpeng wants to merge 156 commits intomasterfrom
4.4.x

Conversation

@gavenpeng
Copy link
Copy Markdown

@gavenpeng gavenpeng commented May 21, 2017

I am use httpcore-nio found a strange problem, the request is very faster,bu no get the result,I read the code,has the follow problem.

while http request response complete, the reactor io thread then set request consumer is complete, the http reactor io thread to invoke the completed method of the RequestExecutionCallback,the follower is code:

public void completed(final T result) {
try {
this.connPool.release(this.poolEntry, true);
} finally {
this.future.completed(result);
}
}

the connPool.release method need get the lock, release lock after and process the leasing request, if blocked while get the lock then the request future complete is delay, this may be trigger the tomcat thread found the handler is done but the request future is no done, lead to cancel the request ,no return result,but really is the request response is return; the code is :
private void initExecution(
final HttpAsyncClientExchangeHandler handler, final NHttpClientConnection conn) {

    final HttpContext context = conn.getContext();
    synchronized (context) {
        context.setAttribute(HttpAsyncRequestExecutor.HTTP_HANDLER, handler);
        if (!conn.isOpen()) {
            handler.failed(new ConnectionClosedException("Connection closed"));
        } else {
            //唤醒IO线程,开始发送请求
            conn.requestOutput();
        }
    }     
    //the request consumer is complete,
    if (handler.isDone()) {
        try {
            handler.close();
        } catch (final IOException ex) {
            log(ex);
        }
    }
}

I also have a problem about the method of initExecution,why need the synchronized the context, the context is
bind with conn, the conn is hold by only one thread.please help me ,thanks

ok2c and others added 30 commits October 21, 2014 11:18
…chronized access

Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1638960 13f79535-47bb-0310-9956-ffa450edef68
…nchronized scope

Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1638961 13f79535-47bb-0310-9956-ffa450edef68
…buffer, 0)

Contributed by Dmitry Potapov <dpotapov at yandex-team.ru>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1639702 13f79535-47bb-0310-9956-ffa450edef68
… / key managers when loading trust / ket material from multiple sources

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1644008 13f79535-47bb-0310-9956-ffa450edef68
…subclass in order perform additional trust / key material validation

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1645438 13f79535-47bb-0310-9956-ffa450edef68
…long as there is still data in the session input buffer

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1658389 13f79535-47bb-0310-9956-ffa450edef68
Restored logic with UNAVAILABLE relase identifier

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpcore/branches/4.4.x@1658945 13f79535-47bb-0310-9956-ffa450edef68
@gavenpeng gavenpeng changed the title 4.4.5 4.4.5 why the httpcore-nio release conn is before the request future is done, this may trigger request be canceled May 21, 2017
@gavenpeng gavenpeng changed the title 4.4.5 why the httpcore-nio release conn is before the request future is done, this may trigger request be canceled 4.4.5 why the httpcore-nio release conn is before the request future is done, this may trigger request be canceled, this lead to request future don't get the result but really the response is return. May 21, 2017
@ok2c
Copy link
Copy Markdown
Member

ok2c commented May 24, 2017

Could you please update your PR to include only those changes you would like to be incorporated into the project? At the moment your PR pulls 143 commits and changes 314 files.

@garydgregory
Copy link
Copy Markdown
Member

garydgregory commented May 24, 2017 via email

… throwing "Maximum line length limit exceeded" exception in some corner cases
@ok2c
Copy link
Copy Markdown
Member

ok2c commented Jun 26, 2017

@gavenpeng If you are unwilling to update the PR could you please close it?

@gavenpeng gavenpeng closed this Jul 2, 2017
@gavenpeng
Copy link
Copy Markdown
Author

closed

@gavenpeng gavenpeng reopened this Jul 2, 2017
@ok2c
Copy link
Copy Markdown
Member

ok2c commented Jul 15, 2017

@gavenpeng Could you please close this pull request?

ok2c and others added 3 commits August 25, 2017 11:28
…not used.

Currently for each remote connection we make an SSLIOSession.
Each SSLIOSession has 4 buffers:
private final SSLBuffer inEncrypted;
private final SSLBuffer outEncrypted;
private final SSLBuffer inPlain;
private final SSLBuffer outPlain;
And each of these buffers occupies 16K (64K per remote connection).
If an application uses NIO for long polling and there are (for example) 9000 idle long polling connections waiting for notifications.
This makes 9000 * 64K = 576 000K (576MB).
As outPlain buffer is not used if we remove it this will save 25% of the memory from the buffers used for the remote connections. In the example case this is 144MB.
@gmcdonald
Copy link
Copy Markdown

All done here.

@gmcdonald gmcdonald closed this Aug 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants