Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: zlib: revert concatenated-stream changes #240

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions lib/zlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,21 +582,14 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
self._buffer = new Buffer(self._chunkSize);
}

if (availOutAfter === 0 || availInAfter > 0) {
if (availOutAfter === 0) {
// Not actually done. Need to reprocess.
// Also, update the availInBefore to the availInAfter value,
// so that if we have to hit it a third (fourth, etc.) time,
// it'll have the correct byte counts.
inOff += (availInBefore - availInAfter);
availInBefore = availInAfter;

if (availOutAfter !== 0) {
// There is still some data available for reading.
// This is usually a concatenated stream, so, reset and restart.
self.reset();
self._offset = 0;
}

if (!async)
return true;

Expand Down
31 changes: 7 additions & 24 deletions src/node_zlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ enum node_zlib_mode {
UNZIP
};

enum node_zlib_error {
kNoError,
kFailed,
kWritePending
};

void InitZlib(v8::Handle<v8::Object> target);

Expand Down Expand Up @@ -208,7 +203,7 @@ class ZCtx : public AsyncWrap {
if (!async) {
// sync version
Process(work_req);
if (CheckError(ctx) == kNoError)
if (CheckError(ctx))
AfterSync(ctx, args);
return;
}
Expand Down Expand Up @@ -292,7 +287,7 @@ class ZCtx : public AsyncWrap {
}


static node_zlib_error CheckError(ZCtx* ctx) {
static bool CheckError(ZCtx* ctx) {
// Acceptable error states depend on the type of zlib stream.
switch (ctx->err_) {
case Z_OK:
Expand All @@ -305,18 +300,14 @@ class ZCtx : public AsyncWrap {
ZCtx::Error(ctx, "Missing dictionary");
else
ZCtx::Error(ctx, "Bad dictionary");
return kFailed;
return false;
default:
// something else.
if (ctx->strm_.total_out == 0) {
ZCtx::Error(ctx, "Zlib error");
return kFailed;
} else {
return kWritePending;
}
ZCtx::Error(ctx, "Zlib error");
return false;
}

return kNoError;
return true;
}


Expand All @@ -330,8 +321,7 @@ class ZCtx : public AsyncWrap {
HandleScope handle_scope(env->isolate());
Context::Scope context_scope(env->context());

node_zlib_error error = CheckError(ctx);
if (error == kFailed)
if (!CheckError(ctx))
return;

Local<Integer> avail_out = Integer::New(env->isolate(),
Expand All @@ -345,11 +335,6 @@ class ZCtx : public AsyncWrap {
Local<Value> args[2] = { avail_in, avail_out };
ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args);

if (error == kWritePending) {
ZCtx::Error(ctx, "Zlib error");
return;
}

ctx->Unref();
if (ctx->pending_close_)
ctx->Close();
Expand Down Expand Up @@ -554,12 +539,10 @@ class ZCtx : public AsyncWrap {
switch (ctx->mode_) {
case DEFLATE:
case DEFLATERAW:
case GZIP:
ctx->err_ = deflateReset(&ctx->strm_);
break;
case INFLATE:
case INFLATERAW:
case GUNZIP:
ctx->err_ = inflateReset(&ctx->strm_);
break;
default:
Expand Down
83 changes: 0 additions & 83 deletions test/parallel/test-zlib-from-multiple-gzip-with-garbage.js

This file was deleted.

74 changes: 0 additions & 74 deletions test/parallel/test-zlib-from-multiple-gzip.js

This file was deleted.

93 changes: 0 additions & 93 deletions test/parallel/test-zlib-from-multiple-huge-gzip.js

This file was deleted.