Skip to content

Commit bc629c0

Browse files
src: zlib: revert concatenated-stream changes
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 <[email protected]>
1 parent 9f45799 commit bc629c0

5 files changed

+8
-282
lines changed

lib/zlib.js

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

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

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

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

@@ -208,7 +203,7 @@ class ZCtx : public AsyncWrap {
208203
if (!async) {
209204
// sync version
210205
Process(work_req);
211-
if (CheckError(ctx) == kNoError)
206+
if (CheckError(ctx))
212207
AfterSync(ctx, args);
213208
return;
214209
}
@@ -292,7 +287,7 @@ class ZCtx : public AsyncWrap {
292287
}
293288

294289

295-
static node_zlib_error CheckError(ZCtx* ctx) {
290+
static bool CheckError(ZCtx* ctx) {
296291
// Acceptable error states depend on the type of zlib stream.
297292
switch (ctx->err_) {
298293
case Z_OK:
@@ -305,18 +300,14 @@ class ZCtx : public AsyncWrap {
305300
ZCtx::Error(ctx, "Missing dictionary");
306301
else
307302
ZCtx::Error(ctx, "Bad dictionary");
308-
return kFailed;
303+
return false;
309304
default:
310305
// something else.
311-
if (ctx->strm_.total_out == 0) {
312-
ZCtx::Error(ctx, "Zlib error");
313-
return kFailed;
314-
} else {
315-
return kWritePending;
316-
}
306+
ZCtx::Error(ctx, "Zlib error");
307+
return false;
317308
}
318309

319-
return kNoError;
310+
return true;
320311
}
321312

322313

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

333-
node_zlib_error error = CheckError(ctx);
334-
if (error == kFailed)
324+
if (!CheckError(ctx))
335325
return;
336326

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

348-
if (error == kWritePending) {
349-
ZCtx::Error(ctx, "Zlib error");
350-
return;
351-
}
352-
353338
ctx->Unref();
354339
if (ctx->pending_close_)
355340
ctx->Close();
@@ -554,12 +539,10 @@ class ZCtx : public AsyncWrap {
554539
switch (ctx->mode_) {
555540
case DEFLATE:
556541
case DEFLATERAW:
557-
case GZIP:
558542
ctx->err_ = deflateReset(&ctx->strm_);
559543
break;
560544
case INFLATE:
561545
case INFLATERAW:
562-
case GUNZIP:
563546
ctx->err_ = inflateReset(&ctx->strm_);
564547
break;
565548
default:

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

-83
This file was deleted.

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

-74
This file was deleted.

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

-93
This file was deleted.

0 commit comments

Comments
 (0)