replace dont_block with a flag.

This commit is contained in:
Wez Furlong 2002-10-04 18:59:34 +00:00
parent 08645d53c0
commit 9c5883bdf6
3 changed files with 8 additions and 3 deletions

View File

@ -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
};

View File

@ -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;

View File

@ -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;
}
}