mangoapp: Select unique SysV message queue #1660
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows multiple mangoapp instances to run on the same system.
Currently gamescope and mangoapp communicate using a System V message queue with the key
0xffffffff
. This is becauseftok("mangoapp", 65)
returns-1
when it fails to findmangoapp
in the current working directory.This means messages from any instance of gamescope will be received by any instance of mangoapp.
A simple fix for this would be to use
ftok(".", 65)
which would generate a key from theinode
of the working directory and the number65
, however this would break backwards compatibility and cause collisions for gamescope instances sharing a working directory.Instead I decided to use a POSIX message queues with the descriptive name/gamescope-mangoapp-{gamescope pid}
which gets shared with mangoapp using the environment variableMANGOAPP_MQ_NAME
.This branch avoids collisions by using the current directory and incrementing the
proj_id
field untilgetmsg
successfully creates a new queue.This implementation also leaves the old message queues intact which should silently fail when they fill up.
Works with flightlessmango/MangoHud#1502