aboutsummaryrefslogtreecommitdiffstats
path: root/android/framebuffer-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'android/framebuffer-core.c')
-rw-r--r--android/framebuffer-core.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/android/framebuffer-core.c b/android/framebuffer-core.c
index 978bfc0..3eb7665 100644
--- a/android/framebuffer-core.c
+++ b/android/framebuffer-core.c
@@ -136,6 +136,9 @@ fbupdatenotify_delete(FBUpdateNotify* desc)
}
}
+/* Implemented in android/console.c */
+extern void destroy_control_fb_client(void);
+
/*
* Asynchronous I/O callback launched when writing framebuffer notifications
* to the socket.
@@ -147,6 +150,15 @@ corefb_io_func(void* opaque, int fd, unsigned events)
{
CoreFramebuffer* core_fb = opaque;
+ if (events & LOOP_IO_READ) {
+ // We don't expect the UI client to write anything here, except when
+ // the client gets disconnected.
+ loopIo_dontWantWrite(&core_fb->io);
+ loopIo_dontWantRead(&core_fb->io);
+ destroy_control_fb_client();
+ return;
+ }
+
while (core_fb->fb_update_head != NULL) {
FBUpdateNotify* current_update = core_fb->fb_update_head;
// Lets continue writing of the current notification.
@@ -192,6 +204,9 @@ corefb_create(int sock, const char* protocol, QFrameBuffer* fb)
ret->sock = sock;
ret->looper = looper_newCore();
loopIo_init(&ret->io, ret->looper, sock, corefb_io_func, ret);
+ // Since we're overriding the read callback with our looper's I/O routine,
+ // we need to have set our read callback here to monitor disconnections.
+ loopIo_wantRead(&ret->io);
ret->fb = fb;
ret->fb_update_head = NULL;
ret->fb_update_tail = NULL;