swoole / swoole-src Goto Github PK
View Code? Open in Web Editor NEW🚀 Coroutine-based concurrency library for PHP
Home Page: https://www.swoole.com
License: Apache License 2.0
🚀 Coroutine-based concurrency library for PHP
Home Page: https://www.swoole.com
License: Apache License 2.0
Please upgrade language of website to English 😭
Will be nice to add an option in config.m4 for PHP extension to used shared libswoole instead of bundling it (which is forbidden, in various linux distro, by guidelines).
So, something like :
# the library
cmake .
make
sudo make install
# the php extension
phpize
./configure --with-swoole --with-libswoole ...
make
sudo make install
configuration完毕,make出错
机器环境:
➜ swoole-swoole-1.5.5 clang -v
Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix
错误信息:
/bin/sh /Users/robbin/Downloads/swoole-swoole-1.5.5/libtool --mode=link cc -DPHP_ATOM_INC -I/Users/robbin/Downloads/swoole-swoole-1.5.5/include -I/Users/robbin/Downloads/swoole-swoole-1.5.5/main -I/Users/robbin/Downloads/swoole-swoole-1.5.5 -I/Users/robbin/.phpenv/versions/5.5.1/include/php -I/Users/robbin/.phpenv/versions/5.5.1/include/php/main -I/Users/robbin/.phpenv/versions/5.5.1/include/php/TSRM -I/Users/robbin/.phpenv/versions/5.5.1/include/php/Zend -I/Users/robbin/.phpenv/versions/5.5.1/include/php/ext -I/Users/robbin/.phpenv/versions/5.5.1/include/php/ext/date/lib -I/include -DHAVE_CONFIG_H -g -O2 -o swoole.la -export-dynamic -avoid-version -prefer-pic -module -rpath /Users/robbin/Downloads/swoole-swoole-1.5.5/modules swoole.lo src/core/Base.lo src/core/RingQueue.lo src/core/Chan.lo src/memory/ShareMemory.lo src/memory/MemPool.lo src/factory/Factory.lo src/factory/FactoryThread.lo src/factory/FactoryProcess.lo src/reactor/ReactorBase.lo src/reactor/ReactorSelect.lo src/reactor/ReactorPoll.lo src/reactor/ReactorEpoll.lo src/reactor/ReactorKqueue.lo src/pipe/PipeBase.lo src/pipe/PipeEventfd.lo src/pipe/PipeUnsock.lo src/pipe/PipeMsg.lo src/lock/Semaphore.lo src/lock/Mutex.lo src/lock/RWLock.lo src/lock/FileLock.lo src/network/Server.lo src/network/Client.lo src/network/buffer.lo -lrt
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/swoole.so -bundle .libs/swoole.o src/core/.libs/Base.o src/core/.libs/RingQueue.o src/core/.libs/Chan.o src/memory/.libs/ShareMemory.o src/memory/.libs/MemPool.o src/factory/.libs/Factory.o src/factory/.libs/FactoryThread.o src/factory/.libs/FactoryProcess.o src/reactor/.libs/ReactorBase.o src/reactor/.libs/ReactorSelect.o src/reactor/.libs/ReactorPoll.o src/reactor/.libs/ReactorEpoll.o src/reactor/.libs/ReactorKqueue.o src/pipe/.libs/PipeBase.o src/pipe/.libs/PipeEventfd.o src/pipe/.libs/PipeUnsock.o src/pipe/.libs/PipeMsg.o src/lock/.libs/Semaphore.o src/lock/.libs/Mutex.o src/lock/.libs/RWLock.o src/lock/.libs/FileLock.o src/network/.libs/Server.o src/network/.libs/Client.o src/network/.libs/buffer.o -lrt
ld: library not found for -lrt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [swoole.la] Error 1
使用 swoole 1.7.1-stable 版本.
gdb core result:
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6_4.1)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
[New Thread 21318]
Reading symbols from /lib64/libcrypt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libcrypt.so.1
Reading symbols from /usr/lib64/libedit.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libedit.so.0
Reading symbols from /lib64/libncurses.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib64/libncurses.so.5
Reading symbols from /usr/lib64/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libstdc++.so.6
Reading symbols from /lib64/libz.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libz.so.1
Reading symbols from /lib64/librt.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/librt.so.1
Reading symbols from /lib64/libm.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libm.so.6
Reading symbols from /lib64/libdl.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libnsl.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnsl.so.1
Reading symbols from /usr/lib64/libxml2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libxml2.so.2
Reading symbols from /lib64/libgssapi_krb5.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgssapi_krb5.so.2
Reading symbols from /lib64/libkrb5.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib64/libkrb5.so.3
Reading symbols from /lib64/libk5crypto.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib64/libk5crypto.so.3
Reading symbols from /lib64/libcom_err.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libcom_err.so.2
Reading symbols from /usr/lib64/libssl.so.10...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libssl.so.10
Reading symbols from /usr/lib64/libcrypto.so.10...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libcrypto.so.10
Reading symbols from /lib64/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/libresolv.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libresolv.so.2
Reading symbols from /lib64/libfreebl3.so...(no debugging symbols found)...done.
Loaded symbols for /lib64/libfreebl3.so
Reading symbols from /lib64/libtinfo.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib64/libtinfo.so.5
Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libgcc_s.so.1
Reading symbols from /lib64/libpthread.so.0...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
Loaded symbols for /lib64/libpthread.so.0
Reading symbols from /lib64/libkrb5support.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib64/libkrb5support.so.0
Reading symbols from /lib64/libkeyutils.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libkeyutils.so.1
Reading symbols from /lib64/libselinux.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libselinux.so.1
Reading symbols from /usr/lib64/php/modules/apc.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/apc.so
Reading symbols from /usr/lib64/php/modules/bcmath.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/bcmath.so
Reading symbols from /usr/lib64/php/modules/bz2.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/bz2.so
Reading symbols from /lib64/libbz2.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libbz2.so.1
Reading symbols from /usr/lib64/php/modules/calendar.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/calendar.so
Reading symbols from /usr/lib64/php/modules/ctype.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/ctype.so
Reading symbols from /usr/lib64/php/modules/curl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/curl.so
Reading symbols from /usr/lib64/libcurl.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libcurl.so.4
Reading symbols from /lib64/libidn.so.11...(no debugging symbols found)...done.
Loaded symbols for /lib64/libidn.so.11
Reading symbols from /lib64/libldap-2.4.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/libldap-2.4.so.2
Reading symbols from /usr/lib64/libssl3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libssl3.so
Reading symbols from /usr/lib64/libsmime3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libsmime3.so
Reading symbols from /usr/lib64/libnss3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libnss3.so
Reading symbols from /usr/lib64/libnssutil3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libnssutil3.so
Reading symbols from /lib64/libplds4.so...(no debugging symbols found)...done.
Loaded symbols for /lib64/libplds4.so
Reading symbols from /lib64/libplc4.so...(no debugging symbols found)...done.
Loaded symbols for /lib64/libplc4.so
Reading symbols from /lib64/libnspr4.so...(no debugging symbols found)...done.
Loaded symbols for /lib64/libnspr4.so
Reading symbols from /usr/lib64/libssh2.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libssh2.so.1
Reading symbols from /lib64/liblber-2.4.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib64/liblber-2.4.so.2
Reading symbols from /usr/lib64/libsasl2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libsasl2.so.2
Reading symbols from /usr/lib64/php/modules/exif.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/exif.so
Reading symbols from /usr/lib64/php/modules/fileinfo.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/fileinfo.so
Reading symbols from /usr/lib64/php/modules/ftp.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/ftp.so
Reading symbols from /usr/lib64/php/modules/gd.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/gd.so
Reading symbols from /usr/lib64/libt1.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libt1.so.5
Reading symbols from /usr/lib64/libX11.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libX11.so.6
Reading symbols from /usr/lib64/libXpm.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libXpm.so.4
Reading symbols from /usr/lib64/libpng12.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libpng12.so.0
Reading symbols from /usr/lib64/libjpeg.so.62...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libjpeg.so.62
Reading symbols from /usr/lib64/libfreetype.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libfreetype.so.6
Reading symbols from /usr/lib64/libxcb.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libxcb.so.1
Reading symbols from /usr/lib64/libXau.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libXau.so.6
Reading symbols from /usr/lib64/php/modules/gettext.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/gettext.so
Reading symbols from /usr/lib64/php/modules/gmp.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/gmp.so
Reading symbols from /usr/lib64/libgmp.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libgmp.so.3
Reading symbols from /usr/lib64/php/modules/iconv.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/iconv.so
Reading symbols from /usr/lib64/php/modules/json.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/json.so
Reading symbols from /usr/lib64/php/modules/mbstring.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/mbstring.so
Reading symbols from /usr/lib64/php/modules/mcrypt.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/mcrypt.so
Reading symbols from /usr/lib64/libmcrypt.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libmcrypt.so.4
Reading symbols from /usr/lib64/libltdl.so.7...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libltdl.so.7
Reading symbols from /usr/lib64/php/modules/mysqlnd.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/mysqlnd.so
Reading symbols from /usr/lib64/php/modules/mysqlnd_mysql.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/mysqlnd_mysql.so
Reading symbols from /usr/lib64/php/modules/mysqlnd_mysqli.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/mysqlnd_mysqli.so
Reading symbols from /usr/lib64/php/modules/pdo.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/pdo.so
Reading symbols from /usr/lib64/php/modules/pdo_mysqlnd.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/pdo_mysqlnd.so
Reading symbols from /usr/lib64/php/modules/pdo_sqlite.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/pdo_sqlite.so
Reading symbols from /usr/lib64/libsqlite3.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/libsqlite3.so.0
Reading symbols from /usr/lib64/php/modules/phar.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/phar.so
Reading symbols from /usr/lib64/php/modules/posix.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/posix.so
Reading symbols from /usr/lib64/php/modules/redis.so...done.
Loaded symbols for /usr/lib64/php/modules/redis.so
Reading symbols from /usr/lib64/php/modules/shmop.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/shmop.so
Reading symbols from /usr/lib64/php/modules/simplexml.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/simplexml.so
Reading symbols from /usr/lib64/php/modules/sockets.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/sockets.so
Reading symbols from /usr/lib64/php/modules/swoole.so...done.
Loaded symbols for /usr/lib64/php/modules/swoole.so
Reading symbols from /usr/lib64/php/modules/httpparser.so...done.
Loaded symbols for /usr/lib64/php/modules/httpparser.so
Reading symbols from /usr/lib64/php/modules/sqlite3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/sqlite3.so
Reading symbols from /usr/lib64/php/modules/sysvmsg.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/sysvmsg.so
Reading symbols from /usr/lib64/php/modules/sysvsem.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/sysvsem.so
Reading symbols from /usr/lib64/php/modules/sysvshm.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/sysvshm.so
Reading symbols from /usr/lib64/php/modules/tokenizer.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/tokenizer.so
Reading symbols from /usr/lib64/php/modules/uuid.so...done.
Loaded symbols for /usr/lib64/php/modules/uuid.so
Reading symbols from /lib64/libuuid.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib64/libuuid.so.1
Reading symbols from /usr/lib64/php/modules/xml.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/xml.so
Reading symbols from /usr/lib64/php/modules/zip.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/php/modules/zip.so
Core was generated by `php -c etc/php.ini async_mysql.php'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007fa825d378e9 in zif_swoole_event_add (ht=, return_value=0x7fa830d16df0,
return_value_ptr=<value optimized out>, this_ptr=<value optimized out>,
return_value_used=<value optimized out>) at /opt/swoole-swoole-1.7.1-stable/swoole_client.c:800
800 if (!ZVAL_IS_NULL(cb_write))
Missing separate debuginfos, use: debuginfo-install php54w-cli-5.4.28-1.w6.x86_64
(gdb) bt
#0 0x00007fa825d378e9 in zif_swoole_event_add (ht=, return_value=0x7fa830d16df0,
return_value_ptr=<value optimized out>, this_ptr=<value optimized out>,
return_value_used=<value optimized out>) at /opt/swoole-swoole-1.7.1-stable/swoole_client.c:800
#1 0x00000000005a4159 in dtrace_execute_internal ()
#2 0x000000000062e955 in ?? ()
#3 0x000000000061c4d8 in execute ()
#4 0x00000000005a427e in dtrace_execute ()
#5 0x00000000005b1f70 in zend_execute_scripts ()
#6 0x0000000000554958 in php_execute_script ()
#7 0x000000000065de53 in ?? ()
#8 0x000000000065e618 in ?? ()
#9 0x000000366ca1ed1d in __libc_start_main () from /lib64/libc.so.6
#10 0x0000000000421009 in _start ()
(gdb) f 1
#1 0x00000000005a4159 in dtrace_execute_internal ()
(gdb) f 0
#0 0x00007fa825d378e9 in zif_swoole_event_add (ht=, return_value=0x7fa830d16df0,
return_value_ptr=<value optimized out>, this_ptr=<value optimized out>,
return_value_used=<value optimized out>) at /opt/swoole-swoole-1.7.1-stable/swoole_client.c:800
800 if (!ZVAL_IS_NULL(cb_write))
编译时参数 --enable-swoole-debug --enable-msgqueue --enable-async-mysql --with-swoole
In 1.7.2 version, use the method like "$serv->shutdown();".
It will close master process only, but the manager and worker process still alive.
Here is the terminal output, fyi.
before:
root@john:~# ps aux|grep swoole
root 9005 0.1 0.9 201308 13884 pts/0 Sl+ 16:44 0:00 php-swoole-master-9005
root 9007 0.0 0.2 193112 4304 pts/0 S+ 16:44 0:00 php-swoole-manager
root 9010 0.0 0.3 193428 6096 pts/0 S+ 16:44 0:00 php-swoole-worker-9010
root 9011 0.0 0.3 193428 6096 pts/0 S+ 16:44 0:00 php-swoole-worker-9011
root 9012 0.0 0.4 193372 6180 pts/0 S+ 16:44 0:00 php-swoole-worker-9012
root 9013 0.0 0.4 193372 6180 pts/0 S+ 16:44 0:00 php-swoole-worker-9013
after:
root@john:~# ps aux|grep swoole
root 9007 0.0 0.2 193112 4304 pts/0 S 16:44 0:00 php-swoole-manager
root 9010 0.0 0.4 193428 6444 pts/0 S 16:44 0:00 php-swoole-worker-9010
root 9011 0.0 0.3 193428 6096 pts/0 S 16:44 0:00 php-swoole-worker-9011
root 9012 0.0 0.4 193372 6180 pts/0 S 16:44 0:00 php-swoole-worker-9012
root 9013 0.0 0.4 193372 6180 pts/0 S 16:44 0:00 php-swoole-worker-9013
test
SwooleG.serv->workers is NULL point in worker process.
/usr/local/service/source/php_swoole/swoole.c: 在函数‘zif_swoole_server_create’中:
/usr/local/service/source/php_swoole/swoole.c:205: 错误:expected expression before ‘;’ token
make: *** [swoole.lo] 错误 1
这几天在找websocket来在我的php里弄一个聊天功能,但是说php不支持多线程,我就各种找,刚准备用node.js的时候,看到了swoole,看样子可行,希望能出websocket的example让我这菜鸟学习学习
The --enable-async-mysql don't work with PHP 5.5 (ok with 5.4)
/dev/shm/BUILD/php-pecl-swoole-1.6.7/NTS/swoole.c:376:58: error: 'MYSQLND_NET' has no member named 'stream'
exapmle\server.php中的finish函数有问题.
function my_onFinish(swoole_server $serv, $data)
应该是三个参数,少了个task_id
function my_onFinish(swoole_server $serv, $task_id, $data)
cc -I. -I/Users/rek/git/github/swoole -DPHP_ATOM_INC -I/Users/rek/git/github/swoole/include -I/Users/rek/git/github/swoole/main -I/Users/rek/git/github/swoole -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/include -I/Users/rek/git/github/swoole/include -DHAVE_CONFIG_H -Wall -g -O2 -std=gnu89 -c /Users/rek/git/github/swoole/src/os/sendfile.c -fno-common -DPIC -o src/os/.libs/sendfile.o
/Users/rek/git/github/swoole/src/os/sendfile.c:29:63: error: too many arguments
to function call, expected 6, have 7
ret = sendfile(in_fd, out_fd, *offset, size, 0, &sent_bytes, 0);
~~~~~~~~ ^
/usr/include/sys/socket.h:580:1: note: 'sendfile' declared here
int sendfile(int, int, off_t, off_t *, struct sf_hdtr *, int);
^
1 error generated.
CMake Error: cmake_symlink_library: System Error: Protocol error
make[2]: *** [lib/libswoole.so.1.6.12] Error 1
make[1]: *** [CMakeFiles/swoole_shared.dir/all] Error 2
make: *** [all] Error 2
what's wrong with the make?
hi, I have read the code and have a question,
the main thread use select and only accept new connections,
and added the new file descriptor to the work threads fd-sets( server.c #117).
is this ok ?
the main & worker are running in different thread, how the worker knows a new fd is added & break from its' sub select/poll function?
I use windows, so I cant build the code. thanks for your reply!
function my_onReceive($serv, $fd, $from_id, $data)
{
//echo "Client:Data. fd=$fd|from_id=$from_id|data=$data\n";
swoole_server_send($serv, $fd, $data);
//echo "len=".strlen($data)."\n & data=\n$data\n";
}
<?php
$clients = array();
for($i = 0; $i < 1; $i++){
$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_SYNC); //同步阻塞
$ret = $client->connect('127.0.0.1', 9501, 0.5, 0);
if(!$ret)
{
echo "Over flow. errno=".$client->errCode;
die("\n");
}
$clients[] = $client;
}
sleep(1);
while (1) {
foreach ($clients as $client) {
$buf = "";
for ($i = 0; $i < 8192; $i++) {
$buf .= chr(rand(0, 255));
}
echo "before len=" . strlen($buf) . "\n";
$client->send($buf);
$data = $client->recv(8192, 0);
echo "after len=" . strlen($data) . "\n";
if (strcmp($buf, $data) != 0) {
die("mismatch");
}
}
sleep(1);
}
before len=8192
after len=0
mismatch
On RHEL-5
During build:
/builddir/build/BUILD/php-pecl-swoole-1.7.2/ZTS/src/network/TaskWorker.c:46: warning: implicit declaration of function 'mkostemp'
On PHP startup:
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/swoole.so' - modules/swoole.so: undefined symbol: mkostemp in Unknown on line 0
as title
is done
very need firebird support
src/core/timer.c
SWINLINE time_t swTimer_get_ms()
{
struct timeval now;
if (gettimeofday(&now, NULL) < 0)
{
swWarn("gettimeofday fail.Error: %s[%d]", strerror(errno), errno);
return SW_ERR;
}
return (now.tv_sec * 1000) + (now.tv_usec / 1000);
}
以上的代码在32位LINUX运行时,会导致time_t溢出,返回负数。
Test Code:
$serv = new swoole_server("127.0.0.1", 9501);
$serv->set(array(
'worker_num' => 8,
));
$serv->on('connect', function ($serv, $fd){
echo "Client:Connect.\n";
});
$serv->on('receive', function ($serv, $fd, $from_id, $data) {
$serv->send($fd, 'Swoole: '.$data);
$serv->close($fd);
});
$serv->on('close', function ($serv, $fd) {
echo "Client: Close.\n";
});
$serv->start();
Webbench Test:
$ webbench -c 100 -t 10 "http://192.168.0.15:9501/"
Command line show:
...
Client:Connect.
Client:Connect.
Client: Close.
Client: Close.
Client: Close.
Client: Close.
[2014-01-21 09:45:44] WARN swServer_poll_onReceive_no_buffer: Read from socket[34] fail. Error: Bad file descriptor [9]
Client: Close.
Client:Connect.
[2014-01-21 09:45:44] WARN swServer_poll_onReceive_no_buffer: Read from socket[34] fail. Error: Bad file descriptor [9]
Client: Close.
Client: Close.
[2014-01-21 09:45:44] WARN swReactorEpoll_wait: [Reactor#0] epoll handle fail. fd=34|type=0
[2014-01-21 09:45:44] WARN swServer_poll_onReceive_no_buffer: Read from socket[26] fail. Error: Bad file descriptor [9]
[2014-01-21 09:45:44] WARN swReactorEpoll_wait: [Reactor#0] epoll handle fail. fd=26|type=0
Client: Close.
Client: Close.
[2014-01-21 09:45:44] WARN swServer_poll_onReceive_no_buffer: Read from socket[40] fail. Error: Bad file descriptor [9]
[2014-01-21 09:45:44] WARN swReactorEpoll_wait: [Reactor#0] epoll handle fail. fd=40|type=0
Client: Close.
Client: Close.
Client: Close.
Client: Close.
Client: Close.
Client: Close.
Client: Close.
Client: Close.
[2014-01-21 09:45:44] WARN swReactorEpoll_wait: [Reactor#0] epoll handle fail. fd=40|type=0
Client: Close.
[2014-01-21 09:45:44] WARN swReactorEpoll_del: epoll remove fd[=48] fail. Error: Bad file descriptor[9]
[2014-01-21 09:45:44] WARN swReactorEpoll_del: epoll remove fd[=56] fail. Error: Bad file descriptor[9]
Client: Close.
[2014-01-21 09:45:44] WARN swReactorEpoll_del: epoll remove fd[=56] fail. Error: Bad file descriptor[9]
[2014-01-21 09:45:44] WARN swServer_poll_onReceive_no_buffer: Read from socket[29] fail. Error: Bad file descriptor [9]
[2014-01-21 09:45:44] WARN swReactorEpoll_wait: [Reactor#1] epoll handle fail. fd=29|type=0
Client: Close.
...
Use ZPHP framework Swoole Server
Show php Warning:
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 36 [ip:127.0.0.1:45769]
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 33 [ip:127.0.0.1:45771]
Client 36:close
Client 30:close
Warning: SwooleServer: onClose handler error in /opt/wwwroot/ZPHP/Socket/Adapter/Swoole.php on line 65
Call Stack:
0.0005 630272 1. {main}() /opt/wwwroot/socket/webroot/main.php:0
0.0016 693224 2. ZPHP\ZPHP::run() /opt/wwwroot/socket/webroot/main.php:7
0.0071 789664 3. ZPHP\Server\Adapter\Socket->run() /opt/wwwroot/ZPHP/ZPHP.php:126
0.0322 1026560 4. ZPHP\Socket\Adapter\Swoole->run() /opt/wwwroot/ZPHP/Server/Adapter/Socket.php:24
0.0330 1032304 5. swoole_server_start() /opt/wwwroot/ZPHP/Socket/Adapter/Swoole.php:65
Client 30:[ip:127.0.0.1:45773] Connect
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 30 [ip:127.0.0.1:45773]
Warning: SwooleServer: onConnect handler error in /opt/wwwroot/ZPHP/Socket/Adapter/Swoole.php on line 65
Call Stack:
0.0005 630272 1. {main}() /opt/wwwroot/socket/webroot/main.php:0
0.0016 693224 2. ZPHP\ZPHP::run() /opt/wwwroot/socket/webroot/main.php:7
0.0071 789664 3. ZPHP\Server\Adapter\Socket->run() /opt/wwwroot/ZPHP/ZPHP.php:126
0.0322 1026560 4. ZPHP\Socket\Adapter\Swoole->run() /opt/wwwroot/ZPHP/Server/Adapter/Socket.php:24
0.0330 1032304 5. swoole_server_start() /opt/wwwroot/ZPHP/Socket/Adapter/Swoole.php:65
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 33 [ip:127.0.0.1:45775]
Client 36:[ip:127.0.0.1:45777] Connect
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 36 [ip:127.0.0.1:45777]
Client 30:close
Client 30:[ip:127.0.0.1:45779] Connect
Get data {"a":"message\/message","m":"send","fd":"28","content":"123"} from 30 [ip:127.0.0.1:45779]
Warning: SwooleServer: onClose handler error in /opt/wwwroot/ZPHP/Socket/Adapter/Swoole.php on line 65
Hi,
New version, lot of new build warnings. :(
I've spent lot of time fixing the previous ones, but it seems you don't care, so I give up.
At least, in 1.6.10
swoole.c:1103:3: warning: implicit declaration of function 'zend_exception_error' [-Wimplicit-function-declaration]
Such issue (here probably a missing header) could raise awfull runtime issue.
Please consider using -Wall in your dev env.
You can ever add, in config.m4 (keeping system value)
CFLAGS="$CFLAGS -Wall"
hi, 能否给一个爬虫的例子,比如一个请求触发查询另个一个外部服务,返回这个外部服务返回的数据。
请问这个框架有文档吗? 介绍上说实现了ORM Log Cache MVC等,但是一个介绍怎么样使用的文档都没有,让人怎么使用啊,不好意思,说的是这个项目 swoole_framework forked from matyhtf/swoole_framework
php_swoole.h:81:2: error: #error "Enable async_mysql support, But no mysqli or mysqlnd."
I have already install mysql, and php5-mysqli.
but it still have the problem.
mysql is from Percona 5.6.
How does this Swoole compare to:
ReactPHP
Amp https://github.com/rdlowrey/Amp
what's wrong about the PHP Fatal error: Call to undefined function swoole_get_mysqli_sock() ?
The swoole-1.6.7.tgz is obviously not created correctly.
Please fix the package.xml and use the "pecl package" command to generate the official archive.
It will be nice to also add the "examples" tree.
Thanks.
文档和示例还不够,他人无法深入认识和理解,多弄点文档和示例吧
int swDataBuffer_clear(swDataBuffer *data_buffer, int fd)
{
swDataBuffer_item *item = NULL;
swHashMap_add_int(&data_buffer->map, fd, item);
if (item == NULL)
{
swTrace("buffer item not found\n");
return SW_ERR;
}
....
}
在src/network/buffer.c的 swDataBuffer_clear函数,定义一个item=NULL,然后插入到哈希表,但是这个过程item并没有分配内存,也就是item永远都是null,这个会一直返回SW_ERR.
操作系统环境:MAC OSX 10.9.2
PHP版本:5.4.14
查看源代码:swoole_client.c 833行,if (cli->connected != 1)
再到swoole_client_create_socket函数的调用,没有找到设置成员变量connected=1.
我注释掉if (cli->connected != 1)可以正常连接swoole server.
如标题
Antony Dovgal:
You really shouldn't be using zend_error().
Take a look at PHP sources, zend_error() is used only in Zend Engine itself for true engineerrors, all PHP extensions use php_error_docref() instead, which allows to call custom error handlers, do the logging and other stuff.
发现了一个很致命的问题,就是这个服务,如果在php脚本中出现语法,找不到类等致命错误的时候,服务进程会直接退出,造成服务不可用。
作为服务的话,稳定是必须的。一出错就不提供服务,这肯定不行。请问有没有什么解决方法?
简单说就是虽然出错,但如果不调用错误代码服务不会退出,即使运行错误代码,也能throw 出,但不退出服务进程
现在很多API都要加证书连接,希望能支持ssl的连接
/root/test/swoole-swoole-1.6.11-stable/src/pipe/PipeEventfd.c: In function ‘swPipeEventfd_create’:
/root/test/swoole-swoole-1.6.11-stable/src/pipe/PipeEventfd.c:47: error: ‘EFD_SEMAPHORE’ undeclared (first use in this function)
/root/test/swoole-swoole-1.6.11-stable/src/pipe/PipeEventfd.c:47: error: (Each undeclared identifier is reported only once
/root/test/swoole-swoole-1.6.11-stable/src/pipe/PipeEventfd.c:47: error: for each function it appears in.)
make: *** [src/pipe/PipeEventfd.lo] Error 1
你好,
请问在传输的字符串中插入'\0'字符或者或者其他特殊字符可以吗
我在测试时发现如果传输的字符串中包含'\0'字符就会被截断,后面的内容就不会传输了
比如发送的是:"abcdef\00ABCDEF"
接收到的就只有:"abcdef"
但是利用strlen计算,发送端的长度为13,接收端得到的长度为6
不知道是我的编译环境的问题还是php语言本身的设定就是这样,本人刚学php,好多东西都不懂~
$serv->taskwait("task data", 2); //when timeout no return
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.