Skip to content

Commit 1ea6c5a

Browse files
committed
update for libuv 1.0.0rc2, updated tests for api changes
1 parent 84d7e09 commit 1ea6c5a

File tree

11 files changed

+68
-23
lines changed

11 files changed

+68
-23
lines changed

php_uv.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -875,14 +875,14 @@ static void php_uv_fs_common(uv_fs_type fs_type, INTERNAL_FUNCTION_PARAMETERS)
875875
PHP_UV_FS_SETUP_AND_EXECUTE(open, path, flag, mode);
876876
break;
877877
}
878-
case UV_FS_READDIR:
878+
case UV_FS_SCANDIR:
879879
{
880880
char *path;
881881
int path_len = 0;
882882
long flags;
883883

884884
PHP_UV_FS_PARSE_PARAMETERS("zslf!", &zloop, &path, &path_len, &flags, &fci, &fcc);
885-
PHP_UV_FS_SETUP_AND_EXECUTE(readdir, path, flags);
885+
PHP_UV_FS_SETUP_AND_EXECUTE(scandir, path, flags);
886886
break;
887887
}
888888
case UV_FS_LSTAT:
@@ -1798,7 +1798,7 @@ static void php_uv_fs_cb(uv_fs_t* req)
17981798
argc = 1;
17991799
break;
18001800
}
1801-
case UV_FS_READDIR:
1801+
case UV_FS_SCANDIR:
18021802
{
18031803
zval *dirent;
18041804
int nnames, i = 0;
@@ -2133,7 +2133,7 @@ static void php_uv_idle_cb(uv_timer_t *handle)
21332133

21342134
params[0] = &idle;
21352135

2136-
php_uv_do_callback2(&retval_ptr, uv, params, 2, PHP_UV_IDLE_CB TSRMLS_CC);
2136+
php_uv_do_callback2(&retval_ptr, uv, params, 1, PHP_UV_IDLE_CB TSRMLS_CC);
21372137

21382138

21392139
if (retval_ptr != NULL) {
@@ -4839,6 +4839,7 @@ PHP_FUNCTION(uv_pipe_pending_count)
48394839
{
48404840
php_uv_t *uv;
48414841
zval *handle;
4842+
int count;
48424843

48434844
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
48444845
"z",&handle) == FAILURE) {
@@ -4848,7 +4849,8 @@ PHP_FUNCTION(uv_pipe_pending_count)
48484849

48494850
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
48504851

4851-
uv_pipe_pending_count(&uv->uv.pipe);
4852+
count = uv_pipe_pending_count(&uv->uv.pipe);
4853+
RETURN_LONG(count);
48524854
}
48534855
/* }}} */
48544856

@@ -4858,6 +4860,7 @@ PHP_FUNCTION(uv_pipe_pending_type)
48584860
{
48594861
php_uv_t *uv;
48604862
zval *handle;
4863+
uv_handle_type ret;
48614864

48624865
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
48634866
"z",&handle) == FAILURE) {
@@ -4867,7 +4870,8 @@ PHP_FUNCTION(uv_pipe_pending_type)
48674870

48684871
PHP_UV_TYPE_CHECK(uv, IS_UV_PIPE);
48694872

4870-
uv_pipe_pending_type(&uv->uv.pipe);
4873+
ret = uv_pipe_pending_type(&uv->uv.pipe);
4874+
RETURN_LONG(ret);
48714875
}
48724876
/* }}} */
48734877

@@ -5934,7 +5938,15 @@ PHP_FUNCTION(uv_fs_fstat)
59345938
*/
59355939
PHP_FUNCTION(uv_fs_readdir)
59365940
{
5937-
php_uv_fs_common(UV_FS_READDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
5941+
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
5942+
}
5943+
/* }}} */
5944+
5945+
/* {{{ proto uv_fs_scandir(resource $loop, string $path, long $flags, callable $callback)
5946+
* */
5947+
PHP_FUNCTION(uv_fs_scandir)
5948+
{
5949+
php_uv_fs_common(UV_FS_SCANDIR, INTERNAL_FUNCTION_PARAM_PASSTHRU);
59385950
}
59395951
/* }}} */
59405952

tests/100-uv_async.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Check for uv_async
33
--FILE--
44
<?php
55
$loop = uv_default_loop();
6-
$async = uv_async_init($loop, function($async, $status){
6+
$async = uv_async_init($loop, function($async){
77
echo "Hello";
88
uv_close($async);
99
});
@@ -12,4 +12,4 @@ uv_async_send($async);
1212

1313
uv_run();
1414
--EXPECT--
15-
Hello
15+
Hello

tests/100-uv_check.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ uv_idle_start($idle, function($stat) use (&$i, $idle, $loop){
1616
}
1717
});
1818

19-
uv_check_start($check, function($check, $status){
19+
uv_check_start($check, function($check){
2020
echo "Hello";
2121
uv_check_stop($check);
2222
});
2323

2424
uv_run();
2525
--EXPECT--
26-
Hello
26+
Hello

tests/100-uv_prepare.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ Check for uv_prepare
55
$loop = uv_default_loop();
66
$prepare = uv_prepare_init($loop);
77

8-
uv_prepare_start($prepare, function($rsc, $status){
8+
uv_prepare_start($prepare, function($rsc){
99
echo "Hello";
1010
uv_unref($rsc);
1111
});
1212

1313
uv_run();
1414
--EXPECT--
15-
Hello
15+
Hello

tests/100-uv_timer.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ $loop = uv_default_loop();
66
$timer = uv_timer_init();
77

88
$i = 0;
9-
uv_timer_start($timer, 10, 10, function($timer, $stat)
9+
uv_timer_start($timer, 10, 10, function($timer)
1010
use (&$i) {
1111

1212
echo "count: {$i}" . PHP_EOL;
@@ -26,4 +26,4 @@ count: 0
2626
count: 1
2727
count: 2
2828
count: 3
29-
finished
29+
finished

tests/399-fs-stat-regression-no14.phpt

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,39 @@ Check for #14
55
$loop = uv_default_loop();
66
$filename ="does_not_exist.txt";
77
uv_fs_stat($loop, $filename, function ($result, $stat) {
8-
echo $result . PHP_EOL;
8+
if($result < 0) {
9+
echo 'OK' . PHP_EOL;
10+
} else {
11+
echo 'FAILED: uv_fs_stat should have returned a value less than 0' . PHP_EOL;
12+
}
13+
914
if (is_null($stat)) {
1015
echo "NULL" . PHP_EOL;
16+
} else {
17+
echo "FAILED: uv_fs_stat \$stat return value should be NULL" . PHP_EOL;
18+
}
19+
});
20+
21+
$filename = tempnam(sys_get_temp_dir(), 'test-no14');
22+
23+
uv_fs_stat($loop, $filename, function ($result, $stat) {
24+
if($result === 0) {
25+
echo 'OK' . PHP_EOL;
26+
} else {
27+
echo "FAILED: uv_fs_stat should have returned a result of 0" . PHP_EOL;
28+
}
29+
30+
if(!empty($stat)) {
31+
echo 'OK' . PHP_EOL;
32+
} else {
33+
echo 'FAILED: $stat should be an array with values' . PHP_EOL;
1134
}
1235
});
36+
1337
uv_run();
1438

1539
--EXPECT--
16-
-1
17-
NULL
40+
OK
41+
NULL
42+
OK
43+
OK

tests/400-tcp_bind.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ uv_tcp_connect($c, uv_ip4_addr($addrinfo['address'],$addrinfo['port']), function
2929

3030
uv_run();
3131
--EXPECT--
32-
Hello
32+
Hello

tests/800-uv_spawn.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ uv_spawn(uv_default_loop(), "php", array('-r','echo "WORLD";'), $stdio, dirname(
1919

2020
}, $flags);
2121

22-
uv_read2_start($out, function($out, $nread, $buffer, $stat){
22+
uv_read_start($out, function($out, $nread, $buffer) {
2323
echo $buffer;
2424

2525
uv_close($out,function(){});
@@ -28,4 +28,4 @@ uv_read2_start($out, function($out, $nread, $buffer, $stat){
2828
uv_run();
2929

3030
--EXPECT--
31-
HELLO WORLD
31+
HELLO WORLD

tests/999-uv_chdir.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ Check for uv_chdir
44
<?php
55
uv_chdir(); // don't SEGV
66

7-
uv_chdir(dirname(__FILE__));
7+
if(uv_chdir(dirname(__FILE__))) {
8+
echo "OK\n";
9+
} else {
10+
echo "FAILED: expected uv_chdir to return true";
11+
}
12+
813
if (uv_cwd() == dirname(__FILE__)) {
914
echo "OK";
1015
} else {
@@ -15,3 +20,4 @@ if (uv_cwd() == dirname(__FILE__)) {
1520

1621
Warning: uv_chdir() expects exactly 1 parameter, 0 given in %s on line %d
1722
OK
23+
OK

tests/fixtures/poll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hoge

0 commit comments

Comments
 (0)