Avoid callstack loop by making sure only one geocoder data iterator buffer-flush operation is happening at once

This commit is contained in:
Andrew Pendleton
2016-03-30 01:10:20 -04:00
parent aac15a8f81
commit 3967adcb4a

View File

@@ -625,7 +625,11 @@ MBTiles.prototype.geocoderDataIterator = function(type) {
var doneSentinel = {};
var _this = this;
var sending = false;
var sendIfAvailable = function() {
if (sending) return;
sending = true;
while (nextQueue.length && dataQueue.length) {
var nextCb = nextQueue.shift(), data;
if (dataQueue[0] == doneSentinel) {
@@ -637,6 +641,8 @@ MBTiles.prototype.geocoderDataIterator = function(type) {
nextCb({value: {shard: data.shard, data: zlib.inflateSync(data.data)}, done: false});
}
}
sending = false;
}
var refilling = false;