【摘要】 Swoole 4.4——支持 CURL 协程化考必过小编为大家整理了关于Swoole 4.4——支持 CURL 协程化的信息,希望可以帮助到大家!
Swoole 4.4——支持 CURL 协程化
标签:hojidpmysqlreadfunction异步默认pbc--
在4.4
之前的版本中,Swoole
一直不支持CURL
协程化,在代码中无法使用curl
。由于curl
使用了pbcurl
库实现,无法直接hook
它的socket
,4.4
版本使用Swoole\Coroutine\Http\Cpent
模拟实现了curl
的API
,并在底层替换了curl_init
等函数的C Handler
。
提示
CURL Hook
的特性尚处于试验阶段,请勿在生产环境中直接使用
暂不支持文件上传、CURL Mpti
仍然需要依赖curl
,请务必安装curl
扩展
支持的特性列表
GET/POST
Header
Cookie
Https
经过验证
Guzzle CURL
完全可以使用
开启
使用Runtime::enableCoroutine
来开启CURL Hook
。
默认不开启
CURL Hook
Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_CURL);
使用
$n = 10;
while($n--) {
go(function () {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.xinhuanet.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
if ($output === FALSE) {
echo "CURL Error:" . curl_error($ch);
}
curl_close($ch);
echo strlen($output) . " bytes\n";
});
}
要将上面两段代码合并到一个文件中执行
运行结果
htf@LAPTOP-0K15EFQI:~/swoole-src/examples$ time php curl.php
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
177173 bytes
real 0m0.534s
user 0m0.031s
sys 0m0.297s
可以看到整个程序是并行的,进程没有任何阻塞。
strace 跟踪
使用strace
跟踪发现,所有系统调用均变成epoll
+socket
的异步非阻塞调用了。
epoll_create(512) = 3
mmap(NULL, 258048, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc038a50000
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc028910000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 4
fcntl(4, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0
pipe([5, 6]) = 0
fcntl(5, F_GETFL) = 0 (flags O_RDONLY)
fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl(6, F_GETFL) = 0x1 (flags O_WRONLY)
fcntl(6, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN, {u32=5, u64=34359738373}}) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fc028100000
mprotect(0x7fc028101000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fc0288ffb70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fc0289009d0, tls=0x7fc028900700, child_tidptr=0x7fc0289009d0) = 55
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fc0237f0000
mprotect(0x7fc0237f1000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fc023fefb70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fc023ff09d0, tls=0x7fc023ff0700, child_tidptr=0x7fc023ff09d0) = 56
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fc022fe0000
mprotect(0x7fc022fe1000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fc0237dfb70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fc0237e09d0, tls=0x7fc0237e0700, child_tidptr=0x7fc0237e09d0) = 57
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7fc0227d0000
mprotect(0x7fc0227d1000, 8388608, PROT_READ|PROT_WRITE) = 0
clone(child_stack=0x7fc022fcfb70, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fc022fd09d0, tls=0x7fc022fd0700, child_tidptr=0x7fc022fd09d0) = 58
futex(0x7fffd9e01ce0, FUTEX_WAKE_PRIVATE, 1) = 1
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=513190000}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=513408000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc0225c0000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 8
fcntl(8, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(8, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(8, SOL_TCP, TCP_NODELAY, [1], 4) = 0
futex(0x7fffd9e01ce0, FUTEX_WAKE_PRIVATE, 1) = 1
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=514359000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc0223b0000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 10
fcntl(10, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(10, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(10, SOL_TCP, TCP_NODELAY, [1], 4) = 0
futex(0x7fffd9e01ce0, FUTEX_WAKE_PRIVATE, 1) = 1
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=515961000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc0221a0000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 9
fcntl(9, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(9, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(9, SOL_TCP, TCP_NODELAY, [1], 4) = 0
futex(0x7fffd9e01ce4, FUTEX_WAKE_PRIVATE, 1) = 1
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=517822000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021f90000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 7
fcntl(7, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(7, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(7, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=520138000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021b60000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 11
fcntl(11, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(11, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(11, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=521400000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021950000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 12
fcntl(12, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(12, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(12, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=523446000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021530000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 17
fcntl(17, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(17, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(17, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=524631000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021320000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 18
fcntl(18, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(18, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(18, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=525903000}) = 0
mmap(NULL, 2101248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fc021110000
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_IP) = 19
fcntl(19, F_GETFL) = 0x80002 (flags O_RDWR|O_CLOEXEC)
fcntl(19, F_SETFL, O_RDWR|O_NONBLOCK|O_CLOEXEC) = 0
setsockopt(19, SOL_TCP, TCP_NODELAY, [1], 4) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=527295000}) = 0
epoll_wait(3, [{EPOLLIN, {u32=5, u64=34359738373}}], 4096, 1000) = 1
read(5, "0T\340\331\377\177\0\0", 1024) = 8
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(8, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=636297000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLOUT, {u32=8, u64=38654705672}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=638815000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
brk(0x7fffd9e19000) = 0x7fffd9e19000
epoll_wait(3, [{EPOLLIN, {u32=5, u64=34359738373}}], 4096, 875) = 1
read(5, "\0u\333\331\377\177\0\0\20g\341\331\377\177\0\0\200W\340\331\377\177\0\0", 1024) = 24
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(4, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=643393000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLOUT, {u32=4, u64=38654705668}}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(9, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=647077000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLOUT, {u32=9, u64=38654705673}}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(10, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=648967000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 10, {EPOLLOUT, {u32=10, u64=38654705674}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=649672000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLOUT, {u32=8, u64=38654705672}}], 4096, 870) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 8, NULL) = 0
getsockopt(8, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
brk(0x7fffd9e49000) = 0x7fffd9e49000
sendto(8, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(8, 0x7fffd9e28c70, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=38654705672}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=655130000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLIN, {u32=5, u64=34359738373}}, {EPOLLOUT, {u32=4, u64=38654705668}}, {EPOLLOUT, {u32=9, u64=38654705673}}], 4096, 865) = 3
read(5, "\360l\341\331\377\177\0\0", 1024) = 8
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(7, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=657746000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLOUT, {u32=7, u64=38654705671}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 4, NULL) = 0
getsockopt(4, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(4, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
brk(0x7fffd9e79000) = 0x7fffd9e79000
recvfrom(4, 0x7fffd9e48c90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=4, u64=38654705668}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 9, NULL) = 0
getsockopt(9, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(9, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(9, 0x7fffd9e68cb0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=9, u64=38654705673}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=662268000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLIN, {u32=5, u64=34359738373}}, {EPOLLOUT, {u32=10, u64=38654705674}}, {EPOLLOUT, {u32=7, u64=38654705671}}], 4096, 859) = 3
read(5, "P~\341\331\377\177\0\0\320r\341\331\377\177\0\0px\341\331\377\177\0\0", 1024) = 24
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(17, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=664547000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 17, {EPOLLOUT, {u32=17, u64=38654705681}}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(11, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=665490000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLOUT, {u32=11, u64=38654705675}}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(12, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=667097000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 12, {EPOLLOUT, {u32=12, u64=38654705676}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 10, NULL) = 0
getsockopt(10, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
brk(0x7fffd9ea9000) = 0x7fffd9ea9000
sendto(10, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(10, 0x7fffd9e88cd0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=38654705674}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 7, NULL) = 0
getsockopt(7, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(7, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
brk(0x7fffd9ed9000) = 0x7fffd9ed9000
recvfrom(7, 0x7fffd9ea8cf0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLIN, {u32=7, u64=38654705671}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=670626000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLIN, {u32=5, u64=34359738373}}, {EPOLLOUT, {u32=17, u64=38654705681}}, {EPOLLOUT, {u32=11, u64=38654705675}}], 4096, 855) = 3
read(5, "\20\212\341\331\377\177\0\0000\204\341\331\377\177\0\0", 1024) = 16
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(19, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=672183000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 19, {EPOLLOUT, {u32=19, u64=38654705683}}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
connect(18, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("123.125.76.136")}, 16) = -1 EINPROGRESS (Operation now in progress)
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=672576000}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 18, {EPOLLOUT, {u32=18, u64=38654705682}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 17, NULL) = 0
getsockopt(17, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(17, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(17, 0x7fffd9ec8d10, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 17, {EPOLLIN, {u32=17, u64=38654705681}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 11, NULL) = 0
getsockopt(11, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
brk(0x7fffd9f09000) = 0x7fffd9f09000
sendto(11, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(11, 0x7fffd9ee8d30, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11, u64=38654705675}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=674303000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLOUT, {u32=12, u64=38654705676}}], 4096, 992) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 12, NULL) = 0
getsockopt(12, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(12, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
brk(0x7fffd9f39000) = 0x7fffd9f39000
recvfrom(12, 0x7fffd9f08d50, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 12, {EPOLLIN, {u32=12, u64=38654705676}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=687389000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLOUT, {u32=19, u64=38654705683}}, {EPOLLOUT, {u32=18, u64=38654705682}}], 4096, 984) = 2
epoll_ctl(3, EPOLL_CTL_DEL, 19, NULL) = 0
getsockopt(19, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
sendto(19, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(19, 0x7fffd9f28d70, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 19, {EPOLLIN, {u32=19, u64=38654705683}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 18, NULL) = 0
getsockopt(18, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
brk(0x7fffd9f69000) = 0x7fffd9f69000
sendto(18, "GET / HTTP/1.1\r\nHost: www.xinhua"..., 90, 0, NULL, 0) = 90
recvfrom(18, 0x7fffd9f48d90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 18, {EPOLLIN, {u32=18, u64=38654705682}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=232, tv_nsec=694225000}) = 0
time(NULL) = 1559698600 (2019-06-05T09:36:40+0800)
epoll_wait(3, [{EPOLLIN, {u32=4, u64=38654705668}}], 4096, -1) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 4, NULL) = 0
recvfrom(4, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 4096
recvfrom(4, 0x7fffd9e48c90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=4, u64=38654705668}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=237, tv_nsec=399093000}) = 0
time(NULL) = 1559698604 (2019-06-05T09:36:44+0800)
brk(0x7fffd9f59000) = 0x7fffd9f59000
epoll_wait(3, [{EPOLLIN, {u32=4, u64=38654705668}}], 4096, -1) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 4, NULL) = 0
recvfrom(4, "V{\362b4\236\22\331\350H\357\313\374\314s\372N\3257\324\16\n\257\24H\217y\376\204P\3\206"..., 65536, 0, NULL, NULL) = 8192
recvfrom(4, 0x7fffd9e48c90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=4, u64=38654705668}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=237, tv_nsec=460756000}) = 0
time(NULL) = 1559698604 (2019-06-05T09:36:44+0800)
epoll_wait(3, [{EPOLLIN, {u32=4, u64=38654705668}}], 4096, -1) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 4, NULL) = 0
recvfrom(4, "\374\346{V\311\306\246|0F\276\337\0\370`\22\224\7\253\312\306\200\262~\374\250\20‘\317\233w\r"..., 65536, 0, NULL, NULL) = 8192
recvfrom(4, 0x7fffd9e48c90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN, {u32=4, u64=38654705668}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=237, tv_nsec=465855000}) = 0
time(NULL) = 1559698604 (2019-06-05T09:36:44+0800)
epoll_wait(3, [{EPOLLIN, {u32=4, u64=38654705668}}], 4096, -1) = 1
epoll_ctl(3, EPOLL_CTL_DEL, 4, NULL) = 0
recvfrom(4, "\3442@o\362\340\10\240#\337=J2=\274\337\201\307=3O\324\342\35s7\\\16\7^\"\23"..., 65536, 0, NULL, NULL) = 19559
brk(0x7fffd9f99000) = 0x7fffd9f99000
close(4) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc028910000, 2101248) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=237, tv_nsec=479677000}) = 0
time(NULL) = 1559698604 (2019-06-05T09:36:44+0800)
epoll_wait(3, [{EPOLLIN, {u32=9, u64=38654705673}}, {EPOLLIN, {u32=7, u64=38654705671}}, {EPOLLIN, {u32=17, u64=38654705681}}, {EPOLLIN, {u32=11, u64=38654705675}}], 4096, -1) = 4
epoll_ctl(3, EPOLL_CTL_DEL, 9, NULL) = 0
recvfrom(9, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 4096
recvfrom(9, 0x7fffd9e68cb0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 9, {EPOLLIN, {u32=9, u64=38654705673}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 7, NULL) = 0
recvfrom(7, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 4096
recvfrom(7, "V{\362b4\236\22\331\350H\357\313\374\314s\372N\3257\324\16\n\257\24H\217y\376\204P\3\206"..., 65536, 0, NULL, NULL) = 4096
recvfrom(7, 0x7fffd9ea8cf0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 7, {EPOLLIN, {u32=7, u64=38654705671}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 17, NULL) = 0
recvfrom(17, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 8192
recvfrom(17, 0x7fffd9ec8d10, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 17, {EPOLLIN, {u32=17, u64=38654705681}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 11, NULL) = 0
recvfrom(11, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 8192
recvfrom(11, 0x7fffd9ee8d30, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 11, {EPOLLIN, {u32=11, u64=38654705675}}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=238, tv_nsec=747275000}) = 0
time(NULL) = 1559698606 (2019-06-05T09:36:46+0800)
madvise(0x7fffd9dcd000, 61440, MADV_DONTNEED) = 0
madvise(0x7fffd9e39000, 126976, MADV_DONTNEED) = 0
epoll_wait(3, [{EPOLLIN, {u32=8, u64=38654705672}}, {EPOLLIN, {u32=10, u64=38654705674}}, {EPOLLIN, {u32=12, u64=38654705676}}, {EPOLLIN, {u32=19, u64=38654705683}}, {EPOLLIN, {u32=18, u64=38654705682}}, {EPOLLIN, {u32=9, u64=38654705673}}, {EPOLLIN, {u32=7, u64=38654705671}}, {EPOLLIN, {u32=17, u64=38654705681}}], 4096, -1) = 8
epoll_ctl(3, EPOLL_CTL_DEL, 8, NULL) = 0
recvfrom(8, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 20480
recvfrom(8, 0x7fffd9e28c70, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=38654705672}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 10, NULL) = 0
recvfrom(10, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 12288
recvfrom(10, 0x7fffd9e88cd0, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 10, {EPOLLIN, {u32=10, u64=38654705674}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 12, NULL) = 0
recvfrom(12, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 20480
recvfrom(12, 0x7fffd9f08d50, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 12, {EPOLLIN, {u32=12, u64=38654705676}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 19, NULL) = 0
recvfrom(19, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 20480
recvfrom(19, 0x7fffd9f28d70, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 19, {EPOLLIN, {u32=19, u64=38654705683}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 18, NULL) = 0
recvfrom(18, "HTTP/1.1 200 OK\r\nContent-Type: t"..., 65536, 0, NULL, NULL) = 20480
recvfrom(18, 0x7fffd9f48d90, 65536, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_ADD, 18, {EPOLLIN, {u32=18, u64=38654705682}}) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 9, NULL) = 0
recvfrom(9, "V{\362b4\236\22\331\350H\357\313\374\314s\372N\3257\324\16\n\257\24H\217y\376\204P\3\206"..., 65536, 0, NULL, NULL) = 29504
recvfrom(9, "\23\1_\243‘\240C\301\37649\31\314\255\236\344f\22\305_\357hojll0FS\240\t\254"..., 65536, 0, NULL, NULL) = 6439
close(9) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc0221a0000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 7, NULL) = 0
recvfrom(7, "3\231\3\372\375\"\271e\271cZ\343bb\251\331\314\227\323L\257\224\311\324\335\276(D\323\341\242\31"..., 65536, 0, NULL, NULL) = 31847
close(7) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021f90000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 17, NULL) = 0
recvfrom(17, "3\231\3\372\375\"\271e\271cZ\343bb\251\331\314\227\323L\257\224\311\324\335\276(D\323\341\242\31"..., 65536, 0, NULL, NULL) = 31847
close(17) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021530000, 2101248) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=238, tv_nsec=783851000}) = 0
time(NULL) = 1559698606 (2019-06-05T09:36:46+0800)
epoll_wait(3, [{EPOLLIN, {u32=11, u64=38654705675}}, {EPOLLIN, {u32=8, u64=38654705672}}, {EPOLLIN, {u32=10, u64=38654705674}}, {EPOLLIN, {u32=12, u64=38654705676}}, {EPOLLIN, {u32=19, u64=38654705683}}, {EPOLLIN, {u32=18, u64=38654705682}}], 4096, -1) = 6
epoll_ctl(3, EPOLL_CTL_DEL, 11, NULL) = 0
recvfrom(11, "3\231\3\372\375\"\271e\271cZ\343bb\251\331\314\227\323L\257\224\311\324\335\276(D\323\341\242\31"..., 65536, 0, NULL, NULL) = 31847
close(11) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021b60000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 8, NULL) = 0
recvfrom(8, "\3442@o\362\340\10\240#\337=J2=\274\337\201\307=3O\324\342\35s7\\\16\7^\"\23"..., 65536, 0, NULL, NULL) = 19559
close(8) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc0225c0000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 10, NULL) = 0
recvfrom(10, "\374\346{V\311\306\246|0F\276\337\0\370`\22\224\7\253\312\306\200\262~\374\250\20‘\317\233w\r"..., 65536, 0, NULL, NULL) = 27751
close(10) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc0223b0000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 12, NULL) = 0
recvfrom(12, "\3442@o\362\340\10\240#\337=J2=\274\337\201\307=3O\324\342\35s7\\\16\7^\"\23"..., 65536, 0, NULL, NULL) = 19559
close(12) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021950000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 19, NULL) = 0
recvfrom(19, "\3442@o\362\340\10\240#\337=J2=\274\337\201\307=3O\324\342\35s7\\\16\7^\"\23"..., 65536, 0, NULL, NULL) = 19559
close(19) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021110000, 2101248) = 0
epoll_ctl(3, EPOLL_CTL_DEL, 18, NULL) = 0
recvfrom(18, "\3442@o\362\340\10\240#\337=J2=\274\337\201\307=3O\324\342\35s7\\\16\7^\"\23"..., 65536, 0, NULL, NULL) = 19559
close(18) = 0
write(1, "177115 bytes\n", 13) = 13
munmap(0x7fc021320000, 2101248) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=238, tv_nsec=802835000}) = 0
time(NULL) = 1559698606 (2019-06-05T09:36:46+0800)
futex(0x7fffd9e01ce0, FUTEX_WAKE_PRIVATE, 2147483647) = 4
futex(0x7fffd9e01c90, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fc023ff09d0, FUTEX_WAIT, 56, NULL) = -1 EAGAIN (Resource temporarily unavailable)
epoll_ctl(3, EPOLL_CTL_DEL, 5, NULL) = 0
close(5) = 0
close(6) = 0
close(2) = 0
close(1) = 0
close(0) = 0
munmap(0x7fc028fa0000, 2231560) = 0
munmap(0x7fc028d1f000, 2624568) = 0
close(3) = 0
在4.4的版本,支持用PHP代码写Swoole的扩展来替换掉PHP的类或方法,这样将针大大提升程序的兼容性,像CURL, MongoDb这些也可以做到无缝支持协程了
更多学习内容可以访问【对标大厂】精品PHP架构师教程目录大全,只要你能看完保证薪资上升一个台阶(持续更新)
以上内容希望帮助到大家,很多PHPer在进阶的时候总会遇到一些问题和瓶颈,业务代码写多了没有方向感,不知道该从那里入手去提升,对此我整理了一些资料,包括但不限于:分布式架构、高可扩展、高性能、高并发、服务器性能调优、TP6,laravel,YII2,Redis,Swoole、Swoft、Kafka、Mysql优化、shell脚本、Docker、微服务、Nginx等多个知识点高级进阶干货需要的可以免费分享给大家,需要的可以点击链接领取进阶PHP月薪30k>>>架构师成长路线【视频、面试文档免费获取】
Swoole 4.4——支持 CURL 协程化
标签:hojidpmysqlreadfunction异步默认pbc--
以上就是Swoole 4.4——支持 CURL 协程化的内容,更多资讯请及时关注考必过网站,最新消息小编会第一时间发布,大家考试加油!