$this->commitMasterChanges( __METHOD__ ); // sanity
}
+ /**
+ * @see ILBFactory::newMainLB()
+ * @param bool $domain
+ * @return LoadBalancer
+ */
+ abstract public function newMainLB( $domain = false );
+
+ /**
+ * @see ILBFactory::getMainLB()
+ * @param bool $domain
+ * @return mixed
+ */
+ abstract public function getMainLB( $domain = false );
+
+ /**
+ * @see ILBFactory::newExternalLB()
+ * @param string $cluster
+ * @param bool $domain
+ * @return LoadBalancer
+ */
+ abstract public function newExternalLB( $cluster, $domain = false );
+
+ /**
+ * @see ILBFactory::getExternalLB()
+ * @param string $cluster
+ * @param bool $domain
+ * @return mixed
+ */
+ abstract public function getExternalLB( $cluster, $domain = false );
+
/**
* Call a method of each tracked load balancer
*
"$fname: transaction round '{$this->trxRoundId}' still running."
);
}
+ /** @noinspection PhpUnusedLocalVariableInspection */
+ $scope = $this->getScopedPHPBehaviorForCommit(); // try to ignore client aborts
// Run pre-commit callbacks and suppress post-commit callbacks, aborting on failure
$this->forEachLBCallMethod( 'finalizeMasterChanges' );
$this->trxRoundId = false;
$this->requestInfo = $info + $this->requestInfo;
}
+ /**
+ * Make PHP ignore user aborts/disconnects until the returned
+ * value leaves scope. This returns null and does nothing in CLI mode.
+ *
+ * @return ScopedCallback|null
+ */
+ final protected function getScopedPHPBehaviorForCommit() {
+ if ( PHP_SAPI != 'cli' ) { // http://bugs.php.net/bug.php?id=47540
+ $old = ignore_user_abort( true ); // avoid half-finished operations
+ return new ScopedCallback( function () use ( $old ) {
+ ignore_user_abort( $old );
+ } );
+ }
+
+ return null;
+ }
+
function __destruct() {
$this->destroy();
}