Increment the pending_msgs counter immediately to avoid race conditions that send more messages

This commit is contained in:
Jason Grout 2015-03-24 22:32:16 +00:00
parent c9f3c8e073
commit c70f687c0e

View File

@ -347,6 +347,7 @@ define(["widgets/js/manager",
// We haven't exceeded the throttle, send the message like // We haven't exceeded the throttle, send the message like
// normal. // normal.
this.send_sync_message(attrs, callbacks); this.send_sync_message(attrs, callbacks);
this.pending_msgs++;
} }
} }
// Since the comm is a one-way communication, assume the message // Since the comm is a one-way communication, assume the message
@ -395,8 +396,11 @@ define(["widgets/js/manager",
} }
} }
that.comm.send({method: 'backbone', sync_data: state, buffer_keys: buffer_keys}, callbacks, {}, buffers); that.comm.send({method: 'backbone', sync_data: state, buffer_keys: buffer_keys}, callbacks, {}, buffers);
that.pending_msgs++; }).catch(utils.reject("Couldn't send widget sync message"), true)
}) .catch(function(error) {
that.pending_msgs--;
return error;
});
}, },
serialize: function(model, attrs) { serialize: function(model, attrs) {