Skip to content

Commit b69d0b4

Browse files
committed
fix X server hanging after activity disconnected during redrawing
1 parent 0634a1d commit b69d0b4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/src/main/cpp/lorie/cmdentrypoint.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <randrstr.h>
2323
#include <linux/in.h>
2424
#include <arpa/inet.h>
25+
#include <poll.h>
2526
#include "lorie.h"
2627

2728
#define log(prio, ...) __android_log_print(ANDROID_LOG_ ## prio, "LorieNative", __VA_ARGS__)
@@ -421,7 +422,12 @@ void lorieRequestClipboard(void) {
421422
}
422423

423424
bool lorieConnectionAlive(void) {
424-
return conn_fd != -1;
425+
if (conn_fd == -1)
426+
return false;
427+
428+
// Check if socket is closed or has errors.
429+
struct pollfd p = { .fd = conn_fd, .events = POLLIN | POLLHUP | POLLERR | POLLRDHUP };
430+
return !(poll(&p, 1, 0) == 1 && (p.revents & (POLLERR | POLLNVAL | POLLRDHUP | POLLHUP)));
425431
}
426432

427433
static Bool addFd(__unused ClientPtr pClient, void *closure) {

0 commit comments

Comments
 (0)