[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tm-cvs-commit] moberhuber org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells TerminalServiceShellWriterThread.java TerminalServiceShellOutputReader.java TerminalServiceHostShell.java

Update of /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells
In directory dev1:/tmp/cvs-serv6092/src/org/eclipse/rse/internal/services/shells

Modified Files:
	TerminalServiceShellWriterThread.java 
	TerminalServiceShellOutputReader.java 
	TerminalServiceHostShell.java 
Log Message:
Bug 335059 - TerminalServiceShellOutputReader logs error when hostShell.exit() is called

Index: TerminalServiceHostShell.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceHostShell.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TerminalServiceHostShell.java	14 Dec 2008 18:28:53 -0000	1.3
--- TerminalServiceHostShell.java	25 Jan 2011 22:50:19 -0000	1.4
***************
*** 1,4 ****
  /*******************************************************************************
!  * Copyright (c) 2006, 2008 IBM Corporation and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
--- 1,4 ----
  /*******************************************************************************
!  * Copyright (c) 2006, 2011 IBM Corporation and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
***************
*** 21,24 ****
--- 21,25 ----
   * Anna Dushistova  (MontaVista) - [240523] [rseterminals] Provide a generic adapter factory that adapts any ITerminalService to an IShellService
   * Anna Dushistova  (MontaVista) - [258720] SshHostShell fails to run command if initialWorkingDirectory supplied
+  * Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
   *******************************************************************************/
  
***************
*** 120,123 ****
--- 121,130 ----
  			fShellWriter.stopThread();
  		}
+ 		if( fStderrHandler != null ) {
+ 			fStderrHandler.stopThread();
+ 		}
+ 		if( fStdoutHandler!= null ) {
+ 			fStdoutHandler.stopThread();
+ 		}
  		fTerminalShell.exit();
  	}

Index: TerminalServiceShellWriterThread.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceShellWriterThread.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** TerminalServiceShellWriterThread.java	19 Dec 2008 14:37:58 -0000	1.2
--- TerminalServiceShellWriterThread.java	25 Jan 2011 22:50:19 -0000	1.3
***************
*** 1,4 ****
  /*******************************************************************************
!  * Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
--- 1,4 ----
  /*******************************************************************************
!  * Copyright (c) 2006, 2011 Wind River Systems, Inc. and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
***************
*** 10,13 ****
--- 10,14 ----
   * Anna Dushistova  (MontaVista) - adapted from SshShellWriterThread
   * Anna Dushistova  (MontaVista) - [240523] [rseterminals] Provide a generic adapter factory that adapts any ITerminalService to an IShellService
+  * Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
   *******************************************************************************/
  package org.eclipse.rse.internal.services.shells;
***************
*** 21,25 ****
  	private PrintWriter fOutputWriter;
  	private String fNextCommand;
! 	private boolean fIsCancelled;
  
  	/**
--- 22,26 ----
  	private PrintWriter fOutputWriter;
  	private String fNextCommand;
! 	private volatile boolean fIsCancelled;
  
  	/**

Index: TerminalServiceShellOutputReader.java
===================================================================
RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.services/src/org/eclipse/rse/internal/services/shells/TerminalServiceShellOutputReader.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** TerminalServiceShellOutputReader.java	4 Dec 2008 22:19:52 -0000	1.1
--- TerminalServiceShellOutputReader.java	25 Jan 2011 22:50:19 -0000	1.2
***************
*** 1,4 ****
  /*******************************************************************************
!  * Copyright (c) 2006, 2008 IBM Corporation and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
--- 1,4 ----
  /*******************************************************************************
!  * Copyright (c) 2006, 2011 IBM Corporation and others.
   * All rights reserved. This program and the accompanying materials
   * are made available under the terms of the Eclipse Public License v1.0
***************
*** 17,20 ****
--- 17,21 ----
   * Anna Dushistova  (MontaVista) - adapted from SshShellOutputReader
   * Anna Dushistova  (MontaVista) - [240523] [rseterminals] Provide a generic adapter factory that adapts any ITerminalService to an IShellService
+  * Rob Stryker (JBoss) - [335059] TerminalServiceShellOutputReader logs error when hostShell.exit() is called
   *******************************************************************************/
  
***************
*** 36,39 ****
--- 37,42 ----
  		AbstractHostShellOutputReader {
  	protected BufferedReader fReader;
+ 	private volatile Thread fReaderThread = null;
+ 	private volatile boolean isCanceled = false;
  	private String fPromptChars = ">$%#]"; //Characters we accept as the end of a prompt //$NON-NLS-1$;
  
***************
*** 51,54 ****
--- 54,66 ----
  			return null;
  		}
+ 		fReaderThread = Thread.currentThread();
+ 		try {
+ 			return interruptableReadLine();
+ 		} finally {
+ 			fReaderThread = null;
+ 		}
+ 	}
+ 
+ 	private IHostOutput interruptableReadLine() {
  		StringBuffer theLine = new StringBuffer();
  		StringBuffer theDebugLine = null;
***************
*** 56,60 ****
  		int ch;
  		boolean done = false;
! 		while (!done && !isFinished()) {
  			try {
  				ch = fReader.read();
--- 68,72 ----
  		int ch;
  		boolean done = false;
! 		while (!done && !isFinished() && !isCanceled) {
  			try {
  				ch = fReader.read();
***************
*** 126,132 ****
  						waitIncrement = 5; //wait only 5 msec if we think it's a prompt
  					}
! 					try {
! 						Thread.sleep(waitIncrement);
! 					} catch (InterruptedException e) {
  					}
  					if (!fReader.ready()) {
--- 138,145 ----
  						waitIncrement = 5; //wait only 5 msec if we think it's a prompt
  					}
! 					if (!isCanceled) {
! 						try {
! 							Thread.sleep(waitIncrement);
! 						} catch (InterruptedException e) { /*ignore*/ }
  					}
  					if (!fReader.ready()) {
***************
*** 138,142 ****
  				//our reader thread completely... the exception could just be
  				//temporary, and we should keep running!
! 				Activator.getDefault().logException(e);
  				return null;
  			}
--- 151,158 ----
  				//our reader thread completely... the exception could just be
  				//temporary, and we should keep running!
! 				if( !this.isCanceled ) {
! 					/* 335059: Don't log IOException on close due to cancellation */
! 					Activator.getDefault().logException(e);
! 				}
  				return null;
  			}
***************
*** 148,150 ****
--- 164,177 ----
  		return new SimpleHostOutput(theLine.toString());
  	}
+ 	
+ 	/**
+ 	 * Stop the reader Thread, forcing internalReadLine() to return.
+ 	 * Does not close the Stream.
+ 	 */
+ 	public void stopThread() {
+ 		this.isCanceled = true;
+ 		if (fReaderThread != null) {
+ 			fReaderThread.interrupt();
+ 		}
+ 	}
  }