Skip to content

Commit 28a2239

Browse files
committed
MFH: invert the logics - FLAG_FCLOSE -> FLAG_NO_FCLOSE
1 parent 16ace18 commit 28a2239

File tree

9 files changed

+5
-22
lines changed

9 files changed

+5
-22
lines changed

ext/bz2/bz2.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
247247
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
248248
bz_file = BZ2_bzdopen(fd, mode);
249249
}
250-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
251250
}
252251

253252
/* remove the file created by php_stream_open_wrapper(), it is not needed since BZ2 functions
@@ -261,7 +260,6 @@ PHP_BZ2_API php_stream *_php_stream_bz2open(php_stream_wrapper *wrapper,
261260
if (bz_file) {
262261
retstream = _php_stream_bz2open_from_BZFILE(bz_file, mode, stream STREAMS_REL_CC TSRMLS_CC);
263262
if (retstream) {
264-
retstream->flags |= PHP_STREAM_FLAG_FCLOSE;
265263
return retstream;
266264
}
267265

ext/standard/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ static void _php_do_opendir(INTERNAL_FUNCTION_PARAMETERS, int createobject)
220220
if (dirp == NULL) {
221221
RETURN_FALSE;
222222
}
223+
224+
dirp->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
223225

224226
php_set_default_dir(dirp->rsrc_id TSRMLS_CC);
225227

ext/standard/file.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,8 +856,6 @@ PHP_NAMED_FUNCTION(php_if_tmpfile)
856856
stream = php_stream_fopen_tmpfile();
857857

858858
if (stream) {
859-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
860-
861859
php_stream_to_zval(stream, return_value);
862860
} else {
863861
RETURN_FALSE;
@@ -888,8 +886,6 @@ PHP_NAMED_FUNCTION(php_if_fopen)
888886
RETURN_FALSE;
889887
}
890888

891-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
892-
893889
php_stream_to_zval(stream, return_value);
894890
}
895891
/* }}} */
@@ -907,7 +903,7 @@ PHPAPI PHP_FUNCTION(fclose)
907903

908904
PHP_STREAM_TO_ZVAL(stream, &arg1);
909905

910-
if (!(stream->flags & PHP_STREAM_FLAG_FCLOSE)) {
906+
if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
911907
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id);
912908
RETURN_FALSE;
913909
}

ext/standard/fsock.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ static void php_fsockopen_stream(INTERNAL_FUNCTION_PARAMETERS, int persistent)
7979
stream = php_stream_xport_create(hostname, hostname_len, ENFORCE_SAFE_MODE | REPORT_ERRORS,
8080
STREAM_XPORT_CLIENT | STREAM_XPORT_CONNECT, hashkey, &tv, NULL, &errstr, &err);
8181

82-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
83-
8482
if (port > 0) {
8583
efree(hostname);
8684
}

ext/standard/proc_open.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ PHP_FUNCTION(proc_open)
969969
zval *retfp;
970970

971971
/* nasty hack; don't copy it */
972-
stream->flags |= PHP_STREAM_FLAG_NO_SEEK | PHP_STREAM_FLAG_FCLOSE;
972+
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
973973

974974
MAKE_STD_ZVAL(retfp);
975975
php_stream_to_zval(stream, retfp);

ext/standard/streamsfuncs.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ PHP_FUNCTION(stream_socket_client)
155155
RETURN_FALSE;
156156
}
157157

158-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
159-
160158
if (errstr) {
161159
efree(errstr);
162160
}
@@ -204,8 +202,6 @@ PHP_FUNCTION(stream_socket_server)
204202
STREAM_XPORT_SERVER | flags,
205203
NULL, NULL, context, &errstr, &err);
206204

207-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
208-
209205
if (stream == NULL) {
210206
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : errstr);
211207
}
@@ -271,8 +267,6 @@ PHP_FUNCTION(stream_socket_accept)
271267
&tv, &errstr
272268
TSRMLS_CC) && clistream) {
273269

274-
clistream->flags |= PHP_STREAM_FLAG_FCLOSE;
275-
276270
if (peername) {
277271
ZVAL_STRINGL(zpeername, peername, peername_len, 0);
278272
}

ext/zip/zip_stream.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ php_stream *php_stream_zip_open(char *filename, char *path, char *mode STREAMS_D
140140
if (!stream) {
141141
return NULL;
142142
} else {
143-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
144143
return stream;
145144
}
146145

main/php_streams.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ struct _php_stream_wrapper {
183183

184184
#define PHP_STREAM_FLAG_IS_DIR 64
185185

186-
#define PHP_STREAM_FLAG_FCLOSE 128
186+
#define PHP_STREAM_FLAG_NO_FCLOSE 128
187187

188188
struct _php_stream {
189189
php_stream_ops *ops;

sapi/cli/php_cli.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,6 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */
502502
return;
503503
}
504504

505-
s_in->flags |= PHP_STREAM_FLAG_FCLOSE;
506-
s_out->flags |= PHP_STREAM_FLAG_FCLOSE;
507-
s_err->flags |= PHP_STREAM_FLAG_FCLOSE;
508-
509505
#if PHP_DEBUG
510506
/* do not close stdout and stderr */
511507
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;

0 commit comments

Comments
 (0)