Current, broken PHP 7 port...

This commit is contained in:
Bob Weinand 2015-01-18 02:58:40 +01:00
parent 605a20a568
commit 4332fe7aa1
26 changed files with 1431 additions and 1718 deletions

2959
php_uv.c

File diff suppressed because it is too large Load Diff

View File

@ -39,9 +39,7 @@
#include "php_network.h" #include "php_network.h"
#include "php_streams.h" #include "php_streams.h"
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION >= 3)
#include "ext/sockets/php_sockets.h" #include "ext/sockets/php_sockets.h"
#endif
#include <Zend/zend.h> #include <Zend/zend.h>
#include <Zend/zend_compile.h> #include <Zend/zend_compile.h>
@ -134,7 +132,7 @@ typedef struct {
#ifdef ZTS #ifdef ZTS
void ***thread_ctx; void ***thread_ctx;
#endif #endif
int resource_id; zend_resource *resource_id;
int type; int type;
uv_os_sock_t sock; uv_os_sock_t sock;
union { union {
@ -167,7 +165,7 @@ typedef struct {
typedef struct { typedef struct {
int is_ipv4; int is_ipv4;
int resource_id; zend_resource *resource_id;
union { union {
struct sockaddr_in ipv4; struct sockaddr_in ipv4;
struct sockaddr_in6 ipv6; struct sockaddr_in6 ipv6;
@ -177,7 +175,7 @@ typedef struct {
typedef struct { typedef struct {
int locked; int locked;
enum php_uv_lock_type type; enum php_uv_lock_type type;
int resource_id; zend_resource *resource_id;
union { union {
uv_rwlock_t rwlock; uv_rwlock_t rwlock;
uv_mutex_t mutex; uv_mutex_t mutex;
@ -186,7 +184,7 @@ typedef struct {
} php_uv_lock_t; } php_uv_lock_t;
typedef struct { typedef struct {
int resource_id; zend_resource *resource_id;
int fd; int fd;
zval *stream; zval *stream;
int flags; int flags;
@ -201,11 +199,7 @@ typedef struct {
#define PHP_UV_STDIO_RESOURCE_NAME "uv_stdio" #define PHP_UV_STDIO_RESOURCE_NAME "uv_stdio"
#if PHP_VERSION_ID>=50399 #define PHP_UV_LIST_INSERT(type, handle) Z_RES_P(zend_list_insert(type, handle))
#define PHP_UV_LIST_INSERT(type, handle) zend_list_insert(type, handle TSRMLS_CC)
#else
#define PHP_UV_LIST_INSERT(type, handle) zend_list_insert(type, handle)
#endif
/* File/directory stat mode constants*/ /* File/directory stat mode constants*/

View File

@ -3,7 +3,7 @@ Check for uv_async
--FILE-- --FILE--
<?php <?php
$loop = uv_default_loop(); $loop = uv_default_loop();
$async = uv_async_init($loop, function($async){ $async = uv_async_init($loop, function($async) {
echo "Hello"; echo "Hello";
uv_close($async); uv_close($async);
}); });
@ -11,5 +11,6 @@ $async = uv_async_init($loop, function($async){
uv_async_send($async); uv_async_send($async);
uv_run(); uv_run();
?>
--EXPECT-- --EXPECT--
Hello Hello

View File

@ -16,7 +16,7 @@ uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){
} }
}); });
uv_check_start($check, function($check){ uv_check_start($check, function($check) {
echo "Hello"; echo "Hello";
uv_check_stop($check); uv_check_stop($check);
}); });

View File

@ -5,7 +5,7 @@ Check for uv_prepare
$loop = uv_default_loop(); $loop = uv_default_loop();
$prepare = uv_prepare_init($loop); $prepare = uv_prepare_init($loop);
uv_prepare_start($prepare, function($rsc){ uv_prepare_start($prepare, function($rsc) {
echo "Hello"; echo "Hello";
uv_unref($rsc); uv_unref($rsc);
}); });

View File

@ -6,9 +6,7 @@ $loop = uv_default_loop();
$timer = uv_timer_init(); $timer = uv_timer_init();
$i = 0; $i = 0;
uv_timer_start($timer, 10, 10, function($timer) uv_timer_start($timer, 10, 10, function($timer) use (&$i) {
use (&$i) {
echo "count: {$i}" . PHP_EOL; echo "count: {$i}" . PHP_EOL;
$i++; $i++;

View File

@ -2,25 +2,25 @@
Check for ares_getaddrinfo Check for ares_getaddrinfo
--FILE-- --FILE--
<?php <?php
uv_getaddrinfo(uv_default_loop(),function($status,$names){ uv_getaddrinfo(uv_default_loop(), function($status, $names) {
echo "status: " . $status . PHP_EOL; echo "status: " . $status . PHP_EOL;
if (is_array($names)) { if (is_array($names)) {
echo "OK" . PHP_EOL; echo "OK" . PHP_EOL;
} else { } else {
echo "FAILED: 2nd parameter does not array" . PHP_EOL; echo "FAILED: 2nd parameter does not array" . PHP_EOL;
} }
},"php.net", NULL ,array( },"php.net", NULL, array(
"ai_family" => UV::AF_UNSPEC "ai_family" => UV::AF_UNSPEC
)); ));
uv_getaddrinfo(uv_default_loop(),function($status,$names){ uv_getaddrinfo(uv_default_loop(), function($status, $names) {
echo "status: " . $status . PHP_EOL; echo "status: " . $status . PHP_EOL;
if (is_array($names)) { if (is_array($names)) {
echo "OK" . PHP_EOL; echo "OK" . PHP_EOL;
} else { } else {
echo "FAILED: 2nd parameter does not array" . PHP_EOL; echo "FAILED: 2nd parameter does not array" . PHP_EOL;
} }
},"php.net", NULL ,array( },"php.net", NULL, array(
"ai_family" => UV::AF_UNSPEC "ai_family" => UV::AF_UNSPEC
)); ));
@ -29,4 +29,4 @@ uv_run();
status: 0 status: 0
OK OK
status: 0 status: 0
OK OK

View File

@ -4,15 +4,14 @@ Check for fs read and close
<?php <?php
define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data"); define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data");
uv_fs_open(uv_default_loop(),FIXTURE_PATH, UV::O_RDONLY, 0, function($r){ uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($r) {
uv_fs_read(uv_default_loop(),$r, $offset=0, $len=32,function($stream, $nread, $data) { uv_fs_read(uv_default_loop(), $r, $offset = 0, $len = 32, function($stream, $nread, $data) {
if ($nread <= 0) { if ($nread <= 0) {
if ($nread < 0) { if ($nread < 0) {
throw new Exception("read error"); throw new Exception("read error");
} }
uv_fs_close(uv_default_loop(), $stream, function(){ uv_fs_close(uv_default_loop(), $stream, function() { });
});
} else { } else {
echo $data ; echo $data ;
} }
@ -20,15 +19,14 @@ uv_fs_open(uv_default_loop(),FIXTURE_PATH, UV::O_RDONLY, 0, function($r){
}); });
// test offset // test offset
uv_fs_open(uv_default_loop(),FIXTURE_PATH, UV::O_RDONLY, 0, function($r){ uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($r) {
uv_fs_read(uv_default_loop(),$r, $offset=1, $len=32,function($stream, $nread, $data) { uv_fs_read(uv_default_loop(), $r, $offset = 1, $len = 32, function($stream, $nread, $data) {
if ($nread <= 0) { if ($nread <= 0) {
if ($nread < 0) { if ($nread < 0) {
throw new Exception("read error"); throw new Exception("read error");
} }
uv_fs_close(uv_default_loop(), $stream, function(){ uv_fs_close(uv_default_loop(), $stream, function() { });
});
} else { } else {
echo $data; echo $data;
} }

View File

@ -4,7 +4,7 @@ Check for fs mkdir
<?php <?php
define("DIRECTORY_PATH", dirname(__FILE__) . "/fixtures/example_directory"); define("DIRECTORY_PATH", dirname(__FILE__) . "/fixtures/example_directory");
@rmdir(DIRECTORY_PATH); @rmdir(DIRECTORY_PATH);
uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result){ uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result) {
echo $result . PHP_EOL; echo $result . PHP_EOL;
rmdir(DIRECTORY_PATH); rmdir(DIRECTORY_PATH);
@ -12,5 +12,5 @@ uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result){
uv_run(); uv_run();
--EXPECT-- --EXPECTF--
0 Resource id #%d

View File

@ -6,11 +6,11 @@ define("DIRECTORY_PATH", dirname(__FILE__) . "/fixtures/example_directory");
@rmdir(DIRECTORY_PATH); @rmdir(DIRECTORY_PATH);
mkdir(DIRECTORY_PATH, 0755); mkdir(DIRECTORY_PATH, 0755);
uv_fs_rmdir(uv_default_loop(), DIRECTORY_PATH, function($result){ uv_fs_rmdir(uv_default_loop(), DIRECTORY_PATH, function($result) {
echo $result . PHP_EOL; echo $result . PHP_EOL;
}); });
uv_run(); uv_run();
--EXPECT-- --EXPECTF--
0 Resource id #%d

View File

@ -4,12 +4,12 @@ Check for fs event
<?php <?php
define("DIRECTORY_PATH", dirname(__FILE__) . "/fixtures/example_directory"); define("DIRECTORY_PATH", dirname(__FILE__) . "/fixtures/example_directory");
/* /*
$ev = uv_fs_event_init(uv_default_loop(),dirname(DIRECTORY_PATH), function($rsc, $name, $event, $stat) { $ev = uv_fs_event_init(uv_default_loop(), dirname(DIRECTORY_PATH), function($rsc, $name, $event, $stat) {
echo "finished" . PHP_EOL; echo "finished" . PHP_EOL;
uv_close($rsc); uv_close($rsc);
},0); }, 0);
uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result){ uv_fs_mkdir(uv_default_loop(), DIRECTORY_PATH, 0755, function($result) {
@rmdir(DIRECTORY_PATH); @rmdir(DIRECTORY_PATH);
}); });

View File

@ -9,7 +9,7 @@ $poll = uv_fs_poll_init(uv_default_loop());
fclose(fopen(FIXTURE_PATH, "w+")); fclose(fopen(FIXTURE_PATH, "w+"));
$i = 0; $i = 0;
uv_fs_poll_start($poll,function($rsc,$stat,$p,$c) use (&$i){ uv_fs_poll_start($poll,function($rsc,$stat,$p,$c) use (&$i) {
echo "OK"; echo "OK";
if ($i > 3) { if ($i > 3) {
@ -20,7 +20,7 @@ uv_fs_poll_start($poll,function($rsc,$stat,$p,$c) use (&$i){
}, FIXTURE_PATH, 1); }, FIXTURE_PATH, 1);
$timer = uv_timer_init(); $timer = uv_timer_init();
uv_timer_start($timer, 100, 100, function($timer) use (&$i){ uv_timer_start($timer, 100, 100, function($timer) use (&$i) {
$fp = fopen(FIXTURE_PATH, "w+"); $fp = fopen(FIXTURE_PATH, "w+");
fwrite($fp,"hoge"); fwrite($fp,"hoge");
fclose($fp); fclose($fp);
@ -33,4 +33,4 @@ uv_timer_start($timer, 100, 100, function($timer) use (&$i){
uv_run(); uv_run();
--EXPECT-- --EXPECT--
OKOKOKOKOK OKOKOKOKOK

View File

@ -4,12 +4,11 @@ Check for fs_send_file
<?php <?php
define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data"); define("FIXTURE_PATH", dirname(__FILE__) . "/fixtures/hello.data");
uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($read_fd){ uv_fs_open(uv_default_loop(), FIXTURE_PATH, UV::O_RDONLY, 0, function($read_fd) {
$std_err = 1; // phpt doesn't catch stdout as uv_fs_sendfile uses stdout directly. $std_err = STDERR; // phpt doesn't catch stdout as uv_fs_sendfile uses stdout directly.
uv_fs_sendfile(uv_default_loop(),$std_err, $read_fd, 0, 6, function($result){ uv_fs_sendfile(uv_default_loop(), $std_err, $read_fd, 0, 6, function($result) { });
});
}); });
uv_run(); uv_run();
--EXPECT-- --EXPECT--
Hello Hello

View File

@ -6,13 +6,12 @@ $socket = stream_socket_server("tcp://0.0.0.0:9999", $errno, $errstr);
stream_set_blocking($socket, 0); stream_set_blocking($socket, 0);
$poll = uv_poll_init(uv_default_loop(), $socket); $poll = uv_poll_init(uv_default_loop(), $socket);
uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket){ uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket) {
$conn = stream_socket_accept($socket); $conn = stream_socket_accept($socket);
uv_poll_stop($poll); uv_poll_stop($poll);
$pp = uv_poll_init(uv_default_loop(), $conn); $pp = uv_poll_init(uv_default_loop(), $conn);
uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn) use (&$pp){ uv_poll_start($pp, UV::WRITABLE, function($poll, $stat, $ev, $conn) use (&$pp) {
uv_poll_stop($poll); uv_poll_stop($poll);
uv_fs_write(uv_default_loop(), $conn, "OK", -1, function($conn, $nwrite){ uv_fs_write(uv_default_loop(), $conn, "OK", -1, function($conn, $nwrite){
fclose($conn); fclose($conn);
@ -22,15 +21,14 @@ uv_poll_start($poll, UV::READABLE, function($poll, $stat, $ev, $socket){
$address = uv_ip4_addr("0.0.0.0","9999"); $address = uv_ip4_addr("0.0.0.0","9999");
$tcp = uv_tcp_init(); $tcp = uv_tcp_init();
uv_tcp_connect($tcp, $address, function($client, $stat){ uv_tcp_connect($tcp, $address, function($client, $stat) {
$request = <<<EOF $request = <<<EOF
HELO HELO
EOF; EOF;
uv_write($client,$request,function($client, $stat){ uv_write($client, $request, function($client, $stat) {
if ($stat == 0) { if ($stat == 0) {
uv_read_start($client,function($client, $nread, $buffer){ uv_read_start($client, function($client, $nread, $buffer) {
echo "$buffer\n"; echo "$buffer\n";
//var_dump($buffer);
uv_close($client); uv_close($client);
}); });
} else { } else {

View File

@ -4,13 +4,13 @@ Check for tcp bind
<?php <?php
$tcp = uv_tcp_init(); $tcp = uv_tcp_init();
uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',0)); uv_tcp_bind($tcp, uv_ip4_addr('0.0.0.0',0));
uv_listen($tcp,100, function($server){ uv_listen($tcp, 100, function($server){
$client = uv_tcp_init(); $client = uv_tcp_init();
uv_accept($server, $client); uv_accept($server, $client);
uv_read_start($client, function($socket, $nread, $buffer) use ($server){ uv_read_start($client, function($socket, $nread, $buffer) use ($server) {
echo $buffer . PHP_EOL; echo $buffer . PHP_EOL;
uv_close($socket); uv_close($socket);
uv_close($server,function() use ($server){ uv_close($server, function() use ($server) {
uv_unref($server); uv_unref($server);
}); });
}); });
@ -19,10 +19,10 @@ uv_listen($tcp,100, function($server){
$addrinfo = uv_tcp_getsockname($tcp); $addrinfo = uv_tcp_getsockname($tcp);
$c = uv_tcp_init(); $c = uv_tcp_init();
uv_tcp_connect($c, uv_ip4_addr($addrinfo['address'],$addrinfo['port']), function($client, $stat){ uv_tcp_connect($c, uv_ip4_addr($addrinfo['address'],$addrinfo['port']), function($client, $stat) {
if ($stat == 0) { if ($stat == 0) {
uv_write($client,"Hello",function($socket, $stat){ uv_write($client,"Hello",function($socket, $stat) {
uv_close($socket,function(){}); uv_close($socket,function() { });
}); });
} }
}); });

View File

@ -3,14 +3,14 @@ Check for tcp bind
--FILE-- --FILE--
<?php <?php
$tcp = uv_tcp_init(); $tcp = uv_tcp_init();
uv_tcp_bind6($tcp, uv_ip6_addr('::1',0)); uv_tcp_bind6($tcp, uv_ip6_addr('::1', 0));
uv_listen($tcp,100, function($server){ uv_listen($tcp,100, function($server) {
$client = uv_tcp_init(); $client = uv_tcp_init();
uv_accept($server, $client); uv_accept($server, $client);
uv_read_start($client, function($socket, $nread, $buffer) use ($server){ uv_read_start($client, function($socket, $nread, $buffer) use ($server) {
echo $buffer . PHP_EOL; echo $buffer . PHP_EOL;
uv_close($socket); uv_close($socket);
uv_close($server,function() use ($server){ uv_close($server,function() use ($server) {
uv_unref($server); uv_unref($server);
}); });
}); });
@ -19,14 +19,14 @@ uv_listen($tcp,100, function($server){
$addrinfo = uv_tcp_getsockname($tcp); $addrinfo = uv_tcp_getsockname($tcp);
$c = uv_tcp_init(); $c = uv_tcp_init();
uv_tcp_connect6($c, uv_ip6_addr($addrinfo['address'],$addrinfo['port']), function($client, $stat){ uv_tcp_connect6($c, uv_ip6_addr($addrinfo['address'], $addrinfo['port']), function($client, $stat) {
if ($stat == 0) { if ($stat == 0) {
uv_write($client,"Hello",function($socket, $stat){ uv_write($client,"Hello",function($socket, $stat){
uv_close($socket,function(){}); uv_close($socket, function() { });
}); });
} }
}); });
uv_run(); uv_run();
--EXPECT-- --EXPECT--
Hello Hello

View File

@ -3,19 +3,19 @@ Check for udp bind
--FILE-- --FILE--
<?php <?php
$udp = uv_udp_init(); $udp = uv_udp_init();
uv_udp_bind($udp, uv_ip4_addr('0.0.0.0',10000)); uv_udp_bind($udp, uv_ip4_addr('0.0.0.0', 10000));
uv_udp_recv_start($udp,function($stream, $nread, $buffer){ uv_udp_recv_start($udp, function($stream, $nread, $buffer) {
echo "recv: " . $buffer; echo "recv: " . $buffer;
uv_close($stream); uv_close($stream);
}); });
$uv = uv_udp_init(); $uv = uv_udp_init();
uv_udp_send($uv, "Hello", uv_ip4_addr("0.0.0.0",10000),function($uv, $s){ uv_udp_send($uv, "Hello", uv_ip4_addr("0.0.0.0", 10000), function($uv, $s) {
uv_close($uv); uv_close($uv);
}); });
uv_run(); uv_run();
--EXPECT-- --EXPECT--
recv: Hello recv: Hello

View File

@ -5,17 +5,17 @@ Check for udp bind
$udp = uv_udp_init(); $udp = uv_udp_init();
uv_udp_bind6($udp, uv_ip6_addr('::1',10000)); uv_udp_bind6($udp, uv_ip6_addr('::1',10000));
uv_udp_recv_start($udp,function($stream, $nread, $buffer){ uv_udp_recv_start($udp,function($stream, $nread, $buffer) {
echo "recv: " . $buffer; echo "recv: " . $buffer;
uv_close($stream); uv_close($stream);
}); });
$uv = uv_udp_init(); $uv = uv_udp_init();
uv_udp_send6($uv, "Hello", uv_ip6_addr("::1",10000),function($uv, $s){ uv_udp_send6($uv, "Hello", uv_ip6_addr("::1", 10000), function($uv, $s) {
uv_close($uv); uv_close($uv);
}); });
uv_run(); uv_run();
--EXPECT-- --EXPECT--
recv: Hello recv: Hello

View File

@ -5,23 +5,23 @@ Check for pipe bind
define("PIPE_PATH", dirname(__FILE__) . "/pipe_test.sock"); define("PIPE_PATH", dirname(__FILE__) . "/pipe_test.sock");
@unlink(PIPE_PATH); @unlink(PIPE_PATH);
$a = uv_pipe_init(uv_default_loop(), 0); $a = uv_pipe_init(uv_default_loop(), 0);
$ret = uv_pipe_bind($a,PIPE_PATH); $ret = uv_pipe_bind($a, PIPE_PATH);
uv_listen($a, 8192, function($stream){ uv_listen($a, 8192, function($stream) {
$pipe = uv_pipe_init(uv_default_loop(),0); $pipe = uv_pipe_init(uv_default_loop(), 0);
uv_accept($stream,$pipe); uv_accept($stream, $pipe);
uv_read_start($pipe,function($pipe, $nread, $buffer) use ($stream){ uv_read_start($pipe,function($pipe, $nread, $buffer) use ($stream) {
echo $buffer; echo $buffer;
uv_read_stop($pipe); uv_read_stop($pipe);
uv_close($stream, function(){ uv_close($stream, function() {
@unlink(PIPE_PATH); @unlink(PIPE_PATH);
}); });
}); });
}); });
$b = uv_pipe_init(uv_default_loop(), 0); $b = uv_pipe_init(uv_default_loop(), 0);
uv_pipe_connect($b, PIPE_PATH, function($a,$b){ uv_pipe_connect($b, PIPE_PATH, function($a, $b) {
uv_write($b,"Hello", function($stream,$stat){ uv_write($b, "Hello", function($stream, $stat) {
uv_close($stream); uv_close($stream);
}); });
}); });
@ -29,4 +29,4 @@ uv_pipe_connect($b, PIPE_PATH, function($a,$b){
uv_run(); uv_run();
exit; exit;
--EXPECT-- --EXPECT--
Hello Hello

View File

@ -12,14 +12,14 @@ if (!preg_match("/Thread Safety.+?enabled/", $data)) {
<?php <?php
$loop = uv_default_loop(); $loop = uv_default_loop();
$a = function(){ $a = function() {
echo "[queue]"; echo "[queue]";
}; };
$b = function(){ $b = function() {
echo "[finished]"; echo "[finished]";
}; };
$queue = uv_queue_work($loop, $a, $b); $queue = uv_queue_work($loop, $a, $b);
uv_run(); uv_run();
--EXPECT-- --EXPECT--
[queue][finished] [queue][finished]

View File

@ -13,16 +13,16 @@ $stdio[] = uv_stdio_new($out, UV::CREATE_PIPE | UV::WRITABLE_PIPE);
$flags = 0; $flags = 0;
uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(uv_exepath()), uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(uv_exepath()),
array("key"=>"hello"), array("key" => "hello"),
function($process, $stat, $signal){ function($process, $stat, $signal){
uv_close($process,function(){}); uv_close($process, function() { });
}, $flags); }, $flags);
uv_read_start($out, function($out, $nread, $buffer) { uv_read2_start($out, function($out, $nread, $buffer, $stat){
echo $buffer; echo $buffer;
uv_close($out,function(){}); uv_close($out, function() { });
}); });
uv_run(); uv_run();

View File

@ -2,7 +2,7 @@
Check for uv_tty Check for uv_tty
--FILE-- --FILE--
<?php <?php
uv_fs_open(uv_default_loop(), "/dev/tty", UV::O_RDONLY, 0, function($r){ uv_fs_open(uv_default_loop(), "/dev/tty", UV::O_RDONLY, 0, function($r) {
$tty = uv_tty_init(uv_default_loop(), $r, 1); $tty = uv_tty_init(uv_default_loop(), $r, 1);
uv_tty_get_winsize($tty, $width, $height); uv_tty_get_winsize($tty, $width, $height);
if ($width >= 0) { if ($width >= 0) {
@ -16,4 +16,4 @@ uv_fs_open(uv_default_loop(), "/dev/tty", UV::O_RDONLY, 0, function($r){
uv_run(); uv_run();
--EXPECT-- --EXPECT--
OK OK
OK OK

View File

@ -4,12 +4,7 @@ Check for uv_chdir
<?php <?php
uv_chdir(); // don't SEGV uv_chdir(); // don't SEGV
if(uv_chdir(dirname(__FILE__))) { uv_chdir(dirname(__FILE__));
echo "OK\n";
} else {
echo "FAILED: expected uv_chdir to return true";
}
if (uv_cwd() == dirname(__FILE__)) { if (uv_cwd() == dirname(__FILE__)) {
echo "OK"; echo "OK";
} else { } else {
@ -20,4 +15,3 @@ if (uv_cwd() == dirname(__FILE__)) {
Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d
OK OK
OK

View File

@ -4,6 +4,6 @@ Check for uv_exepath
<?php <?php
$path = uv_exepath(); $path = uv_exepath();
echo (int)preg_match("/php/",$path,$match); echo (int)preg_match("/php/", $path, $match);
--EXPECT-- --EXPECT--
1 1

View File

@ -6,7 +6,7 @@ Check for uv_http_parser
<?php <?php
$parser = uv_http_parser_init(); $parser = uv_http_parser_init();
$result = array(); $result = array();
if(uv_http_parser_execute($parser,"GET /img/http-parser.png?key=value#frag HTTP/1.1 if (uv_http_parser_execute($parser, "GET /img/http-parser.png?key=value#frag HTTP/1.1
Host: chobie.net Host: chobie.net
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: image/png,image/*;q=0.8,*/*;q=0.5 Accept: image/png,image/*;q=0.8,*/*;q=0.5
@ -17,7 +17,7 @@ Referer: http://chobie.net/
Cookie: key=value Cookie: key=value
Cache-Control: max-age=0 Cache-Control: max-age=0
",$result)) { ", $result)) {
echo "# Headers count\n"; echo "# Headers count\n";
echo count($result['HEADERS']) . PHP_EOL; echo count($result['HEADERS']) . PHP_EOL;
echo "# Headers values\n"; echo "# Headers values\n";

2
uv.c
View File

@ -190,7 +190,7 @@ static int php_uv_class_init(TSRMLS_D)
zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC); zend_declare_class_constant_long(uv_class_entry, "HTTP_RESPONSE", sizeof("HTTP_RESPONSE")-1, HTTP_RESPONSE TSRMLS_CC);
#endif #endif
#define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, #name, sizeof(#name)-1, UV_##name TSRMLS_CC); #define PHP_UV_ERRNO_GEN(name, msg_notused) zend_declare_class_constant_long(uv_class_entry, ZEND_STRL(#name), UV_##name);
UV_ERRNO_MAP(PHP_UV_ERRNO_GEN) UV_ERRNO_MAP(PHP_UV_ERRNO_GEN)
#undef PHP_UV_ERRNO_GEN #undef PHP_UV_ERRNO_GEN