mirror of
https://github.com/FeralInteractive/gamemode.git
synced 2025-06-07 08:07:20 +02:00
gamemode: Optimize detection of dupe registers
GameMode can do a pretty expensive lookup function now for the exe. Let's spare some CPU cycles by detecting a duplicate PID early. Nothing makes use of the exe path at this stage. Signed-off-by: Kai Krakow <kai@kaishome.de>
This commit is contained in:
parent
2a0c6e7098
commit
8214f93630
@ -454,15 +454,18 @@ bool game_mode_context_register(GameModeContext *self, pid_t client)
|
|||||||
fputs("OOM\n", stderr);
|
fputs("OOM\n", stderr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cl->executable = game_mode_context_find_exe(client);
|
|
||||||
if (!cl->executable)
|
|
||||||
goto error_cleanup;
|
|
||||||
|
|
||||||
|
/* Check the PID first to spare a potentially expensive lookup for the exe */
|
||||||
if (game_mode_context_has_client(self, client)) {
|
if (game_mode_context_has_client(self, client)) {
|
||||||
LOG_ERROR("Addition requested for already known process [%d]\n", client);
|
LOG_ERROR("Addition requested for already known process [%d]\n", client);
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Lookup the executable */
|
||||||
|
cl->executable = game_mode_context_find_exe(client);
|
||||||
|
if (!cl->executable)
|
||||||
|
goto error_cleanup;
|
||||||
|
|
||||||
/* Check our blacklist and whitelist */
|
/* Check our blacklist and whitelist */
|
||||||
if (!config_get_client_whitelisted(self->config, cl->executable)) {
|
if (!config_get_client_whitelisted(self->config, cl->executable)) {
|
||||||
LOG_MSG("Client [%s] was rejected (not in whitelist)\n", cl->executable);
|
LOG_MSG("Client [%s] was rejected (not in whitelist)\n", cl->executable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user