首页
下载
文档
问答社区
视频
捐赠
源代码
AI 助理
赞助商
CRMEB
Apipost
腾讯云
微擎
禅道
51Talk
商业产品
Swoole AI 智能文档翻译器
Swoole-Compiler PHP 代码加密器
CRMEB 新零售社交电商系统
登录
注册
全部
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
发表新帖
文档中 swoole 锁的示例程序问题
http://wiki.swoole.com/wiki/page/127.html 通过 strace 运行了一下,好像没有看到 Child 拿到锁啊,求解! strace 结果如下 {{{ ... ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffa4c1ac58) = -1 ENOTTY (Inappropriate ioctl for device) fstat(3, {st_mode=S_IFREG|0664, st_size=398, ...}) = 0 mmap(NULL, 430, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbee2bb9000 munmap(0x7fbee2bb9000, 430) = 0 close(3) = 0 munmap(0x7fbee2bbc000, 4096) = 0 write(1, "[Master]create lock\n", 20[Master]create lock ) = 20 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fbee2ba59d0) = 2141 [Child] Wait Lock rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, 0x7fffa4c1afb0) = 0 write(1, "[Master]release lock\n", 21[Master]release lock ) = 21 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, 0x7fffa4c1afb0) = 0 write(1, "[Master]exit\n", 13[Master]exit ) = 13 munmap(0x7fbedb05f000, 790528) = 0 close(2) = 0 close(1) = 0 munmap(0x7fbee2bba000, 4096) = 0 close(0) = 0 munmap(0x7fbee2bbb000, 4096) = 0 munmap(0x7fbedb321000, 2172504) = 0 munmap(0x7fbedb534000, 2355304) = 0 munmap(0x7fbedb774000, 2368864) = 0 munmap(0x7fbedb9b7000, 2517512) = 0 munmap(0x7fbedbc1e000, 2157104) = 0 munmap(0x7fbedbe2d000, 2272264) = 0 munmap(0x7fbee2a62000, 1052672) = 0 munmap(0x7fbee2b63000, 266240) = 0 munmap(0x7fbee2a13000, 323584) = 0 exit_group(0) = ? }}}
发布于7年前 · 2 次浏览 · 来自
提问
N
Nasser Xu
http://wiki.swoole.com/wiki/page/127.html 通过 strace 运行了一下,好像没有看到 Child 拿到锁啊,求解! strace 结果如下 {{{ ... ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffa4c1ac58) = -1 ENOTTY (Inappropriate ioctl for device) fstat(3, {st_mode=S_IFREG|0664, st_size=398, ...}) = 0 mmap(NULL, 430, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fbee2bb9000 munmap(0x7fbee2bb9000, 430) = 0 close(3) = 0 munmap(0x7fbee2bbc000, 4096) = 0 write(1, "[Master]create lock\n", 20[Master]create lock ) = 20 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fbee2ba59d0) = 2141 [Child] Wait Lock rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, 0x7fffa4c1afb0) = 0 write(1, "[Master]release lock\n", 21[Master]release lock ) = 21 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0 rt_sigaction(SIGCHLD, NULL, {SIG_DFL, [], 0}, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 nanosleep({1, 0}, 0x7fffa4c1afb0) = 0 write(1, "[Master]exit\n", 13[Master]exit ) = 13 munmap(0x7fbedb05f000, 790528) = 0 close(2) = 0 close(1) = 0 munmap(0x7fbee2bba000, 4096) = 0 close(0) = 0 munmap(0x7fbee2bbb000, 4096) = 0 munmap(0x7fbedb321000, 2172504) = 0 munmap(0x7fbedb534000, 2355304) = 0 munmap(0x7fbedb774000, 2368864) = 0 munmap(0x7fbedb9b7000, 2517512) = 0 munmap(0x7fbedbc1e000, 2157104) = 0 munmap(0x7fbedbe2d000, 2272264) = 0 munmap(0x7fbee2a62000, 1052672) = 0 munmap(0x7fbee2b63000, 266240) = 0 munmap(0x7fbee2a13000, 323584) = 0 exit_group(0) = ? }}}
赞
0
分享
收藏
提问
分享
讨论
建议
公告
开发框架
CodeGalaxy
评论
2017-01-12
第
第三方
示例程序如下: {{{ $lock = new swoole_lock(SWOOLE_MUTEX); echo "[Master]create lock\n"; $lock->lock(); if(pcntl_fork() > 0) { sleep(1); $lock->unlock(); } else { echo "[Child] Wait Lock\n"; $lock->
赞
0
回复
微信公众号
热门内容
暂无回复的问答
- CodeGalaxy K3s 轻量集群节点之间如何实现负载均衡
- 关于openssl CURL WARNING swSSL_connect: SSL_connect(fd=69) failed. Error: error:141A318A:SSL routines:tls_process_ske_dhe:dh key too small[1|394]
- 多个模型如何进行事务异常回退?
- websocket开启wss报错
- 协程tcp服务器如何使用多进程?recv()方法接收信息,打印出来的pid一直是同一个。没用使用到多进程啊。