Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit da4af61

Browse files
committed
Merge branch 'develop' of https://github.com/swooletw/laravel-swoole into develop
2 parents 3e4de44 + 7894956 commit da4af61

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/Server/Manager.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function onRequest($swooleRequest, $swooleResponse)
251251
return;
252252
}
253253

254-
// set currnt request to sandbox
254+
// set current request to sandbox
255255
$this->sandbox->setRequest($illuminateRequest);
256256

257257
// enable sandbox
@@ -262,9 +262,6 @@ public function onRequest($swooleRequest, $swooleResponse)
262262
$illuminateResponse = $application->run($illuminateRequest);
263263
$response = Response::make($illuminateResponse, $swooleResponse);
264264
$response->send();
265-
266-
// disable and recycle sandbox resource
267-
$this->sandbox->disable();
268265
} catch (Exception $e) {
269266
try {
270267
$exceptionResponse = $this->app[ExceptionHandler::class]->render($illuminateRequest, $e);
@@ -273,6 +270,9 @@ public function onRequest($swooleRequest, $swooleResponse)
273270
} catch (Exception $e) {
274271
$this->logServerError($e);
275272
}
273+
} finally {
274+
// disable and recycle sandbox resource
275+
$this->sandbox->disable();
276276
}
277277
}
278278

@@ -281,6 +281,7 @@ public function onRequest($swooleRequest, $swooleResponse)
281281
*
282282
* @param \Illuminate\Http\Request $illuminateRequest
283283
* @param \Swoole\Http\Response $swooleResponse
284+
* @return boolean
284285
*/
285286
protected function handleStaticRequest($illuminateRequest, $swooleResponse)
286287
{
@@ -325,7 +326,7 @@ protected function resetOnRequest()
325326
/**
326327
* Set onTask listener.
327328
*/
328-
public function onTask(HttpServer $server, $taskId, $fromId, $data)
329+
public function onTask(HttpServer $server, $taskId, $srcWorkerId, $data)
329330
{
330331
$this->container['events']->fire('swoole.task', func_get_args());
331332

@@ -445,7 +446,10 @@ protected function createPidFile()
445446
*/
446447
protected function removePidFile()
447448
{
448-
unlink($this->getPidFile());
449+
$pidFile = $this->getPidFile();
450+
if (file_exists($pidFile)) {
451+
unlink($pidFile);
452+
}
449453
}
450454

451455
/**

src/Server/Sandbox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ protected function resetSession($application)
213213
protected function resetCookie($application)
214214
{
215215
if (isset($application['cookie'])) {
216-
foreach ($application->make('cookie')->getQueuedCookies() as $key => $value) {
216+
$cookies = $application->make('cookie');
217+
foreach ($cookies->getQueuedCookies() as $key => $value) {
217218
$cookies->unqueue($key);
218219
}
219220
}

src/Table/SwooleTable.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class SwooleTable
1818
*
1919
* @param string $name
2020
* @param \Swoole\Table $table
21+
* @return \SwooleTW\Http\Table\SwooleTable
2122
*/
2223
public function add(string $name, Table $table)
2324
{

0 commit comments

Comments
 (0)