Fix dispd console rendering sync hack not using fsync(2).

This commit is contained in:
Jonas 'Sortie' Termansen 2014-06-11 23:52:19 +02:00
parent 9f0e9f2fd4
commit 0a4e15cf97
1 changed files with 11 additions and 10 deletions

View File

@ -128,17 +128,18 @@ bool dispd_session_setup_game_rgba(struct dispd_session* session)
exit(127); exit(127);
} }
// TODO: HACK: The console may be rendered asynchronously and it is still // HACK: The console may be rendered asynchronously and it might still be
// rendering to the framebuffer, but this process may be able to write to // rendering to the framebuffer, however this process is about to do
// the framebuffer before it is done. We need to wait for the console to // bitmapped graphics to the framebuffer as well. Since there is no
// finish to fix this race condition. // synchronization with the terminal except not writing to it, there
int ttyfd = open("/dev/tty", O_WRONLY); // is a small window where both are fighting for the framebuffer.
if ( 0 <= ttyfd ) // We can resolve this issue by simply fsync()ing the terminal, which
// causes the scheduled console rendering to finish before returning.
int tty_fd = open("/dev/tty", O_WRONLY);
if ( 0 <= tty_fd )
{ {
// TODO: There is no fsync system call yet! Whoops! However, closing a fsync(tty_fd);
// file descriptor also happens to sync it, so this actually works. close(tty_fd);
//fsync(ttyfd);
close(ttyfd);
} }
return session->is_rgba = true; return session->is_rgba = true;