Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

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". Treating subsequent data as a
concatenated stream breaks npm install.

This reverts commits 93533e9
and 6f6a979.

Fixes: #8962
PR-URL: #8985
Reviewed-By: Julien Gilli <julien.gilli@joyent.com>
  • Loading branch information
chrisdickinson committed Jan 7, 2015
1 parent 372a2f5 commit c8ef97e
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 @@ -580,21 +580,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 @@ -212,7 +207,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 @@ -297,7 +292,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 @@ -310,18 +305,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 @@ -335,8 +326,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 @@ -350,11 +340,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 @@ -572,12 +557,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/simple/test-zlib-from-multiple-gzip-with-garbage.js

This file was deleted.

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

This file was deleted.

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

This file was deleted.

0 comments on commit c8ef97e

Please sign in to comment.