RootShell: hoist out synchronization
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
		
							parent
							
								
									14638b10ae
								
							
						
					
					
						commit
						23c09eb655
					
				| @ -57,13 +57,11 @@ public class RootShell { | |||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public boolean isRunning() { |     public synchronized boolean isRunning() { | ||||||
|         try { |         try { | ||||||
|             // Throws an exception if the process hasn't finished yet. |             // Throws an exception if the process hasn't finished yet. | ||||||
|             synchronized (this) { |  | ||||||
|             if (process != null) |             if (process != null) | ||||||
|                 process.exitValue(); |                 process.exitValue(); | ||||||
|             } |  | ||||||
|         } catch (final IllegalThreadStateException ignored) { |         } catch (final IllegalThreadStateException ignored) { | ||||||
|             // The existing process is still running. |             // The existing process is still running. | ||||||
|             return true; |             return true; | ||||||
| @ -149,14 +147,12 @@ public class RootShell { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void stop() throws IOException { |     public synchronized void stop() throws IOException { | ||||||
|         synchronized (this) { |  | ||||||
|         if (process != null) { |         if (process != null) { | ||||||
|             process.destroy(); |             process.destroy(); | ||||||
|             process = null; |             process = null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     public static class NoRootException extends Exception { |     public static class NoRootException extends Exception { | ||||||
|         public NoRootException(final String message, final Throwable cause) { |         public NoRootException(final String message, final Throwable cause) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user