碰到个新问题,socket不能放在dict里面

52 views
Skip to first unread message

Chan WingChung

unread,
Sep 7, 2022, 6:08:02 AM9/7/22
to openresty
打个比方:
A客户连接,通过key识别A,A持续连接,再把socket放在dict里面,B通过从dict里面操作这个socket,最后发现是不行的,而且errorlog没有报错,CPU资源100%,就算用pkill nginx也停不下来。

Junlong li

unread,
Sep 14, 2022, 9:03:52 AM9/14/22
to openresty

dict是共享内存,而socket是属于某一个进程的。你把socket放dict,其它进程使用这个socket会引用到空指针,可能导致崩溃的。
你说的socket如果是值文件句柄,那么这个也是进程自己的,不能跨进程共享。

xue

unread,
Sep 21, 2022, 5:10:28 AM9/21/22
to openresty
啥场景 这是

Chan WingChung

unread,
Sep 21, 2022, 2:18:36 PM9/21/22
to openresty
比如我做了个服务,A和B都连上来了,但是他们必须不断请求服务器,才知道A有没有信息发给B,而不是当A要把信息发给B的时候能触发sock:send(A)
Reply all
Reply to author
Forward
0 new messages