Skip to content

Commit 990de89

Browse files
committed
MFH: invert the logics - FLAG_FCLOSE -> FLAG_NO_FCLOSE
1 parent 41e64a7 commit 990de89

9 files changed

Lines changed: 5 additions & 22 deletions

File tree

‎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
@@ -861,8 +861,6 @@ PHP_NAMED_FUNCTION(php_if_tmpfile)
861861
stream = php_stream_fopen_tmpfile();
862862

863863
if (stream) {
864-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
865-
866864
php_stream_to_zval(stream, return_value);
867865
} else {
868866
RETURN_FALSE;
@@ -894,8 +892,6 @@ PHP_NAMED_FUNCTION(php_if_fopen)
894892
RETURN_FALSE;
895893
}
896894

897-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
898-
899895
php_stream_to_zval(stream, return_value);
900896

901897
if (zcontext) {
@@ -917,7 +913,7 @@ PHPAPI PHP_FUNCTION(fclose)
917913

918914
PHP_STREAM_TO_ZVAL(stream, arg1);
919915

920-
if (!(stream->flags & PHP_STREAM_FLAG_FCLOSE)) {
916+
if ((stream->flags & PHP_STREAM_FLAG_NO_FCLOSE) != 0) {
921917
php_error_docref(NULL TSRMLS_CC, E_WARNING, "%d is not a valid stream resource", stream->rsrc_id);
922918
RETURN_FALSE;
923919
}

‎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
@@ -151,8 +151,6 @@ PHP_FUNCTION(stream_socket_client)
151151
RETURN_FALSE;
152152
}
153153

154-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
155-
156154
if (errstr) {
157155
efree(errstr);
158156
}
@@ -199,8 +197,6 @@ PHP_FUNCTION(stream_socket_server)
199197
STREAM_XPORT_SERVER | flags,
200198
NULL, NULL, context, &errstr, &err);
201199

202-
stream->flags |= PHP_STREAM_FLAG_FCLOSE;
203-
204200
if (stream == NULL) {
205201
php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to connect to %s (%s)", host, errstr == NULL ? "Unknown error" : errstr);
206202
}
@@ -268,8 +264,6 @@ PHP_FUNCTION(stream_socket_accept)
268264
&tv, &errstr
269265
TSRMLS_CC) && clistream) {
270266

271-
clistream->flags |= PHP_STREAM_FLAG_FCLOSE;
272-
273267
if (peername) {
274268
Z_TYPE_P(peername) = IS_STRING;
275269
}

‎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
@@ -505,10 +505,6 @@ static void cli_register_file_handles(TSRMLS_D) /* {{{ */
505505
return;
506506
}
507507

508-
s_in->flags |= PHP_STREAM_FLAG_FCLOSE;
509-
s_out->flags |= PHP_STREAM_FLAG_FCLOSE;
510-
s_err->flags |= PHP_STREAM_FLAG_FCLOSE;
511-
512508
#if PHP_DEBUG
513509
/* do not close stdout and stderr */
514510
s_out->flags |= PHP_STREAM_FLAG_NO_CLOSE;

0 commit comments

Comments
 (0)