ZLMediaKit/ZLToolKit

Send function multithreading deadlock issue

Closed this issue · 1 comments

ZLToolKit Library Version: f8471ab
Socket data callback thread, when calling the Send function, other threads also call the Send function: as shown below
17223939688158

ZLToolKit库版本:f8471ab1e6810358646f39e72f9ea035b1458363
Socket数据回调线程中,调用Send函数时,其他线程同时也调用了Send函数:如下图
17223939688158

TRANS_BY_GITHUB_AI_ASSISTANT

Therefore, to ensure single-threaded access to the Socket, please use getPoller() to obtain the corresponding thread, and then switch to this poller thread to access the Socket function.

The multiplexing mode must have a driver thread, which means that your calling thread must also be this driver thread. If it is another thread, it faces the risk of thread safety, and using mutexes is not a good solution.

所以要保证单线程访问Socket 请使用getPoller()获取对应线程,然后切换到这个poller线程去访问Socket函数的方法。
多路复用模式必须有一条驱动线程,这就意味着你的调用线程也得是这个驱动线程,如果是其他线程面临着线程安全的风险,用互斥锁也不是好办法。

TRANS_BY_GITHUB_AI_ASSISTANT