On Thu Feb 6 12:19:18 2025 +0000, Rémi Bernon wrote:
Okay, this is not obvious from the code, maybe it could be made more obvious that the inproc_sync and the server-side state are mutually exclusive. Maybe a union of the server state members with the inproc pointer? Also, creating the inproc_sync on object creation instead of using lazy init would make it more obvious that in this particular case the owner that is passed to the kernel is always the initial mutex owner. Btw I see that this is true for every other object type, where the lazy init makes it non-obvious that the values passed to every inproc sync creation are the initial state values.
It was done this way to avoid allocating extra memory or fds for objects which are never used from the client side. You could limit it to event/semaphore/mutex, which are useless otherwise, but even those can often be created without ever being used (in fact, I believe one of the first applications to leak hundreds of thousands of objects did this.) I'm not sure that always creating an inproc_sync object and its backing ntsync fd would be a worthwhile improvement.