Skip to content

Commit 9c5883b

Browse files
committed
replace dont_block with a flag.
1 parent 08645d5 commit 9c5883b

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

main/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, const char *per
542542
sock->socket = socket;
543543

544544
stream = php_stream_alloc_rel(&php_stream_socket_ops, sock, persistent_id, "r+");
545+
stream->flags |= PHP_STREAM_FLAG_AVOID_BLOCKING;
545546

546547
if (stream == NULL)
547548
pefree(sock, persistent_id ? 1 : 0);
@@ -924,7 +925,6 @@ php_stream_ops php_stream_socket_ops = {
924925
php_sockop_cast,
925926
php_sockop_stat,
926927
php_sockop_set_option,
927-
1
928928
};
929929

930930

main/php_streams.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ typedef struct _php_stream_ops {
153153
int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC);
154154
int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC);
155155
int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC);
156-
int dont_block;
157156
} php_stream_ops;
158157

159158
typedef struct _php_stream_wrapper_ops {
@@ -225,6 +224,12 @@ struct _php_stream_filter {
225224
#define PHP_STREAM_FLAG_EOL_UNIX 0 /* also includes DOS */
226225
#define PHP_STREAM_FLAG_DETECT_EOL 4
227226
#define PHP_STREAM_FLAG_EOL_MAC 8
227+
228+
/* set this when the stream might represent "interactive" data.
229+
* When set, the read buffer will avoid certain operations that
230+
* might otherwise cause the read to block for much longer than
231+
* is strictly required. */
232+
#define PHP_STREAM_FLAG_AVOID_BLOCKING 16
228233

229234
struct _php_stream {
230235
php_stream_ops *ops;

main/streams.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D
497497

498498
stream->writepos += justread;
499499

500-
if (stream->ops->dont_block)
500+
if (stream->flags & PHP_STREAM_FLAG_AVOID_BLOCKING)
501501
break;
502502
}
503503
}

0 commit comments

Comments
 (0)