mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-30 18:38:32 +00:00
ipc/android: Dup the socket fd in native side, close the fd on java side.
This commit is contained in:
parent
e7f82c297a
commit
d7f0380f53
src/xrt/ipc
|
@ -100,8 +100,14 @@ public class Client implements ServiceConnection {
|
|||
}
|
||||
intent = null;
|
||||
|
||||
//! @todo do we close this first?
|
||||
fd = null;
|
||||
if (fd != null) {
|
||||
try {
|
||||
fd.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
fd = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -91,6 +92,13 @@ ipc_connect(struct ipc_connection *ipc_c)
|
|||
IPC_ERROR(ipc_c, "Service Connect error!");
|
||||
return false;
|
||||
}
|
||||
// The ownership belongs to the Java object. Dup because the fd will be
|
||||
// closed when client destroy.
|
||||
socket = dup(socket);
|
||||
if (socket < 0) {
|
||||
IPC_ERROR(ipc_c, "Failed to dup fd with error %d!", errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
ipc_c->imc.socket_fd = socket;
|
||||
ipc_c->imc.ll = ipc_c->ll;
|
||||
|
|
Loading…
Reference in a new issue