Bug 348709 - [terminal] Revisit closing Terminal Reader Thread
Summary: [terminal] Revisit closing Terminal Reader Thread
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: terminal (show other bugs)
Version: Next   Edit
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on: 348700
Blocks:
  Show dependency tree
 
Reported: 2011-06-08 07:53 EDT by Martin Oberhuber CLA
Modified: 2020-09-04 15:12 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2011-06-08 07:53:33 EDT
Bug 348700 fixed a severe regression late in the game. This bug is for following-up with more investigation and probably a cleaner solution.

Particularly, in VT100TerminalControl#disconnectTerminal(),

- The Connector should likely be disconnected BEFORE terminating the reader job
  (otherwise with high data volume, the connector can write into a pipe that's
  no longer being read from, or even closed)

- The Reader should have a more clean method of terminating fast (other than
  interrupting the entire Thread, which may cause InterruptedException at a
  time where it's not desired, for instance while processing characters - 
  see bug 333613 comment 2)

- Revisit whether it makes sense to keep the PipedInputStream alive and 
  open for the entire lifetime of the VT100TerminalControl, even when 
  different connections read/write to it.

Test cases for these improvement include
- disconnect / reconnect terminals
   - both from the Terminal (pressing button)
   - and from the remote side (pull network cable, connection-lost, EOF)
- Terminate Eclipse with multiple terminals open.
Comment 1 Martin Oberhuber CLA 2011-06-08 17:17:16 EDT
Michael Scharf has found a potential race condition with the fix in bug 348700 (see comments there), which we should address immediately after Indigo.

I can see the following options for addressing potential issues:

- Avoid calling interrupt() at all, and do waitForAvailable(100) instead of 
  500 msec. This should be sufficient to allow doing job.join() timely.

- Instead of calling interrupt(), send a fake character (eg space) on the 
  PipedOutputStream, in order to trigger a notify on the pipe to exit
  waitForAvailable().

- Instead of calling interrupt(), introduce new API to terminate the reader 
  thread cleanly. Either readerJob.cancelNow() or PipedOutputStream.flush().

Patches and discussions are welcome on this bug.
Comment 2 Martin Oberhuber CLA 2015-09-07 03:37:40 EDT
In a Terminal Workspace with Mars, I saw some compiler warnings regarding resource leaks. Not sure if it's related to this, but could probably be looked at at the same time.
Comment 3 Jonah Graham CLA 2020-05-01 10:08:58 EDT
The Terminal component of the Eclipse Ecosystem has a new home. The Terminal is now part of the Eclipse CDT project[1].

This change means a new Git repo[2], P2 site[3] and Bugzilla component. The terminal will continue to be delivered as part of the quarterly Simultaneous Release of Eclipse as well.

The marketplace entry[4] had not been updated in a few years. It will once again install the latest release of the terminal on the latest release of the whole IDE (currently 2020-03).

If this bug is no longer relevant, please feel free to comment or close the bug. If you can confirm if this issues still occurs in the latest release please do let me know in a comment.

[1] https://wiki.eclipse.org/CDT/User/NewIn911
[2] https://git.eclipse.org/c/cdt/org.eclipse.cdt.git (in the terminal directory)
[3] current release is 9.11 - P2 site https://download.eclipse.org/tools/cdt/releases/9.11/
[4] https://marketplace.eclipse.org/content/tm-terminal

(This comment was added to all open terminal bugs along with changing the Product/component pair to CDT/terminal.)