tomaswolf opened a new pull request, #224: URL: https://github.com/apache/mina-sshd/pull/224
Handling of global requests with want-reply=true was synchronous. This is fine if the call is made on a non-I/O thread, but to be able to use global requests in I/O threads, an asynchronous handling is needed. Provide an asynchronous variant of Session.request() that returns a future and that takes an optional reply handler as argument. If a handler is given, it will be invoked by the framework once the reply is received, on the I/O thread that received the reply. The future can in this case be used to wait until the request has indeed be sent. Without handler, the future can be used to await the reply on some other thread, or to handle it via a future listener. This makes global request handling much more flexible, avoids that a synchronous implementation blocks an I/O thread, and it avoids problems with making global requests while a key exchange is ongoing. It also removes the restriction that there must be only one pending global request per SSH session. The implementation keeps a FIFO list of requests sent, and associates a reply with the front-most request in that list. Only requests with want-reply=true enter that list. Because of SSHD-968 we must also know the SSH message sequence number of each global request made with want-reply=true. The previous implementation assumed that the when a request was made, the next packet written would be that request. But that may not be true when a KEX is ongoing. Improve that implementation to report the sequence number via a callback when the request's packet is indeed sent. In AbstractSession.preClose(), fail all pending global requests. Additionally, make Session.request() also work for global requests with want-reply=false. Such requests can also be written directly with Session.writePacket(), but it seems natural and convenient for users of the library to also be able to use Session.request() for this. Add some fairly advanced unit tests to verify the implementation. The new unit tests showcase different implementations, somewhat simplified, of a client-side OpenSshHostKeysHandler. Add some technical documentation on global requests. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
