mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-23 11:17:09 +08:00
申请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) {
|
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;
|
int try_count = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user