Skip to content

Commit 122d2de

Browse files
obmschdregad
authored andcommitted
SVN: pipe handling reordering, read STDOUT first
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 <dregad@mantisbt.org> - Original commit message and comment block reworded - Updated changelog - Bump SourceSVN plugin version Fixes #333
1 parent 05852d9 commit 122d2de

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

SourceSVN/SourceSVN.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class SourceSVNPlugin extends MantisSourcePlugin {
1111

12-
const PLUGIN_VERSION = '2.2.0';
12+
const PLUGIN_VERSION = '2.3.0';
1313
const FRAMEWORK_VERSION_REQUIRED = '2.0.0';
1414

1515
/**
@@ -338,12 +338,23 @@ private function svn_run( $p_cmd, $p_repo = null )
338338
plugin_error( self::ERROR_SVN_RUN );
339339
}
340340

341-
# Get output of the process & clean up
342-
$t_stderr = stream_get_contents( $t_pipes[2] );
343-
fclose( $t_pipes[2] );
341+
# Get the output of the process & clean up
342+
# Due to limitations on the buffering of pipes (at least on Windows) and
343+
# possible resulting deadlocks, the order the pipes are read is crucial.
344+
# Processing STDOUT before STDERR will NOT(!) prevent a deadlock if the
345+
# output to STDERR exceeds the pipe's max buffered size.
346+
# As discussed in #261, it is better to handle an unlikely error
347+
# scenario, than to frequently get stuck when processing good commits.
348+
349+
#STDOUT
344350
$t_svn_out = stream_get_contents( $t_pipes[1] );
345351
fclose( $t_pipes[1] );
352+
#STDERR
353+
$t_stderr = stream_get_contents( $t_pipes[2] );
354+
fclose( $t_pipes[2] );
355+
#STDIN
346356
fclose( $t_pipes[0] );
357+
347358
proc_close( $t_svn_proc );
348359

349360
# Error handling

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ specification.
2121

2222
- GitHub: authentication using query parameters is deprecated
2323
[#335](https://github.com/mantisbt-plugins/source-integration/issues/335)
24+
- SVN: Workaround to avoid data import failures due to timeout reading proc_open() buffers
25+
[#333](https://github.com/mantisbt-plugins/source-integration/issues/333)
2426

2527

2628
## [2.3.0] - 2019-09-06

0 commit comments

Comments
 (0)