
Wrap struct lws_conmon into an lws_cao_t, and give that its own lifecycle distinct from any wsi. Conmon contains what we want, but it was composed into the wsi and so had to follow its single wsi's lifecycle. Let's give it its own lifecycle independent of the wsi it happened to be born for, and wrap it with an lws_cao_t that can contain private things. We can still present the lws_conmon_t unchanged to the public apis that expect it. Client wsi with the connection have at least one CAO, the HEAD CAO is taken as the active one for a wsi, it may acquire other "losing" CAOs as it goes along. desc moves into this new CAO, it's a bit messy because only client connections have CAOs, but server connections and listeners have desc. So we have a .desc in the wsi still for that, and desc in the CAO for client, and new helpers to take care of which to use.
1.5 KiB
lws_cao Connection Attempt Objects
lws_cao_t
are internal lws objects that act as entries in a multi-indexed
database of recent connection attempts, what path they took, and what the
results were.
Client network connections have at least one HEAD CAO that contains the network
socket desc and the related CONMON. A client network connection wsi can get
additions "losing" CAOs from connection attempts that didn't "win" also attached
to the tail of its cao_owner
.
CAOs contain CONMON information as well as additional members.
Background
Multi-homed client devices have become very common, eg, Android phones may have multiple network interfaces and handle a mix of ipv4 and ipv6, possibly with multiple source addresses for each family.
At the same time, it's not uncommon for some of the options to be degraded or nonfunctional, such as ipv6 local addresses that cannot route out to the internet.
In order to understand the situation the client device finds itself in, which may be changeable itself, client connections have to do more work to measure what happens during connection attempts and remember it so it can make decisions next time driven by what it has been observing.
That's the function of CAOs.
It's not enough to simplify the network topology at the client using blunt instruments like "ipv4 vs ipv6", each network interface and path component like a gateway has its own story.