-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to proc_open pipe handling #261
Conversation
Changed the descriptorspec for the stderr pipe to 'w' (it was 'a' but this seems only applicable when streaming to a file, not a pipe) Reversed the order in which the stderr and stdout pipes are read to get around an apparent bug in the proc_open
Update SourceSVN.php
I'm wondering if the more robust approach is to use |
@bright-tools regarding your suggestion, according to user notes in PHP manual Maybe an alternative solution would be to use a file to read STDERR ? |
there should be a solution for this issue. for me, the unblock should just be executed. so it only gets better. |
I ran into this problem the first time yesterday. I am running a post-commit hook (POST to checkin.php) Assuming STDERR will never exceed BUFFERSIZE (unlikely but possible), reversing the order the pipes are
|
I finally got round to cleaning up & testing what I hope is a robust way to deal with this. I wrote an off-line "stress test" for the code which seems to show it dealing with a large quantity of data spread across the two streams. Only tested in Windows at the moment, needs more testing before submitting a pull request. |
Today, using the Change from:
|
@fhaut I think it's been established by now that using @bright-tools where do you stand with those tests ? FYI @raspopov submitted another PR for this issue (see #268) but that relies on stream_set_blocking() so based on previous discussion I don't think it's the right solution. |
I noticed that closing STDIN and reading STDOUT before STDERR helps a lot in all cases including STDERR-only and STDOUT-only results of SVN run. BTW "a" is not working. |
@bright-tools were you able to make any progress on this issue ? |
@bright-tools ping |
Can confirm this is still an issue on Windows. I followed obmsch and raspopov's instructions, and that allowed me to get up and running. While awaiting a more robust solution, I think it would be a good idea to at least implement the stream order swap in the master branch. The plugin couldn't import merges for me at all until I did that. After swapping the order the situation has improved from "broken" to "fragile" - it definitely works when SVN doesn't return errors, and it looks like it should continue to work so long as SVN doesn't return very long error content? I'm a little worried about reverting to the broken state if I deploy a plugin update which doesn't include that change. Obviously @bright-tools's robust fix would be even better. |
We ran into this bug too (I had created #314). Swapping the two stream_get_contents() "fixed" the issue for us. Do I understand correctly from reading all the above that there's no robust/correct solution known? |
Yep. That being said, I would be fine with implementing the swap of streams, since based on the feedback provided here by various users, it would appear to improve the plugin's behavior overall. Please cast your vote by up/down-voting this post if you agree with this approach. |
@dregad so is 7 upvotes enough to swap those statements? :) |
For the standing svn users of us, this should be finally resolved. Sorry but what @bright-tools offers is The simple swap of STDERR and STDOUT is the right way to go! After that a deadlock could only happen, if (svnexe) spills out >MAX_BUFFERED_PIPE_SIZE(STDERR). As unlikely that is, I'd would |
@dregad so we've got 8 up votes and 0 down votes. Is there anything worse about swapping the streams vs what's in master now? Maybe there's an even better solution somewhere, but that shouldn't stop an incremental improvement, right? Thanks. |
Due to limitations on the buffering of pipes and therefore possible resulting deadlocks, the order in which the pipes are read is crucial. This reordering of the pipes is just a partial workaround. Processing STDOUT before STDERR will NOT(!) prevent a deadlock if the output to STDERR exceeds the pipe's max buffered size. Regardless, as discussed in #261, it is better to handle an unlikely error scenario, than to frequently get stuck when processing good commits. Signed-off-by: Damien Regad <[email protected]> - Original commit message and comment block reworded - Updated changelog - Bump SourceSVN plugin version Fixes #333
Not really, except my lack of available time to actually get to it. Thanks for your patience and understanding. I have just merged @obmsch's PR #333, and will also close this one as it was basically the same fix, and I don't see any reason to leave it open. Considering that reordering the order in which the buffers are read is only a workaround / partial fix, the original issue #259 remains open. Maybe one of you SVN guys will find the time to pursue the work done by @bright-tools in #259 (comment) and test his feature branch. |
Changed the descriptorspec for the stderr pipe to 'w' (it was 'a' but this seems only applicable when streaming to a file, not a pipe)
Reversed the order in which the stderr and stdout pipes are read to get around an apparent bug in the proc_open