Fix server synch queue drain to work like client one

This commit is contained in:
Naomi Seyfer
2013-05-02 16:38:44 -07:00
parent be8dc47113
commit 91c273fa41

View File

@@ -52,6 +52,11 @@ Meteor._SynchronousQueue = function () {
// that task. We use this to throw an error rather than deadlocking if the
// user calls runTask from within a task on the same fiber.
self._currentTaskFiber = undefined;
// This is true if we're currently draining. While we're draining, a further
// drain is a noop, to prevent infinite loops. "drain" is a heuristic type
// operation, that has a meaning like unto "what a naive person would expect
// when modifying a table from an observe"
self._draining = false;
};
_.extend(Meteor._SynchronousQueue.prototype, {
@@ -91,11 +96,15 @@ _.extend(Meteor._SynchronousQueue.prototype, {
drain: function () {
var self = this;
if (self._draining)
return;
if (!self.safeToRunTask())
return;
self._draining = true;
while (!_.isEmpty(self._taskHandles)) {
self.flush();
}
self._draining = false;
},
_scheduleRun: function () {