Code Monkey home page Code Monkey logo

phpgo's People

Contributors

birdwyx avatar helloworld2050 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phpgo's Issues

PHP-7.2 下编译失败

  • php-7.2
  • gcc 5.4.0
  • ubuntu 16.04
make
/bin/bash /home/htf/workspace/c/phpgo/libtool --mode=compile g++  -I. -I/home/htf/workspace/c/phpgo -DPHP_ATOM_INC -I/home/htf/workspace/c/phpgo/include -I/home/htf/workspace/c/phpgo/main -I/home/htf/workspace/c/phpgo -I/opt/php/php-7.2/include/php -I/opt/php/php-7.2/include/php/main -I/opt/php/php-7.2/include/php/TSRM -I/opt/php/php-7.2/include/php/Zend -I/opt/php/php-7.2/include/php/ext -I/opt/php/php-7.2/include/php/ext/date/lib  -DHAVE_CONFIG_H  -std=c++11 -g -O0   -c /home/htf/workspace/c/phpgo/src/zend_variables_persist.cc -o src/zend_variables_persist.lo 
 g++ -I. -I/home/htf/workspace/c/phpgo -DPHP_ATOM_INC -I/home/htf/workspace/c/phpgo/include -I/home/htf/workspace/c/phpgo/main -I/home/htf/workspace/c/phpgo -I/opt/php/php-7.2/include/php -I/opt/php/php-7.2/include/php/main -I/opt/php/php-7.2/include/php/TSRM -I/opt/php/php-7.2/include/php/Zend -I/opt/php/php-7.2/include/php/ext -I/opt/php/php-7.2/include/php/ext/date/lib -DHAVE_CONFIG_H -std=c++11 -g -O0 -c /home/htf/workspace/c/phpgo/src/zend_variables_persist.cc  -fPIC -DPIC -o src/.libs/zend_variables_persist.o
In file included from /opt/php/php-7.2/include/php/Zend/zend.h:33:0,
                 from /opt/php/php-7.2/include/php/main/php.h:35,
                 from /home/htf/workspace/c/phpgo/src/stdinc.h:8,
                 from /home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:21:
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc: In function ‘void _zval_persistent_copy_ctor_func(zval*, const char*, uint32_t)’:
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:6: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
      ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:110:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:52:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘len’
 #define ZSTR_LEN(zstr)  (zstr)->len
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:20: note: in expansion of macro ‘ZSTR_LEN’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:110:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:122: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                                                                                                                          ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:110:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:6: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
      ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:121:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:52:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘len’
 #define ZSTR_LEN(zstr)  (zstr)->len
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:20: note: in expansion of macro ‘ZSTR_LEN’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:121:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:122: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                                                                                                                          ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:121:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc: In function ‘void _zval_persistent_to_local_copy_ctor_func(zval*, const char*, uint32_t)’:
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:6: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
      ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:234:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:52:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘len’
 #define ZSTR_LEN(zstr)  (zstr)->len
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:20: note: in expansion of macro ‘ZSTR_LEN’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:234:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:122: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                                                                                                                          ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:234:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:6: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
      ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:245:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:52:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘len’
 #define ZSTR_LEN(zstr)  (zstr)->len
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:20: note: in expansion of macro ‘ZSTR_LEN’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:245:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:122: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                                                                                                                          ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:245:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc: In function ‘void _zval_persistent_dtor_func(zval*, const char*, uint32_t)’:
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:6: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
      ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:344:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:52:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘len’
 #define ZSTR_LEN(zstr)  (zstr)->len
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:20: note: in expansion of macro ‘ZSTR_LEN’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                    ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:344:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
/opt/php/php-7.2/include/php/Zend/zend_string.h:51:33: error: ‘zval {aka struct _zval_struct}’ has no member named ‘val’
 #define ZSTR_VAL(zstr)  (zstr)->val
                                 ^
/opt/php/php-7.2/include/php/Zend/zend_API.h:583:122: note: in expansion of macro ‘ZSTR_VAL’
  if (ZSTR_VAL(str)[ZSTR_LEN(str)] != '\0') { zend_error(E_WARNING, "String is not zero-terminated (%s) (source: %s:%d)", ZSTR_VAL(str) ZEND_FILE_LINE_RELAY_CC); }
                                                                                                                          ^
/home/htf/workspace/c/phpgo/src/zend_variables_persist.cc:344:4: note: in expansion of macro ‘CHECK_ZVAL_STRING_REL’
    CHECK_ZVAL_STRING_REL(zvalue);
    ^
Makefile:206: recipe for target 'src/zend_variables_persist.lo' failed
make: *** [src/zend_variables_persist.lo] Error 1

go函数内使用sleep居然是挨个跳出来,不能利用多核吗?

<?php
use \go\Scheduler; //for the Scheduler functions 

go(function(){   //creates a go routine
    sleep(1);
    echo "Hello World!" . PHP_EOL;
});

go(function(){   //creates a go routine
    sleep(1);
    echo "Hello World!2" . PHP_EOL;
});


go(function(){   //creates a go routine
    sleep(1);
    echo "Hello World!3" . PHP_EOL;
});

go(function(){   //creates a go routine
    sleep(1);
    echo "Hello World!4" . PHP_EOL;
});

go(function(){   //creates a go routine
    sleep(1);
    echo "Hello World!5" . PHP_EOL;
});

Scheduler::join();  //execute all go routines

启用 Syscall Hook 调用 PDO 无效

代码

<?php
use \Go\Chan;
use \Go\Scheduler;

go(function () {
	$user='root';
	$pass='root';
	$dsn="mysql:host=127.0.0.1;dbname=test";
	$db = new PDO($dsn, $user, $pass);
	$rs = $db->query("show tables");
	var_dump($rs->fetchall());
});

Scheduler::join();

执行

htf@htf-All-Series:~/workspace/cpp/phpgo$ LD_PRELOAD=liblibgo.so php t.php 

没有任何输出

关闭SysCall Hook 直接使用同步阻塞IOPDO可以正确返回数据。

htf@htf-All-Series:~/workspace/cpp/phpgo$ php t.php 
array(2) {
  [0]=>
  array(2) {
    ["Tables_in_test"]=>
    string(3) "ckl"
    [0]=>
    string(3) "ckl"
  }
  [1]=>
  array(2) {
    ["Tables_in_test"]=>
    string(8) "userinfo"
    [0]=>
    string(8) "userinfo"
  }
}

strace

htf@htf-All-Series:~/workspace/cpp/phpgo$ LD_PRELOAD=liblibgo.so strace php t.php 
execve("/home/htf/bin/php", ["php", "t.php"], [/* 71 vars */]) = 0
brk(NULL)                               = 0x2f8d000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
open("/usr/local/lib/tls/x86_64/liblibgo.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls/x86_64", 0x7fff97863760) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/tls/liblibgo.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/tls", 0x7fff97863760) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/x86_64/liblibgo.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/x86_64", 0x7fff97863760) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/liblibgo.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\373\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=3402616, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fd438555000
mmap(NULL, 2428848, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fd4380e0000

....


socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
fcntl(5, F_GETFL)                       = 0x2 (flags O_RDWR)
fstat(5, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fcntl(5, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
getsockopt(5, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
connect(5, {sa_family=AF_INET, sin_port=htons(3306), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
poll([{fd=5, events=POLLIN|POLLOUT|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
getsockopt(5, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(5, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
poll([{fd=5, events=POLLIN|POLLERR|POLLHUP}], 1, 0) = 1 ([{fd=5, revents=POLLIN}])
epoll_create(10240)                     = 6
rt_sigaction(SIGPIPE, {SIG_IGN, [], SA_RESTORER, 0x7fd4355f24b0}, NULL, 8) = 0
epoll_ctl(6, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=4294967301}}) = 0
rt_sigprocmask(SIG_SETMASK, [], [], 8)  = 0
epoll_wait(6, [{EPOLLIN, {u32=5, u64=4294967301}}], 1024, 0) = 1
epoll_ctl(6, EPOLL_CTL_DEL, 5, 0x7fff97860cc8) = 0
epoll_wait(6, [], 1024, 20)             = 0
epoll_wait(6, [], 1024, 20)             = 0
epoll_wait(6, [], 1024, 20)             = 0
epoll_wait(6, [], 1024, 20)             = 0


  • open("/usr/local/lib/liblibgo.so", O_RDONLY|O_CLOEXEC) = 3 说明正确加载了 libgo.so
  • socket connect 3306 也是对的,但epoll_wait后直接调用EPOLL_CTL_DEL删除了socket

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.