Bug 175308 - initial filter expansion problem with dstore/shell processes connection
Summary: initial filter expansion problem with dstore/shell processes connection
Status: VERIFIED FIXED
Alias: None
Product: Target Management
Classification: Tools
Component: RSE (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 2.0.1   Edit
Assignee: David McKnight CLA
QA Contact: Martin Oberhuber CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-23 11:46 EST by David McKnight CLA
Modified: 2007-11-27 15:40 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David McKnight CLA 2007-02-23 11:46:15 EST
When I create a new "Linux" connection that uses dstore file and shell services but the "shell processes" service, I hit a strange filter expansion problem.  The first time I expand the "My Home" filter, nothing comes back.  The connection is not decorated with the active indicator yet it is connected.

I have to refresh the file subsystem in order to get the active indicator showing and the filter to show children.


-----------Enter bugs above this line-----------
TM 2.0M5 Testing
installation : eclipse-SDK-3.3M5 (I20070209-1006), cdt-4.0M5, emf-2.3M5
RSE install  : RSE-SDK I200702221906
java.runtime : Sun 1.4.2_13
os.name:     : Windows XP 5.1, Service Pack 1
------------------------------------------------
systemtype   : Unix-ssh / Linux-dstore (daemon Launcher)
targetos     : SUSE Linux Enterprise Server 9, Kernel 2.6.5-7.97-default
targetuname  : Linux  
EST 2006 i686 athlon i386 GNU/Linux
targetvm     : Sun Java HotSpot(TM) Client VM (build 1.4.2_13-b06, mixed mode)
------------------------------------------------
Comment 1 Martin Oberhuber CLA 2007-02-23 11:56:51 EST
I don't think that's major.

First of all, dstore users would use dstore processes normally, and with ssh this works fine - I tested it. Second, there is a simple workaround (connect something else first).
Comment 2 David McKnight CLA 2007-07-23 17:07:26 EDT
The problem is that HostShellProcessAdapter.exitValue() gets called it the shell process service init method after running a check to check something.  This calls IHostShell.exitValue() to determine whether a shell is done:

	public synchronized int exitValue() {
	  if (hostShell.isActive())
		throw new IllegalThreadStateException();
	
		// No way to tell what the exit value was.
		// TODO it would be possible to get the exit value
		// when the remote process is started like this:
		//   sh -c 'remotecmd ; echo "-->RSETAG<-- $?\"'
		// Then the output steram could be examined for -->RSETAG<-- to get the exit value.
		return 0;
	}

The problem is that a shell may not yet have finished but the exception gets thrown anyway.  If we wait a little longer, then the shell will complete.   A simple solution to this would be to insert a sleep after the first isActive() and check again although that's not a perfect solution.  Any other ideas?   
Comment 3 Martin Oberhuber CLA 2007-07-24 09:31:40 EDT
(In reply to comment #2)
The exitValue() method must work like that (i.e. throw an exception) in order to be compatible with java.lang.Process.

In the concrete case, we do not get an exit value from the remote anyways. I see no sense waiting for it (at least not in the current Thread) and thus blocking execution of other commands - since even if we'd get it, it would just be used for printing an error message.

Thus I'd vote for modifying the calling code like this (note that the HostSHellProcessAdapter p must be final for this):


Job waiter = new Job("LinuxShellProcessWaiter") {
   public void run() {
      try {
         p.waitFor();
         if (p.exitValue()!=0) {
            /*etc as right now*/
         }
      } catch(InterruptedException e) { 
         return Status.CANCEL_STATUS;
      }
      return Status.OK_STATUS;
   }
};
waiter.schedule();

Testing this, you should then verify that the remote shells actually do exit eventually -- if not it's a bug in dstore.
Comment 4 David McKnight CLA 2007-07-24 11:26:35 EDT
I've taken Martin's suggestion in using the job to wait for the exit value.
Comment 5 Martin Oberhuber CLA 2007-07-24 11:42:20 EDT
Dave I think there are two more occurrences of p.exitValue() in the shell processes plugin to be fixed the same way. Also, please check that the Job we create is not visible to the user. You might have to do

   waiter.setSystem(true);

Before you do that, please verify that the Jobs eventually go away. We don't want to have memory leaking because the shells never terminate.

Reopening till all this is clarified.
Comment 6 David McKnight CLA 2007-07-24 12:23:51 EDT
(In reply to comment #5)
> Dave I think there are two more occurrences of p.exitValue() in the shell
> processes plugin to be fixed the same way. Also, please check that the Job we
> create is not visible to the user. You might have to do
> 
>    waiter.setSystem(true);

The only issue seemed to be the startup but your right that we should deal with this similarly in other uses of p.exitValue(). I've committed the fixes for this.

> 
> Before you do that, please verify that the Jobs eventually go away. We don't
> want to have memory leaking because the shells never terminate.
> 

The jobs do go away.