1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

dispd: Wait for console rendering to finish.

This prevents a race condition where the console may still be rendering,
but the process may be able to get data on the screen faster, which results
in visual corruption as the two race.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-12-23 21:00:17 +01:00
parent ca7ad9709f
commit ef53864d36
7 changed files with 45 additions and 2 deletions

View file

@ -26,6 +26,7 @@
#include <sys/display.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
@ -121,5 +122,19 @@ bool dispd_session_setup_game_rgba(struct dispd_session* session)
perror(chvideomode);
exit(127);
}
// TODO: HACK: The console may be rendered asynchronously and it is still
// rendering to the framebuffer, but this process may be able to write to
// the framebuffer before it is done. We need to wait for the console to
// finish to fix this race condition.
int ttyfd = open("/dev/tty", O_WRONLY);
if ( 0 <= ttyfd )
{
// TODO: There is no fsync system call yet! Whoops! However, closing a
// file descriptor also happens to sync it, so this actually works.
//fsync(ttyfd);
close(ttyfd);
}
return session->is_rgba = true;
}