nxt_perl_psgi_layer.c (510:4979fe09d9cd) nxt_perl_psgi_layer.c (528:5b2cb5212d75)
1
2/*
3 * Copyright (C) Alexander Borisov
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <perl/nxt_perl_psgi_layer.h>
8

--- 245 unchanged lines hidden (view full) ---

254}
255
256
257static SV *
258nxt_perl_psgi_layer_stream_arg(pTHX_ PerlIO * f,
259 CLONE_PARAMS *param, int flags)
260{
261 SV *var;
1
2/*
3 * Copyright (C) Alexander Borisov
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <perl/nxt_perl_psgi_layer.h>
8

--- 245 unchanged lines hidden (view full) ---

254}
255
256
257static SV *
258nxt_perl_psgi_layer_stream_arg(pTHX_ PerlIO * f,
259 CLONE_PARAMS *param, int flags)
260{
261 SV *var;
262 nxt_perl_psgi_io_arg_t *arg;
263 nxt_perl_psgi_layer_stream_t *unit_stream;
264
265 unit_stream = PerlIOSelf(f, nxt_perl_psgi_layer_stream_t);
262 nxt_perl_psgi_layer_stream_t *unit_stream;
263
264 unit_stream = PerlIOSelf(f, nxt_perl_psgi_layer_stream_t);
266
267 arg = (nxt_perl_psgi_io_arg_t *) (intptr_t) SvIV(SvRV(unit_stream->var));
268 var = unit_stream->var;
269
270 if (flags & PERLIO_DUP_CLONE) {
271 var = PerlIO_sv_dup(aTHX_ var, param);
272
273 } else if (flags & PERLIO_DUP_FD) {
265 var = unit_stream->var;
266
267 if (flags & PERLIO_DUP_CLONE) {
268 var = PerlIO_sv_dup(aTHX_ var, param);
269
270 } else if (flags & PERLIO_DUP_FD) {
274 var = newSV_type(SVt_RV);
271 var = newSVsv(var);
275
272
276 if (var == NULL) {
277 return NULL;
278 }
279
280 sv_setptrref(var, arg);
281
282 } else {
283 var = SvREFCNT_inc(var);
284 }
285
286 return var;
287}
288
289
290static PerlIO *
291nxt_perl_psgi_layer_stream_dup(pTHX_ PerlIO *f, PerlIO *o,
292 CLONE_PARAMS *param, int flags)
293{
273 } else {
274 var = SvREFCNT_inc(var);
275 }
276
277 return var;
278}
279
280
281static PerlIO *
282nxt_perl_psgi_layer_stream_dup(pTHX_ PerlIO *f, PerlIO *o,
283 CLONE_PARAMS *param, int flags)
284{
294 SV *var;
295 nxt_perl_psgi_layer_stream_t *os, *fs;
285 nxt_perl_psgi_layer_stream_t *fs;
296
286
297 os = PerlIOSelf(o, nxt_perl_psgi_layer_stream_t);
298 fs = NULL;
299 var = os->var;
300
301 os->var = newSV_type(SVt_RV);
302 f = PerlIOBase_dup(aTHX_ f, o, param, flags);
303
304 if (f != NULL) {
305 fs = PerlIOSelf(f, nxt_perl_psgi_layer_stream_t);
287 f = PerlIOBase_dup(aTHX_ f, o, param, flags);
288
289 if (f != NULL) {
290 fs = PerlIOSelf(f, nxt_perl_psgi_layer_stream_t);
306
307 /* The "var" has been set by an implicit push and must be replaced. */
308 SvREFCNT_dec(fs->var);
309 }
310
311 SvREFCNT_dec(os->var);
312 os->var = var;
313
314 if (f != NULL) {
315 fs->var = nxt_perl_psgi_layer_stream_arg(aTHX_ o, param, flags);
316 }
317
318 return f;
319}
320
321
322static IV

--- 114 unchanged lines hidden ---
291 fs->var = nxt_perl_psgi_layer_stream_arg(aTHX_ o, param, flags);
292 }
293
294 return f;
295}
296
297
298static IV

--- 114 unchanged lines hidden ---