mobile-shell / mobile-shell/mosh

convert Mosh from using main loops to event-driven code

Open
#816 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
14.5k
Forks
865
PR merge metrics
No merged PRs in 30d

Description

Currently mosh-client, mosh-server and the test programs use main loops with a select() at the top, and selective invocation of various functions depending on timeouts or ready file descriptors.

There's a few problems with this:

  • The handling of timeouts for the network code is a bit tangled because of the lack of explicit timeout events
  • mosh-client does blocking writes to the user's terminal, which can distort time-dependent calculations if the terminal blocks. The is probably also true for mosh-server and writing input to the pty to the user's session. There's other parts of Mosh where timers and the current timestamp can get disconnected from reality, too.
  • Adding new files and/or events (like ssh authentication) to Mosh results in more complexity

Converting Mosh to use events, probably using something like libevent, would probably clarify Mosh's internal structure significantly. I don't think it would be too difficult, but it's not trivial either. Things that would need to be done:

  • In mosh-client, the terminal display would need to run asynchronously from the network code, writing to the terminal in possibly multiple non-blocking writes. I think this means that the terminal display would have to remember (and retain in saved_states) the last state that was written to the terminal, and write the diff between that state and the most-current state on the next go around.
  • Network timers would need to be significantly reworked to use timers and events independent of code execution paths

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by mapping the select()-based main loops in mosh-client, mosh-server, and the test programs, then evaluate whether libevent fits the proposed event model. Focus on asynchronous terminal and pty writes, retained saved_states, and independent network timers. Done means the main loops use explicit events without the described blocking and timeout problems.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.