Jinoh Kang (@iamahuman) commented about dlls/win32u/winstation.c:
#define DESKTOP_ALL_ACCESS 0x01ff
+static pthread_mutex_t session_lock = PTHREAD_MUTEX_INITIALIZER; +static struct shared_session *shared_session;
+struct shared_session +{
- LONG ref;
- LONG weak_ref;
I think our code now matches "locking" pattern more closely than strong/weak ref analogy. In fact IMHO it's harder for reviewers to follow the code when we think of the usual "strong" vs "weak" pattern, inviting gratuitous bikeshedding (e.g., "why do shared session weakref and session object weakref behave differently?" "because keeping track of weak/strong in session objects are more complex, so I deleted it.")
I propose the following nomenclature-only changes (without changes to behavior)[^refs]:
```suggestion:-1+0 LONG refs; // previously "weak_ref". Keeps the reference count of the shared_session object itself. LONG locks; // previously "ref". Similar to GlobalLock or GdipBitmapLockBits, keeps the "lock" (don't free) count of the memory buffer. ```
In addition:
| Before | After | |:------------------------------|:--------------------------------------------| | `shared_session_acquire_weak` | `shared_session_acquire`[^1] | | `shared_session_acquire` | `shared_session_try_lock`[^2][^try] | | `shared_session_release_weak` | `shared_session_release`[^1] | | `shared_session_release` | `shared_session_unlock`[^2] | | `session_object_acquire_weak` | `session_object_acquire`[^1] | | `session_object_acquire` | `session_object_try_lock_acquire`[^3][^try] | | `session_object_release_weak` | `session_object_release`[^1] | | `session_object_release` | `session_object_unlock_release`[^3] | | `weak reference` (comment) | `reference` | | `strong reference` (comment) | `lock` or `locked reference` |
[^refs]: I made `weak_ref` plural so that it's consistent with `locks`, and more unlikely to be confused with previous `ref` (strongref) when doing find-replace. That said, I don't mind `ref` either. [^1]: Weak-only acquire/release [^2]: Strong-only acquire/release, with special case for strong=0 (since nonzero strongref implies one unique weakref) [^3]: Strong *as well as* weak acquire/release [^try]: "Try" à la [TryAcquireSRWLockShared](https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-tryacquiresrwlockshared). I think this communicates "can fail" nature of these functions. Feel free to drop `try_` if it feels too verbose.