Skip to content

Commit 6f1b8ca

Browse files
committed
Fix socket closing
1 parent fc9b716 commit 6f1b8ca

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ext/sockets/sockets.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,14 @@ PHP_FUNCTION(socket_close)
951951
PHP_STREAM_FREE_KEEP_RSRC | PHP_STREAM_FREE_CLOSE |
952952
(stream->is_persistent?PHP_STREAM_FREE_CLOSE_PERSISTENT:0));
953953
}
954-
ZVAL_UNDEF(&php_socket->zstream);
954+
} else {
955+
if (!IS_INVALID_SOCKET(php_socket)) {
956+
close(php_socket->bsd_socket);
957+
}
955958
}
959+
960+
ZVAL_UNDEF(&php_socket->zstream);
961+
php_socket->bsd_socket = -1;
956962
}
957963
/* }}} */
958964

ext/sockets/tests/socket_export_stream-1.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var_dump($stream);
2020
socket_write($s1, "test message");
2121
socket_close($s1);
2222

23-
//var_dump(stream_get_contents($stream));
23+
var_dump(stream_get_contents($stream));
2424
--EXPECTF--
2525
resource(%d) of type (stream)
2626
string(12) "test message"

0 commit comments

Comments
 (0)