main: Check for error in msgrcv

pull/1290/head
Joshua Ashton 2 months ago committed by flightlessmango
parent 7c7cb9a1dc
commit baa06da2ad

@ -162,56 +162,63 @@ static void msg_read_thread(){
while (1){ while (1){
// make sure that the message recieved is compatible // make sure that the message recieved is compatible
// and that we're not trying to use variables that don't exist (yet) // and that we're not trying to use variables that don't exist (yet)
size_t msg_size = msgrcv(msgid, (void *) raw_msg, sizeof(raw_msg), 1, 0) + sizeof(long); size_t msg_size = msgrcv(msgid, (void *) raw_msg, sizeof(raw_msg), 1, 0);
if (hdr->version == 1){ if (msg_size != -1)
if (msg_size > offsetof(struct mangoapp_msg_v1, visible_frametime_ns)){ {
bool should_new_frame = false; if (hdr->version == 1){
if (mangoapp_v1->visible_frametime_ns != ~(0lu) && (!params.no_display || logger->is_active())) { if (msg_size > offsetof(struct mangoapp_msg_v1, visible_frametime_ns)){
update_hud_info_with_frametime(sw_stats, params, vendorID, mangoapp_v1->visible_frametime_ns); bool should_new_frame = false;
should_new_frame = true; if (mangoapp_v1->visible_frametime_ns != ~(0lu) && (!params.no_display || logger->is_active())) {
} update_hud_info_with_frametime(sw_stats, params, vendorID, mangoapp_v1->visible_frametime_ns);
should_new_frame = true;
}
if (msg_size > offsetof(mangoapp_msg_v1, fsrUpscale)){ if (msg_size > offsetof(mangoapp_msg_v1, fsrUpscale)){
HUDElements.g_fsrUpscale = mangoapp_v1->fsrUpscale; HUDElements.g_fsrUpscale = mangoapp_v1->fsrUpscale;
if (params.fsr_steam_sharpness < 0) if (params.fsr_steam_sharpness < 0)
HUDElements.g_fsrSharpness = mangoapp_v1->fsrSharpness; HUDElements.g_fsrSharpness = mangoapp_v1->fsrSharpness;
else else
HUDElements.g_fsrSharpness = params.fsr_steam_sharpness - mangoapp_v1->fsrSharpness; HUDElements.g_fsrSharpness = params.fsr_steam_sharpness - mangoapp_v1->fsrSharpness;
} }
if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_mangoapp_steam]){ if (!HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_mangoapp_steam]){
steam_focused = get_prop("GAMESCOPE_FOCUSED_APP_GFX") == 769; steam_focused = get_prop("GAMESCOPE_FOCUSED_APP_GFX") == 769;
} else { } else {
steam_focused = false; steam_focused = false;
} }
// if (!steam_focused && mangoapp_v1->pid != previous_pid){ // if (!steam_focused && mangoapp_v1->pid != previous_pid){
// string path = "/tmp/mangoapp/" + to_string(mangoapp_v1->pid) + ".json"; // string path = "/tmp/mangoapp/" + to_string(mangoapp_v1->pid) + ".json";
// ifstream i(path); // ifstream i(path);
// if (i.fail()){ // if (i.fail()){
// sw_stats.engine = EngineTypes::GAMESCOPE; // sw_stats.engine = EngineTypes::GAMESCOPE;
// } else { // } else {
// json j; // json j;
// i >> j; // i >> j;
// sw_stats.engine = static_cast<EngineTypes> (j["engine"]); // sw_stats.engine = static_cast<EngineTypes> (j["engine"]);
// } // }
// previous_pid = mangoapp_v1->pid; // previous_pid = mangoapp_v1->pid;
// } // }
if (msg_size > offsetof(mangoapp_msg_v1, latency_ns)) if (msg_size > offsetof(mangoapp_msg_v1, latency_ns))
gamescope_frametime(mangoapp_v1->app_frametime_ns, mangoapp_v1->latency_ns); gamescope_frametime(mangoapp_v1->app_frametime_ns, mangoapp_v1->latency_ns);
if (should_new_frame) if (should_new_frame)
{
{ {
std::unique_lock<std::mutex> lk(mangoapp_m); {
new_frame = true; std::unique_lock<std::mutex> lk(mangoapp_m);
new_frame = true;
}
mangoapp_cv.notify_one();
screenWidth = mangoapp_v1->outputWidth;
screenHeight = mangoapp_v1->outputHeight;
} }
mangoapp_cv.notify_one();
screenWidth = mangoapp_v1->outputWidth;
screenHeight = mangoapp_v1->outputHeight;
} }
} else {
printf("Unsupported mangoapp struct version: %i\n", hdr->version);
exit(1);
} }
} else { }
printf("Unsupported mangoapp struct version: %i\n", hdr->version); else
exit(1); {
printf("mangoapp: msgrcv returned -1 with error %d - %s\n", errno, strerror(errno));
} }
} }
} }

Loading…
Cancel
Save