申请udp端口使用全局互斥锁保护,防止端口重复分配
This commit is contained in:
parent
afc7b019f1
commit
6e445614b4
|
|
@ -386,6 +386,9 @@ static void makeSockPair_l(std::pair<Socket::Ptr, Socket::Ptr> &pair, const stri
|
|||
}
|
||||
|
||||
void makeSockPair(std::pair<Socket::Ptr, Socket::Ptr> &pair, const string &local_ip) {
|
||||
//全局互斥锁保护,防止端口重复分配
|
||||
static recursive_mutex s_mtx;
|
||||
lock_guard<recursive_mutex> lck(s_mtx);
|
||||
int try_count = 0;
|
||||
while (true) {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in New Issue