Page MenuHomePhabricator

Make PhutilChannel::waitForAny more reasonable about detecting unselectable channels
ClosedPublic

Authored by epriestley on Dec 14 2013, 1:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 19, 5:15 PM
Unknown Object (File)
Sun, Nov 10, 12:48 AM
Unknown Object (File)
Wed, Nov 6, 8:01 AM
Unknown Object (File)
Tue, Nov 5, 11:06 PM
Unknown Object (File)
Thu, Oct 24, 8:03 PM
Unknown Object (File)
Oct 22 2024, 5:19 AM
Unknown Object (File)
Oct 20 2024, 12:25 AM
Unknown Object (File)
Oct 19 2024, 5:59 AM
Subscribers

Details

Summary

Ref T4189. Currently, channel getWriteSockets() methods return only blocked write sockets, and waitForAny() degrades to a busy wait if any channels are missing read and write sockets, assuming the channel is not a socket-based channel.

This means that if you have an unblocked, writable, socket-based channel and a blocked, readable socket-based channel, we always degrade to busy wait immediately.

An example of this occurs during git push:

  • We have one R/W channel through SSH to the git push on the user's computer.
  • We have one R/W channel through ExecFuture to the git receive-pack on the remote host.
  • When the client finishes writing, we close the "R" half of the SSH channel. This leaves it writable, socket-based, and unblocked for most of the push.

Instead, make getWriteSockets() methods return all write sockets, even if they're not blocked, and then ignore them if isWriteBufferEmpty() says we don't need to wait for them.

This is generally cleaner, and fixes several issues:

  1. The ssh-exec process no longer sits in a busy wait between the SSH read channel closing and the operation finishing.
  2. The stdin/stdout/stderr log in the SSH stuff can be simplified (next diff).
Test Plan

Ran git push of the Wine repository, saw nothing we own spend an unreasonable amount of time doing CPU stuff. Added a bunch of logging to confirm things are working reasonably under the hood.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped