Page MenuHomePhabricator

Support non-blocking reads for ExecFuture on Windows
ClosedPublic

Authored by hach-que on Feb 5 2015, 3:27 AM.
Tags
None
Referenced Files
F14048445: D11688.diff
Thu, Nov 14, 7:47 AM
F14040941: D11688.diff
Mon, Nov 11, 2:28 PM
F14035887: D11688.diff
Sun, Nov 10, 7:56 AM
F14032884: D11688.id28128.diff
Sat, Nov 9, 4:05 PM
F14032736: D11688.id28128.diff
Sat, Nov 9, 3:29 PM
F14020615: D11688.diff
Wed, Nov 6, 12:57 AM
F14008756: D11688.id28194.diff
Wed, Oct 30, 6:33 AM
F14003074: D11688.diff
Sat, Oct 26, 1:54 AM
Subscribers

Details

Summary

This enables non-blocking reads on Windows for ExecFuture by redirecting the process's standard output and error to temporary files. We then use stream_select on the open files to determine when there is new data to read.

This is primarily to enable setUpdateInterval to work on FutureIterator when running under Windows, which is essential when performing arc unit --everything with lots of tests.

Test Plan

Ran arc diff and arc unit --everything on a project with lots of tests. Saw everything behave correctly and saw setUpdateInterval work as it does on Linux.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

hach-que retitled this revision from to Support non-blocking reads for ExecFuture on Windows.
hach-que updated this object.
hach-que edited the test plan for this revision. (Show Details)
hach-que added a reviewer: epriestley.
hach-que edited edge metadata.
  • Remove commented code

Some inlines. Since this mechanism is certain to be fraught with peril, can we reasonably have an ExecFuture opt in to it for now until we're more confident it works properly? Then only your stuff will break if we hit further Windows weirdness. For example, something like setUseWindowsFileStreams(true).

src/future/exec/ExecFuture.php
588–589

This seems completely crazy -- do feof(), fseek(), ftell(), etc., not work? I'd expect them to work properly since these are standard files.

599

$real_length is only written to and never read, so something is awry in any case.

690–691

These objects are local and not preserved, so I would expect that we'll try to destroy the temporary files immediately upon exiting this function, and fail. In net, I'd expect that we will never remove these files. Do these files get removed?

Roughly, I'd expect that you need to save these to $this->something. That might also resolve the unlink issue on its own.

We should make every reasonable effort to unlink these files.

The default permissions of TempFile also aren't as locked-down as they could be, but it seems like these files should be as tightly locked as possible. Not sure if we can reasonably do anything or what chmod() translates to under Windows, though.

695–696

These calls should be tested for errors.

715–716

As above.

hach-que edited edge metadata.
  • Changes from code review feedback

Remove stream_select as things appear to work without it

Uh, don't derp on the arc diff

epriestley edited edge metadata.
epriestley added inline comments.
src/future/exec/ExecFuture.php
685–686

These variables are unused.

701–702

pht()

721–722

pht()

This revision is now accepted and ready to land.Feb 9 2015, 2:17 PM
hach-que edited edge metadata.

Update for code review

This revision was automatically updated to reflect the committed changes.