Skip to content

Commit

Permalink
Merge branch 'release/2.0.2'
Browse files Browse the repository at this point in the history
### Changed

- #10: Improved shared memory cleanup code.
  • Loading branch information
TheLevti committed Feb 2, 2020
2 parents 3e2922b + 4fa674a commit 29109b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.2] - 2020-02-02

### Changed

- #10: Improved shared memory cleanup code.

## [2.0.1] - 2020-02-02

# Fixed
### Fixed

- #10: Properly detach from and cleanup shared memory.

Expand Down Expand Up @@ -59,7 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added progress callbacks to Deferred.
- Added serializable objects for exit and error messages.

[Unreleased]: https://github.com/TheLevti/spork/compare/2.0.1...HEAD
[Unreleased]: https://github.com/TheLevti/spork/compare/2.0.2...HEAD
[2.0.2]: https://github.com/TheLevti/spork/releases/2.0.2
[2.0.1]: https://github.com/TheLevti/spork/releases/2.0.1
[2.0.0]: https://github.com/TheLevti/spork/releases/2.0.0
[1.0.0]: https://github.com/TheLevti/spork/releases/1.0.0
Expand Down
12 changes: 2 additions & 10 deletions src/Spork/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ public function __construct($pid, SharedMemory $shm, $debug = false)
$this->name = '<anonymous>';
}

/**
* Clean up shared memory when not needed any longer.
*
* @return void
*/
public function cleanupSharedMemory(): void
{
$this->shm->cleanup();
}

/**
* Assign a name to the current fork (useful for debugging).
*/
Expand Down Expand Up @@ -92,6 +82,8 @@ public function processWaitStatus($status)
if ($this->isExited()) {
$this->receive();

$this->shm->cleanup();

$this->isSuccessful() ? $this->resolve() : $this->reject();

if ($this->debug && (!$this->isSuccessful() || $this->getError())) {
Expand Down
9 changes: 5 additions & 4 deletions src/Spork/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ public function __construct(
$this->forks = [];
}

/**
* Does cleanup when the process manager is destroyed.
*
* @return void
*/
public function __destruct()
{
if (!$this->zombieOkay) {
$this->wait();
}

foreach ($this->forks as $fork) {
$fork->cleanupSharedMemory();
}
}

public function getEventDispatcher()
Expand Down

0 comments on commit 29109b7

Please sign in to comment.