From 9c5883bdf658111c389813b6134633c354452a12 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 4 Oct 2002 18:59:34 +0000 Subject: [PATCH] replace dont_block with a flag. --- main/network.c | 2 +- main/php_streams.h | 7 ++++++- main/streams.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main/network.c b/main/network.c index fad7e40ff5a..14238d9b8d1 100644 --- a/main/network.c +++ b/main/network.c @@ -542,6 +542,7 @@ PHPAPI php_stream *_php_stream_sock_open_from_socket(int socket, const char *per sock->socket = socket; stream = php_stream_alloc_rel(&php_stream_socket_ops, sock, persistent_id, "r+"); + stream->flags |= PHP_STREAM_FLAG_AVOID_BLOCKING; if (stream == NULL) pefree(sock, persistent_id ? 1 : 0); @@ -924,7 +925,6 @@ php_stream_ops php_stream_socket_ops = { php_sockop_cast, php_sockop_stat, php_sockop_set_option, - 1 }; diff --git a/main/php_streams.h b/main/php_streams.h index 421dbf25358..3acd52624f5 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -153,7 +153,6 @@ typedef struct _php_stream_ops { int (*cast)(php_stream *stream, int castas, void **ret TSRMLS_DC); int (*stat)(php_stream *stream, php_stream_statbuf *ssb TSRMLS_DC); int (*set_option)(php_stream *stream, int option, int value, void *ptrparam TSRMLS_DC); - int dont_block; } php_stream_ops; typedef struct _php_stream_wrapper_ops { @@ -225,6 +224,12 @@ struct _php_stream_filter { #define PHP_STREAM_FLAG_EOL_UNIX 0 /* also includes DOS */ #define PHP_STREAM_FLAG_DETECT_EOL 4 #define PHP_STREAM_FLAG_EOL_MAC 8 + +/* set this when the stream might represent "interactive" data. + * When set, the read buffer will avoid certain operations that + * might otherwise cause the read to block for much longer than + * is strictly required. */ +#define PHP_STREAM_FLAG_AVOID_BLOCKING 16 struct _php_stream { php_stream_ops *ops; diff --git a/main/streams.c b/main/streams.c index a7cbfc62218..c7ebcf7309a 100755 --- a/main/streams.c +++ b/main/streams.c @@ -497,7 +497,7 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D stream->writepos += justread; - if (stream->ops->dont_block) + if (stream->flags & PHP_STREAM_FLAG_AVOID_BLOCKING) break; } }