On Fri Mar 21 11:19:40 2025 +0000, Jacek Caban wrote:
IMHO, this is an unnecessary complication. The session pointer is shared across the entire process and remains at a fixed location for its lifetime, so we can simply store a global pointer during initialization. Using this function for locking is both more complex than necessary and suboptimal, as it busy-loops when the server modifies an unrelated handle. Since handle entries are immutable for their lifetime, synchronization only requires validating the handle before and after reading the entry. See [this commit](https://gitlab.winehq.org/jacek/wine/-/commit/d532493c3dbcdebe937f38ab45f819...) for an example. To make this work on the server side, we just need to ensure that generation is the last field modified when allocating a handle and the first field changed when freeing it, there is no need for `SHARED_WRITE_*`.
BTW, an advantage of not using this locator infrastructure is that it would allow direct access to shared data from user space, eliminating the need for some Wine-specific exports (that’s why I looked into it while evaluating the win32u migration).