Skip to content

Commit

Permalink
src: zlib: revert concatenated-stream changes
Browse files Browse the repository at this point in the history
Revert "src: fix windows build error" and "zlib: support
concatenated gzip files".

This reverts commits be413ac
and 1183ba4.

Treating subsequent bytes as a concatenated zlib stream
breaks npm install.

Conflicts:
	test/parallel/test-zlib-from-multiple-gzip-with-garbage.js
	test/parallel/test-zlib-from-multiple-gzip.js
	test/parallel/test-zlib-from-multiple-huge-gzip.js

Fixes: nodejs/node-v0.x-archive#8962
PR-URL: #240
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
  • Loading branch information
chrisdickinson committed Jan 9, 2015
1 parent 9f45799 commit bc629c0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 282 deletions.
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.

0 comments on commit bc629c0

Please sign in to comment.