Permalink
Browse files

refactor

  • Loading branch information...
1 parent e2bf575 commit 38afbf5b084ab7c9e1a177d4d9044579b9cb9fe7 @tasogarepg committed Aug 25, 2012
Showing with 6 additions and 9 deletions.
  1. +6 −9 lib/node-block.js
View
@@ -55,11 +55,10 @@ BlockInfo.prototype.next = function(err, stepIndex) {
try {
step.run();
} catch (e) {
- step.end(e);
- return;
+ return step.end(e);
}
step.nextLock = false;
- if (step.asyncCount <= 0 && step.endCount == 0) {
+ if (step.asyncCount <= 0 && !step.endFlg) {
this.next(step.errBaton, step.stepIndex+1);
}
};
@@ -81,7 +80,7 @@ function StepInfo(block, stepIndex, func) {
this.block = block;
this.stepIndex = stepIndex;
this.asyncCount = 0;
- this.endCount = 0;
+ this.endFlg = false;
this.isDone = false;
this.nextLock = false;
this.errBaton = null;
@@ -94,7 +93,8 @@ StepInfo.prototype.run = function() {
};
StepInfo.prototype.end = function(err) {
- if (this.endCount++ === 0) {
+ if (!this.endFlg) {
+ this.endFlg = true;
this.block.end(err);
}
};
@@ -105,10 +105,7 @@ StepInfo.prototype.async = function(dataName) {
return function(err) {
var step = that.step;
var block = step.block;
- if (err) {
- step.end(err);
- return;
- }
+ if (err) return step.end(err);
if (that.dataName) {
var result = Array.prototype.slice.call(arguments, 1);
if (result.length === 0) {

0 comments on commit 38afbf5

Please sign in to comment.