diff options
author | Scott Anderson <ascent12@hotmail.com> | 2017-07-09 22:23:54 +1200 |
---|---|---|
committer | Scott Anderson <ascent12@hotmail.com> | 2017-07-09 22:23:54 +1200 |
commit | 3779ef802ddf89067e1588077ed8c72b4674565a (patch) | |
tree | 9ddd98fb283d6f7769cdf875f960f9721f6ed440 /session/direct-ipc.c | |
parent | 2f2c8205d841a98649e9697ad5ba8cfe430ffaa7 (diff) |
Stop remembering the drm fd in child.
Diffstat (limited to 'session/direct-ipc.c')
-rw-r--r-- | session/direct-ipc.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/session/direct-ipc.c b/session/direct-ipc.c index ef8de68c..fbbde02a 100644 --- a/session/direct-ipc.c +++ b/session/direct-ipc.c @@ -116,7 +116,7 @@ static void communicate(int sock) { int drm_fd = -1; bool running = true; - while (running && recv_msg(sock, NULL, &msg, sizeof(msg)) >= 0) { + while (running && recv_msg(sock, &drm_fd, &msg, sizeof(msg)) >= 0) { switch (msg.type) { case MSG_OPEN: errno = 0; @@ -140,29 +140,24 @@ static void communicate(int sock) { goto error; } - if (maj == DRM_MAJOR) { - if (drmSetMaster(fd)) { - ret = errno; - } else { - drm_fd = fd; - } + if (maj == DRM_MAJOR && drmSetMaster(fd)) { + ret = errno; } error: send_msg(sock, ret ? -1 : fd, &ret, sizeof(ret)); - - if (fd != drm_fd) { - close(fd); - } + close(fd); break; case MSG_SETMASTER: drmSetMaster(drm_fd); + close(drm_fd); send_msg(sock, -1, NULL, 0); break; case MSG_DROPMASTER: drmDropMaster(drm_fd); + close(drm_fd); send_msg(sock, -1, NULL, 0); break; @@ -173,7 +168,6 @@ error: } } - close(drm_fd); close(sock); } @@ -189,17 +183,17 @@ int direct_ipc_open(int sock, const char *path) { return err ? -err : fd; } -void direct_ipc_setmaster(int sock) { +void direct_ipc_setmaster(int sock, int fd) { struct msg msg = { .type = MSG_SETMASTER }; - send_msg(sock, -1, &msg, sizeof(msg)); + send_msg(sock, fd, &msg, sizeof(msg)); recv_msg(sock, NULL, NULL, 0); } -void direct_ipc_dropmaster(int sock) { +void direct_ipc_dropmaster(int sock, int fd) { struct msg msg = { .type = MSG_DROPMASTER }; - send_msg(sock, -1, &msg, sizeof(msg)); + send_msg(sock, fd, &msg, sizeof(msg)); recv_msg(sock, NULL, NULL, 0); } |