From 5c68a24348c9caac365db490351fe6a18a3532dc Mon Sep 17 00:00:00 2001 From: Ma Bingyao Date: Sun, 31 Jul 2016 00:23:29 +0800 Subject: [PATCH] Improved Socket Service for PHP 5.3. --- src/Hprose/Socket/Service.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Hprose/Socket/Service.php b/src/Hprose/Socket/Service.php index 8f1e0294..6e8a5f79 100644 --- a/src/Hprose/Socket/Service.php +++ b/src/Hprose/Socket/Service.php @@ -14,7 +14,7 @@ * * * hprose socket Service library for php 5.3+ * * * - * LastModified: Jul 30, 2016 * + * LastModified: Jul 31, 2016 * * Author: Ma Bingyao * * * \**********************************************************/ @@ -172,8 +172,9 @@ private function getOnReceive($server, $socket) { $onSend(pack("NN", $dataLength | 0x80000000, $id) . $data); } }; + $userFatalErrorHandler = &$this->userFatalErrorHandler; return function() - use ($self, $server, $socket, &$bytes, &$headerLength, &$dataLength, &$id, $send) { + use ($self, $server, $socket, &$bytes, &$headerLength, &$dataLength, &$id, &$userFatalErrorHandler, $send) { $data = @fread($socket, $self->readBuffer); if ($data === false) { $self->error($server, $socket, 'Unknown read error'); @@ -204,7 +205,7 @@ private function getOnReceive($server, $socket) { if (($dataLength >= 0) && (($length - $headerLength) >= $dataLength)) { $context = $self->createContext($server, $socket); $data = substr($bytes, $headerLength, $dataLength); - $self->userFatalErrorHandler = function($error) use ($self, $send, $context) { + $userFatalErrorHandler = function($error) use ($self, $send, $context) { $send($self->endError($error, $context)); }; $self->defaultHandle($data, $context)->then(function($data) use ($send) {