Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions trace/trace_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,11 @@ define(function(require){
var buf = []
var total = 0

function flush(){
function flush(end){
if(buf.length){
gz.write(buf.join(''))
gz.flush();
if (end) gz.end();
buf = []
total = 0
}
Expand All @@ -427,18 +429,18 @@ define(function(require){

process.on('exit', function(){
console.log('exit!')
//gz.end()
})


return function(m){
if(!terminated){
// we should buffer atleast a megabyte
var data = '\x1f'+JSON.stringify(m)+'\x17'
buf.push(data)
total += data.length
if(total > 1024*1024) flush()
}
if (!m) flush(true);
else {
// we should buffer atleast a megabyte
var data = '\x1f'+JSON.stringify(m)+'\x17'
buf.push(data)
total += data.length
if(total > 1024*1024) flush()
}
}
}

Expand Down Expand Up @@ -526,6 +528,10 @@ define(function(require){
child.on('message', function(m){
sender(m)
})

child.on('exit', function () {
sender(false);
})
}

function proxyMode(filter, port, bind, proxy, sender){
Expand Down
24 changes: 15 additions & 9 deletions tracegl.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,9 +403,11 @@ define('/trace/trace_server',function(require){
var buf = []
var total = 0

function flush(){
function flush(end){
if(buf.length){
gz.write(buf.join(''))
gz.flush();
if (end) gz.end();
buf = []
total = 0
}
Expand All @@ -428,18 +430,18 @@ define('/trace/trace_server',function(require){

process.on('exit', function(){
console.log('exit!')
//gz.end()
})


return function(m){
if(!terminated){
// we should buffer atleast a megabyte
var data = '\x1f'+JSON.stringify(m)+'\x17'
buf.push(data)
total += data.length
if(total > 1024*1024) flush()
}
if (!m) flush(true);
else {
// we should buffer atleast a megabyte
var data = '\x1f'+JSON.stringify(m)+'\x17'
buf.push(data)
total += data.length
if(total > 1024*1024) flush()
}
}
}

Expand Down Expand Up @@ -527,6 +529,10 @@ define('/trace/trace_server',function(require){
child.on('message', function(m){
sender(m)
})

child.on('exit', function () {
sender(false);
})
}

function proxyMode(filter, port, bind, proxy, sender){
Expand Down