}
sub DEMOLISH {
- my ($self, $gd) = @_;
- return if $gd;
- if (my $l = $self->listener) {
- $l->get_loop->remove($l);
- unlink($self->socket_location);
- }
+ my ($self, $in_global_destruction) = @_;
+
+ return unless $self->state eq 'running';
+
+ unlink($self->socket_location);
+
+ return if $in_global_destruction;
+
+ Tak->loop->remove($self->listener);
}
sub setup_connection {