Just fixed jPOS-85, now checking for "s instanceof SSLSocket". I didn't use that check in first place because I though we could get away by checking the socket factory, but problem is on channels created by an ISOServer, the socket factory is assigned to the ISOServer object, not the individual channels.
As for the SO_LINGER, we just try to expedite closing on flaky networks (mostly GPRS), so the system tries to handle the handshake, but in 5 seconds it just forgets about it. I believe the default is way larger. Using this trick, we recover faster and avoid 'pool exhausted' errors in the ISOServers.
Answering individual questions from your previous post:
>
> To prevent sessions being leaked the switch closes the old channel on receipt of a message on the new channel (using a map from terminal id to channel)
>
You could just set a timeout on the socket, that's what we do for long lived connections. We know that there has to be traffic (either due to 0800s or high activity) say every minute, so we set a 5 minutes timeout, if we don't get a message in 5 minutes, the system gets an EOFException and the resource is freed.
>
> We can work around this in our switch (calling close in another thread perhaps) but in this use case the original TCP RST behaviour was actually perfect.
> We have another use case where an orderly TCP disconnect is preferable (switch upgrades) but only to be good TCP citizens (and avoid a memory leak
> in our terminal manufacturers code caused by receipt of TCP RST packets).
>
That was exactly our use case, poorly written TCP stacks in the terminal was causing problems (perhaps yours?)
>
> Perhaps adding a disconnect(boolean orderly) method leaving disconnect() calling disconnect(true) would help.
> Hopefully it wouldn't hinder. I can try it out in a fork, see if it works for us and create a pull request
>
That wouldn't hurt, and we can also make it configurable via Q2, with a default backward compatibility.
>
> We also have some hacks to work around not using Q2 which break upgrading from 1.6.6.
> I will float the idea with my employer (if you guys are open to the idea) of creating some pull requests for these too.
> They would be small changes to QMUX and ChannelAdaptor I think.
>
Sure!
>
> Switching to Q2 is not viable in the short term for us I think. Yet we'd like to stay up to date.
>
You'll find out that it is not that hard to make the move, you can run Jetty from Q2, or Q2 from Jetty, it's as easy as instantiating a Q2 object and let it run.
--