mirror of
https://github.com/modelscope/FunASR
synced 2025-09-15 14:48:36 +08:00
fix bug of websocket lock blocking
This commit is contained in:
parent
9fa2b2128d
commit
467186eec4
@ -98,8 +98,8 @@ void WebSocketServer::do_decoder(
|
|||||||
std::string wav_format,
|
std::string wav_format,
|
||||||
FUNASR_HANDLE& tpass_online_handle) {
|
FUNASR_HANDLE& tpass_online_handle) {
|
||||||
// lock for each connection
|
// lock for each connection
|
||||||
scoped_lock guard(thread_lock);
|
|
||||||
if(!tpass_online_handle){
|
if(!tpass_online_handle){
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
LOG(INFO) << "tpass_online_handle is free, return";
|
LOG(INFO) << "tpass_online_handle is free, return";
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
return;
|
return;
|
||||||
@ -128,10 +128,12 @@ void WebSocketServer::do_decoder(
|
|||||||
hotwords_embedding, itn);
|
hotwords_embedding, itn);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
return;
|
return;
|
||||||
@ -162,10 +164,12 @@ void WebSocketServer::do_decoder(
|
|||||||
wav_format, (ASR_TYPE)asr_mode_,
|
wav_format, (ASR_TYPE)asr_mode_,
|
||||||
hotwords_embedding, itn);
|
hotwords_embedding, itn);
|
||||||
} else {
|
} else {
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
return;
|
return;
|
||||||
@ -209,6 +213,7 @@ void WebSocketServer::do_decoder(
|
|||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,7 +68,6 @@ void WebSocketServer::do_decoder(const std::vector<char>& buffer,
|
|||||||
int audio_fs,
|
int audio_fs,
|
||||||
std::string wav_format,
|
std::string wav_format,
|
||||||
FUNASR_DEC_HANDLE& decoder_handle) {
|
FUNASR_DEC_HANDLE& decoder_handle) {
|
||||||
scoped_lock guard(thread_lock);
|
|
||||||
try {
|
try {
|
||||||
int num_samples = buffer.size(); // the size of the buf
|
int num_samples = buffer.size(); // the size of the buf
|
||||||
|
|
||||||
@ -130,6 +129,7 @@ void WebSocketServer::do_decoder(const std::vector<char>& buffer,
|
|||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
std::cerr << "Error: " << e.what() << std::endl;
|
std::cerr << "Error: " << e.what() << std::endl;
|
||||||
}
|
}
|
||||||
|
scoped_lock guard(thread_lock);
|
||||||
msg["access_num"]=(int)msg["access_num"]-1;
|
msg["access_num"]=(int)msg["access_num"]-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user