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

Commit c8ef97e

Browse files
src,zlib: revert concatenated-stream changes
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 <[email protected]>
1 parent 372a2f5 commit c8ef97e

5 files changed

+8
-282
lines changed

lib/zlib.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -580,21 +580,14 @@ Zlib.prototype._processChunk = function(chunk, flushFlag, cb) {
580580
self._buffer = new Buffer(self._chunkSize);
581581
}
582582

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

591-
if (availOutAfter !== 0) {
592-
// There is still some data available for reading.
593-
// This is usually a concatenated stream, so, reset and restart.
594-
self.reset();
595-
self._offset = 0;
596-
}
597-
598591
if (!async)
599592
return true;
600593

src/node_zlib.cc

+7-24
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ enum node_zlib_mode {
6363
UNZIP
6464
};
6565

66-
enum node_zlib_error {
67-
kNoError,
68-
kFailed,
69-
kWritePending
70-
};
7166

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

@@ -212,7 +207,7 @@ class ZCtx : public AsyncWrap {
212207
if (!async) {
213208
// sync version
214209
Process(work_req);
215-
if (CheckError(ctx) == kNoError)
210+
if (CheckError(ctx))
216211
AfterSync(ctx, args);
217212
return;
218213
}
@@ -297,7 +292,7 @@ class ZCtx : public AsyncWrap {
297292
}
298293

299294

300-
static node_zlib_error CheckError(ZCtx* ctx) {
295+
static bool CheckError(ZCtx* ctx) {
301296
// Acceptable error states depend on the type of zlib stream.
302297
switch (ctx->err_) {
303298
case Z_OK:
@@ -310,18 +305,14 @@ class ZCtx : public AsyncWrap {
310305
ZCtx::Error(ctx, "Missing dictionary");
311306
else
312307
ZCtx::Error(ctx, "Bad dictionary");
313-
return kFailed;
308+
return false;
314309
default:
315310
// something else.
316-
if (ctx->strm_.total_out == 0) {
317-
ZCtx::Error(ctx, "Zlib error");
318-
return kFailed;
319-
} else {
320-
return kWritePending;
321-
}
311+
ZCtx::Error(ctx, "Zlib error");
312+
return false;
322313
}
323314

324-
return kNoError;
315+
return true;
325316
}
326317

327318

@@ -335,8 +326,7 @@ class ZCtx : public AsyncWrap {
335326
HandleScope handle_scope(env->isolate());
336327
Context::Scope context_scope(env->context());
337328

338-
node_zlib_error error = CheckError(ctx);
339-
if (error == kFailed)
329+
if (!CheckError(ctx))
340330
return;
341331

342332
Local<Integer> avail_out = Integer::New(env->isolate(),
@@ -350,11 +340,6 @@ class ZCtx : public AsyncWrap {
350340
Local<Value> args[2] = { avail_in, avail_out };
351341
ctx->MakeCallback(env->callback_string(), ARRAY_SIZE(args), args);
352342

353-
if (error == kWritePending) {
354-
ZCtx::Error(ctx, "Zlib error");
355-
return;
356-
}
357-
358343
ctx->Unref();
359344
if (ctx->pending_close_)
360345
ctx->Close();
@@ -572,12 +557,10 @@ class ZCtx : public AsyncWrap {
572557
switch (ctx->mode_) {
573558
case DEFLATE:
574559
case DEFLATERAW:
575-
case GZIP:
576560
ctx->err_ = deflateReset(&ctx->strm_);
577561
break;
578562
case INFLATE:
579563
case INFLATERAW:
580-
case GUNZIP:
581564
ctx->err_ = inflateReset(&ctx->strm_);
582565
break;
583566
default:

test/simple/test-zlib-from-multiple-gzip-with-garbage.js

-83
This file was deleted.

test/simple/test-zlib-from-multiple-gzip.js

-74
This file was deleted.

test/simple/test-zlib-from-multiple-huge-gzip.js

-93
This file was deleted.

0 commit comments

Comments
 (0)