Force disconnection in Predis\Pipeline\StandardExecutor when a Predis\ServerException is thrown to prevent protocol desynchronization between the client and the server.

This commit is contained in:
Daniele Alessandri
2010-05-21 20:31:40 +02:00
parent 5def6bebe3
commit 4c8ecc02e5
+13 -6
View File
@@ -1541,12 +1541,19 @@ class StandardExecutor implements IPipelineExecutor {
foreach ($commands as $command) {
$connection->writeCommand($command);
}
for ($i = 0; $i < $sizeofPipe; $i++) {
$response = $connection->readResponse($commands[$i]);
$values[] = $response instanceof \Iterator
? iterator_to_array($response)
: $response;
unset($commands[$i]);
try {
for ($i = 0; $i < $sizeofPipe; $i++) {
$response = $connection->readResponse($commands[$i]);
$values[] = $response instanceof \Iterator
? iterator_to_array($response)
: $response;
unset($commands[$i]);
}
}
catch (\Predis\ServerException $exception) {
// force disconnection to prevent protocol desynchronization
$connection->disconnect();
throw $exception;
}
return $values;