Mark,
On 9/3/26 4:44 AM, Mark Thomas wrote:
On 02/09/2026 12:14, Rémy Maucherat wrote:
Hi,
The WsWriteTimeout uses a rather uncommon ordered set [by timeout
instant], probably to make timeout checks much faster.
That was the idea.
The code review does not like it, and it seems to start causing issues
when useAsyncIO is disabled (useAsyncIO=true works) on the connector.
onWritePossible then could get called multiple times by the container
on incomplete writes, each adding a new registration with a new
timeout for one endpoint. There's no unregister, which could be added,
but it seems it's not working so well.
> > Anyway things get a bit complicated fast ... Maybe we could switch to
a "dumb" way to implement this instead (= with a ConcurrentHashMap and
no tricks) ?
The more I look at the code, the more issues I find and the more I am
convinced that an alternative approach is required.
The choices appear to be:
- Maintain an ordered list (by timeout expiry) of endpoints. This is
what the current code tries and fails to do.
- Sort the endpoints by timeout expiry in the background thread.
- Iterate through the entire list of endpoints in the background thread.
>
The first option, as you point out, gets complicated, fast. The second
option would ensure that entries are timed out in the correct order. The
third option is the simplest.
We could also use a compound structure: one for fast lookups for
timeouts and another for ... whatever else.
I am trying to determine how important it is that endpoints are timed
out in the correct order. In the static resource cache, that has similar
code, it was more obvious that correct order had a benefit. The benefit
is not as clear for WebSocket writes but I think it is worth doing as it
simplifies reasoning about timeout behaviour.
It would use "public void register(WsRemoteEndpointImplServer
endpoint, long timeoutExpiry)" instead, and I have a patch ready.
Hang on to that patch. I may still end up tying myself in knots.
:D
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]