修复bug:检测未发生互斥锁死锁的程序时,检测状态一直为检测中

This commit is contained in:
changtao 2023-08-14 13:37:37 +08:00
parent 945bda5f93
commit cfde14890a
2 changed files with 41 additions and 26 deletions

View File

@ -875,7 +875,7 @@ export function activate(context: vscode.ExtensionContext) {
}
//});
}
fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
//fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
}
function remote_clean(form: any){
@ -896,13 +896,15 @@ export function activate(context: vscode.ExtensionContext) {
return
}
// sudo apt install sshpass
fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' });
//fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' });
let inputpasswd = form.pwd;
try{
remote_arch = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'uname -m'`).toString();
//remote_arch = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'uname -m'`).toString();
remote_arch = execSync(`sshpass -p '${inputpasswd}' ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'uname -m'`).toString();
}catch (error: any) {
vscode.window.showErrorMessage(`${error.message}`);
fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
//fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
return;
}
if (remote_arch.includes('aarch64')){
@ -914,7 +916,8 @@ export function activate(context: vscode.ExtensionContext) {
}
try{
cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd scp -o StrictHostKeyChecking=no ${__dirname}/../detect-tools/.user.pwd ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${remote_arch}/detect_deadlock ${form.user}@${form.ip}:./`).toString();
//cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd scp -o StrictHostKeyChecking=no ${__dirname}/../detect-tools/.user.pwd ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${remote_arch}/detect_deadlock ${form.user}@${form.ip}:./`).toString();
cmdout = execSync(`sshpass -p '${inputpasswd}' scp -o StrictHostKeyChecking=no ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${remote_arch}/detect_deadlock ${form.user}@${form.ip}:./`).toString();
}catch (error: any) {
let msg = `${error.message}`;
// console.log(`sshpass -f ${__dirname}/.user.pwd scp -o StrictHostKeyChecking=no ${__dirname}/.user.pwd ${__dirname}/../detect-tools/detect.sh ${__dirname}/../detect-tools/${arch}/detect_deadlock ${form.user}@${form.ip}:/tmp`);
@ -929,13 +932,14 @@ export function activate(context: vscode.ExtensionContext) {
}else {
vscode.window.showErrorMessage(msg);
}
fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
//fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
return;
}
cmdout = '';
try{
cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'bash detect.sh ${form.pid};'`).toString();
//cmdout = execSync(`sshpass -f ${__dirname}/../detect-tools/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'bash detect.sh ${form.pid};'`).toString();
cmdout = execSync(`sshpass -p '${inputpasswd}' ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} 'bash detect.sh ${form.pid};'`).toString();
}catch (error: any) {
let msg = `${error.message}`;
// console.log(`sshpass -f ${__dirname}/.user.pwd ssh -o StrictHostKeyChecking=no ${form.user}@${form.ip} '[ ! -d .deadlock-detect ] && mkdir .deadlock-detect || ls .deadlock-detect > /dev/null; mv /tmp/detect.sh .deadlock-detect; bash .deadlock-detect/detect.sh ${form.pid}'`);
@ -954,7 +958,7 @@ export function activate(context: vscode.ExtensionContext) {
panel.webview.postMessage({
res: form});
}
remote_clean(form);
//remote_clean(form);
return;
}
{
@ -963,17 +967,21 @@ export function activate(context: vscode.ExtensionContext) {
panel.webview.postMessage({
res: form});
}
remote_clean(form);
//remote_clean(form);
}
function java_detect_deadlock(message: any, panel: vscode.WebviewPanel){
let form=message.form;
let cmdout = '';
let inputpasswd = form.pwd;
fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' });
//fs.writeFileSync(`${__dirname}/../detect-tools/.user.pwd`, `${form.pwd}`, { encoding: 'utf8', flag: 'w' });
if(form.CmdType===5){
testPwd1((ok)=>{
if(!ok){
let isright = testPwd(inputpasswd);
//testPwd1((ok)=>{
//if(!ok){
if(!isright){
vscode.window.showErrorMessage("用户密码不匹配");
form.shuaxin = true;
form.success='error';
@ -1004,9 +1012,9 @@ export function activate(context: vscode.ExtensionContext) {
res: form});
return;
}
});
//});
}
fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
//fs.unlinkSync(`${__dirname}/../detect-tools/.user.pwd`);
}

View File

@ -521,22 +521,29 @@ export default {
this.deadgraph(echartsData);
}
}else{//fzw deb
this.loading1 = false;
if(event.data.res.success=='success'){
this.drawDeadGraph(event.data.res.data);
let cirle_deadlock = this.hasDeadlock1(this.thread_info);
/* */
if(cirle_deadlock){
this.$message({
message: "发现互斥锁死锁(严格意义的环路死锁)!",
})
}else{
this.$message({
message: "发现互斥锁死锁(无环路,长时间占用未释放)!",
})
}
if(this.thread_info.length==0){
this.$message({
message: "未发现互斥锁死锁!",
})
}else{
let cirle_deadlock = this.hasDeadlock1(this.thread_info);
if(cirle_deadlock){
this.$message({
message: "发现互斥锁死锁(严格意义的环路死锁)!",
})
}else{
this.$message({
message: "发现互斥锁死锁(无环路,长时间占用未释放)!",
})
}
}
}else{
if(event.data.res.shuaxin == true){
this.loading1 = false;
this.local_thread_data = ''
this.thread_info = []
let echartsData=this.getdeadgraphData(this.thread_info);