Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased]

### Fixed

- Taking over a socket address in a simulated environment (as it tried to delete a concrete file)

## 4.0.0 - 2026-01-25

### Added
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function streams(): Capabilities\Streams

public function sockets(): Capabilities\Sockets
{
return $this->implementation->sockets();
return $this->implementation->sockets($this->files());
}

public function watch(): Watch
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Capabilities/AmbientAuthority.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function streams(): Streams
}

#[\Override]
public function sockets(): Sockets
public function sockets(Files $files): Sockets
{
return Sockets::of();
return Sockets::of($files);
}

#[\Override]
Expand Down
4 changes: 2 additions & 2 deletions src/Internal/Capabilities/Async.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public function streams(): Streams
}

#[\Override]
public function sockets(): Sockets
public function sockets(Files $files): Sockets
{
return $this->capabilities->sockets();
return $this->capabilities->sockets($files);
}

#[\Override]
Expand Down
2 changes: 1 addition & 1 deletion src/Internal/Capabilities/Implementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ interface Implementation
{
public function files(): Files;
public function streams(): Streams;
public function sockets(): Sockets;
public function sockets(Files $files): Sockets;
public function watch(): Watch;
}
4 changes: 2 additions & 2 deletions src/Internal/Capabilities/Simulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public function streams(): Streams
}

#[\Override]
public function sockets(): Sockets
public function sockets(Files $files): Sockets
{
return $this->capabilities->sockets();
return $this->capabilities->sockets($files);
}

#[\Override]
Expand Down
11 changes: 6 additions & 5 deletions src/Internal/Capabilities/Sockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
*/
final class Sockets
{
private function __construct()
{
private function __construct(
private Files $files,
) {
}

/**
* @internal
*/
public static function of(): self
public static function of(Files $files): self
{
return new self;
return new self($files);
}

public function clients(): Sockets\Clients
Expand All @@ -33,7 +34,7 @@ public function clients(): Sockets\Clients

public function servers(): Sockets\Servers
{
return Sockets\Servers::of();
return Sockets\Servers::of($this->files);
}

/**
Expand Down
21 changes: 12 additions & 9 deletions src/Internal/Capabilities/Sockets/Servers.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Internal\Socket\Server,
Internal\Socket\Server\Internet,
Internal\Socket\Server\Unix,
Internal\Capabilities\Files,
Exception\RuntimeException,
};
use Innmind\IP\IP;
Expand All @@ -21,16 +22,17 @@
*/
final class Servers
{
private function __construct()
{
private function __construct(
private Files $files,
) {
}

/**
* @internal
*/
public static function of(): self
public static function of(Files $files): self
{
return new self;
return new self($files);
}

/**
Expand Down Expand Up @@ -93,10 +95,11 @@ public function takeOver(Address $path): Attempt
{
return $this
->unix($path)
->recover(function() use ($path) {
@\unlink($path->toString());

return $this->unix($path);
});
->recover(
fn() => $this
->files
->remove($path->asPath())
->flatMap(fn() => $this->unix($path)),
);
}
}
6 changes: 6 additions & 0 deletions src/Sockets/Unix/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public static function of(Path $path): self
return new self($path);
}

#[\NoDiscard]
public function asPath(): Path
{
return $this->path;
}

#[\NoDiscard]
public function toString(): string
{
Expand Down
Loading