mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 18:46:18 +00:00
ipc/android: Dup the fd from JVM and maintain it in native
- dup the fd in native part to avoid fd_san error
This commit is contained in:
parent
4cc68f07c0
commit
d5b9ae137e
|
@ -64,7 +64,11 @@ public class MonadoImpl extends IMonado.Stub {
|
|||
throw new IllegalStateException("server not available");
|
||||
} else {
|
||||
Log.i(TAG, "connect: fd ownership transferred");
|
||||
parcelFileDescriptor.detachFd();
|
||||
try {
|
||||
parcelFileDescriptor.close();
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "connect: close FileDescriptor fail!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -157,8 +157,11 @@ Java_org_freedesktop_monado_ipc_MonadoImpl_nativeAddClient(JNIEnv *env, jobject
|
|||
jni::Object monadoImpl(thiz);
|
||||
U_LOG_D("service: Called nativeAddClient with fd %d", fd);
|
||||
|
||||
int native_fd = dup(fd);
|
||||
U_LOG_D("service: transfer ownership to native and native_fd %d", native_fd);
|
||||
|
||||
// We try pushing the fd number to the server. If and only if we get a 0 return, has the server taken ownership.
|
||||
return IpcServerHelper::instance().addClient(fd);
|
||||
return IpcServerHelper::instance().addClient(native_fd);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
|
Loading…
Reference in a new issue