|
@ -154,7 +154,7 @@ Writable.prototype.pipe = function() { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function writeAfterEnd(stream, state, cb) { |
|
|
function writeAfterEnd(stream, cb) { |
|
|
var er = new Error('write after end'); |
|
|
var er = new Error('write after end'); |
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
|
// TODO: defer error events consistently everywhere, not just the cb
|
|
|
stream.emit('error', er); |
|
|
stream.emit('error', er); |
|
@ -204,7 +204,7 @@ Writable.prototype.write = function(chunk, encoding, cb) { |
|
|
cb = nop; |
|
|
cb = nop; |
|
|
|
|
|
|
|
|
if (state.ended) |
|
|
if (state.ended) |
|
|
writeAfterEnd(this, state, cb); |
|
|
writeAfterEnd(this, cb); |
|
|
else if (validChunk(this, state, chunk, cb)) { |
|
|
else if (validChunk(this, state, chunk, cb)) { |
|
|
state.pendingcb++; |
|
|
state.pendingcb++; |
|
|
ret = writeOrBuffer(this, state, chunk, encoding, cb); |
|
|
ret = writeOrBuffer(this, state, chunk, encoding, cb); |
|
@ -329,7 +329,7 @@ function onwrite(stream, er) { |
|
|
onwriteError(stream, state, sync, er, cb); |
|
|
onwriteError(stream, state, sync, er, cb); |
|
|
else { |
|
|
else { |
|
|
// Check if we're actually ready to finish, but don't emit yet
|
|
|
// Check if we're actually ready to finish, but don't emit yet
|
|
|
var finished = needFinish(stream, state); |
|
|
var finished = needFinish(state); |
|
|
|
|
|
|
|
|
if (!finished && |
|
|
if (!finished && |
|
|
!state.corked && |
|
|
!state.corked && |
|
@ -453,7 +453,7 @@ Writable.prototype.end = function(chunk, encoding, cb) { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function needFinish(stream, state) { |
|
|
function needFinish(state) { |
|
|
return (state.ending && |
|
|
return (state.ending && |
|
|
state.length === 0 && |
|
|
state.length === 0 && |
|
|
state.bufferedRequest === null && |
|
|
state.bufferedRequest === null && |
|
@ -469,7 +469,7 @@ function prefinish(stream, state) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function finishMaybe(stream, state) { |
|
|
function finishMaybe(stream, state) { |
|
|
var need = needFinish(stream, state); |
|
|
var need = needFinish(state); |
|
|
if (need) { |
|
|
if (need) { |
|
|
if (state.pendingcb === 0) { |
|
|
if (state.pendingcb === 0) { |
|
|
prefinish(stream, state); |
|
|
prefinish(stream, state); |
|
|