The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ipc/android: Early reject if server failed to start

authored by

Jarvis Huang and committed by
Ryan Pavlik
503dae28 8d8b0d03

+13 -6
+5 -3
src/xrt/ipc/android/src/main/java/org/freedesktop/monado/ipc/MonadoImpl.java
··· 11 11 package org.freedesktop.monado.ipc; 12 12 13 13 import android.os.ParcelFileDescriptor; 14 + import android.os.RemoteException; 14 15 import android.util.Log; 15 16 import android.view.Surface; 16 17 import android.view.SurfaceHolder; 17 18 18 19 import androidx.annotation.Keep; 19 20 import androidx.annotation.NonNull; 20 - 21 - import org.jetbrains.annotations.NotNull; 22 21 23 22 import java.io.IOException; 24 23 ··· 64 63 } 65 64 66 65 @Override 67 - public void connect(@NotNull ParcelFileDescriptor parcelFileDescriptor) { 66 + public void connect(@NonNull ParcelFileDescriptor parcelFileDescriptor) throws RemoteException { 68 67 nativeStartServer(); 69 68 int fd = parcelFileDescriptor.getFd(); 70 69 Log.i(TAG, "connect: given fd " + fd); ··· 75 74 } catch (IOException e) { 76 75 // do nothing, probably already closed. 77 76 } 77 + 78 + // throw an exception so that client can gracefully fail 79 + throw new IllegalStateException("server not available"); 78 80 } else { 79 81 Log.i(TAG, "connect: fd ownership transferred"); 80 82 parcelFileDescriptor.detachFd();
+1
src/xrt/ipc/server/ipc_server_process.c
··· 832 832 int ret = init_all(s); 833 833 if (ret < 0) { 834 834 free(s); 835 + startup_complete_callback(data); 835 836 return ret; 836 837 } 837 838
+7 -3
src/xrt/targets/service-lib/service_target.cpp
··· 100 100 waitForStartupComplete() 101 101 { 102 102 std::unique_lock<std::mutex> lock{server_mutex}; 103 - bool completed = startup_cond.wait_for(lock, START_TIMEOUT_SECONDS, 104 - [&]() { return server != NULL && startup_complete; }); 103 + bool completed = startup_cond.wait_for(lock, START_TIMEOUT_SECONDS, [&]() { return startup_complete; }); 104 + 105 + if (!server) { 106 + U_LOG_E("Failed to create ipc server"); 107 + } 108 + 105 109 if (!completed) { 106 110 U_LOG_E("Server startup timeout!"); 107 111 } 108 - return completed; 112 + return server && completed; 109 113 } 110 114 111 115 //! Reference to the ipc_server, managed by ipc_server_process