Updated meshagent with deaklock detection.

This commit is contained in:
Ylian Saint-Hilaire 2019-08-05 15:22:00 -07:00
parent c5aa73c355
commit f35a4c96a0
8 changed files with 15 additions and 14 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -170,7 +170,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
try { parent.parent.fs.mkdirSync(parent.parent.recordpath); } catch (e) { } try { parent.parent.fs.mkdirSync(parent.parent.recordpath); } catch (e) { }
var recFilename = 'session' + ((domain.id == '')?'':'-') + domain.id + '-' + Date.now() + '-' + sessionUser.name + '-' + obj.id + '.mcrec' var recFilename = 'session' + ((domain.id == '')?'':'-') + domain.id + '-' + Date.now() + '-' + sessionUser.name + '-' + obj.id + '.mcrec'
var recFullFilename = parent.parent.path.join(parent.parent.recordpath, recFilename); var recFullFilename = parent.parent.path.join(parent.parent.recordpath, recFilename);
console.log('OpenLog'); //console.log('OpenLog');
parent.parent.fs.open(recFullFilename, 'w', function (err, fd) { parent.parent.fs.open(recFullFilename, 'w', function (err, fd) {
relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false }; relayinfo.peer1.ws.logfile = ws.logfile = { fd: fd, lock: false };
ws.send('c'); // Send connect to both peers ws.send('c'); // Send connect to both peers
@ -229,21 +229,22 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
//if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); } //if (typeof data == 'string') { console.log('Relay: ' + data); } else { console.log('Relay:' + data.length + ' byte(s)'); }
try { try {
this._socket.pause(); this._socket.pause();
if ((this.logfile != null) && (this.logfile.lock == false)) { if (this.logfile != null) {
// Write data to log file then perform relay // Write data to log file then perform relay
/*
var xthis = this; var xthis = this;
console.log('Write', data.length, typeof data, data);
this.logfile.lock = true;
try { try {
parent.parent.fs.write(this.logfile.fd, data, function (err, bytesWritten, buffer) { if (typeof data == 'string') {
xthis.logfile.lock = false; // String write
console.log('WriteDone', err, bytesWritten, buffer.length); parent.parent.fs.write(this.logfile.fd, data, function (err, bytesWritten, buffer) {
xthis.peer.send(data, ws.flushSink); xthis.peer.send(data, ws.flushSink);
}); });
} else {
// Binary write
parent.parent.fs.write(this.logfile.fd, data, 0, data.length, function (err, bytesWritten, buffer) {
xthis.peer.send(data, ws.flushSink);
});
}
} catch (ex) { console.log(ex); } } catch (ex) { console.log(ex); }
*/
this.peer.send(data, ws.flushSink);
} else { } else {
// Perform relay // Perform relay
this.peer.send(data, ws.flushSink); this.peer.send(data, ws.flushSink);
@ -275,7 +276,7 @@ module.exports.CreateMeshRelay = function (parent, ws, req, domain, user, cookie
var peer = (relayinfo.peer1 == obj) ? relayinfo.peer2 : relayinfo.peer1; var peer = (relayinfo.peer1 == obj) ? relayinfo.peer2 : relayinfo.peer1;
// Close the recording file // Close the recording file
if (ws.logfile != null) { console.log('CloseLog'); parent.parent.fs.close(ws.logfile.fd); ws.logfile = null; peer.ws.logfile = null; } if (ws.logfile != null) { parent.parent.fs.close(ws.logfile.fd); ws.logfile = null; peer.ws.logfile = null; }
// Disconnect the peer // Disconnect the peer
try { if (peer.relaySessionCounted) { parent.relaySessionCount--; delete peer.relaySessionCounted; } } catch (ex) { console.log(ex); } try { if (peer.relaySessionCounted) { parent.relaySessionCount--; delete peer.relaySessionCounted; } } catch (ex) { console.log(ex); }

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.9-e", "version": "0.3.9-f",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",