cvs: php4(PHP_4_3) /ext/standard file.c /main network.c php_streams.h streams.c

From: Date: Tue, 13 May 2003 00:18:28 +0000
Subject: cvs: php4(PHP_4_3) /ext/standard file.c /main network.c php_streams.h streams.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-20848@lists.php.net to get a copy of this message
wez Mon May 12 20:18:28 2003 EDT Modified files: (Branch: PHP_4_3) /php4/ext/standard file.c /php4/main network.c php_streams.h streams.c Log: Fix erroneous error status when attempting to use stream_select() on an SSL stream. As a by-product, this also fixes Bug #22238, stream_select() clobbers read buffer for pipes. Index: php4/ext/standard/file.c diff -u php4/ext/standard/file.c:1.279.2.18 php4/ext/standard/file.c:1.279.2.19 --- php4/ext/standard/file.c:1.279.2.18 Mon Apr 28 11:11:14 2003 +++ php4/ext/standard/file.c Mon May 12 20:18:27 2003 @@ -21,7 +21,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: file.c,v 1.279.2.18 2003/04/28 15:11:14 moriyoshi Exp $ */ +/* $Id: file.c,v 1.279.2.19 2003/05/13 00:18:27 wez Exp $ */ /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */ @@ -657,7 +657,7 @@ * when casting. It is only used here so that the buffered data warning * is not displayed. * */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { FD_SET(this_fd, fds); if (this_fd > *max_fd) { *max_fd = this_fd; @@ -693,7 +693,7 @@ * when casting. It is only used here so that the buffered data warning * is not displayed. */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { if (FD_ISSET(this_fd, fds)) { zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem); if (dest_elem) Index: php4/main/network.c diff -u php4/main/network.c:1.83.2.9 php4/main/network.c:1.83.2.10 --- php4/main/network.c:1.83.2.9 Mon May 12 19:44:48 2003 +++ php4/main/network.c Mon May 12 20:18:27 2003 @@ -16,7 +16,7 @@ | Streams work by Wez Furlong <wez@thebrainroom.com> | +----------------------------------------------------------------------+ */ -/* $Id: network.c,v 1.83.2.9 2003/05/12 23:44:48 wez Exp $ */ +/* $Id: network.c,v 1.83.2.10 2003/05/13 00:18:27 wez Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -1137,24 +1137,29 @@ switch(castas) { case PHP_STREAM_AS_STDIO: #if HAVE_OPENSSL_EXT - if (sock->ssl_active) + if (sock->ssl_active) { return FAILURE; + } #endif - if (ret) { + if (ret) { *(FILE**)ret = fdopen(sock->socket, stream->mode); - if (*ret) + if (*ret) { return SUCCESS; + } return FAILURE; } return SUCCESS; case PHP_STREAM_AS_FD: case PHP_STREAM_AS_SOCKETD: #if HAVE_OPENSSL_EXT - if (sock->ssl_active) + if (sock->ssl_active) { return FAILURE; + } #endif - if (ret) + case PHP_STREAM_AS_FD_FOR_SELECT: + if (ret) { *(int*)ret = sock->socket; + } return SUCCESS; default: return FAILURE; Index: php4/main/php_streams.h diff -u php4/main/php_streams.h:1.61.2.10 php4/main/php_streams.h:1.61.2.11 --- php4/main/php_streams.h:1.61.2.10 Tue Mar 18 18:39:31 2003 +++ php4/main/php_streams.h Mon May 12 20:18:27 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams.h,v 1.61.2.10 2003/03/18 23:39:31 wez Exp $ */ +/* $Id: php_streams.h,v 1.61.2.11 2003/05/13 00:18:27 wez Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -462,6 +462,8 @@ #define PHP_STREAM_AS_FD 1 /* cast as a socketd */ #define PHP_STREAM_AS_SOCKETD 2 +/* cast as fd/socket for select purposes */ +#define PHP_STREAM_AS_FD_FOR_SELECT 3 /* try really, really hard to make sure the cast happens (avoid using this flag if possible) */ #define PHP_STREAM_CAST_TRY_HARD 0x80000000 Index: php4/main/streams.c diff -u php4/main/streams.c:1.125.2.53 php4/main/streams.c:1.125.2.54 --- php4/main/streams.c:1.125.2.53 Tue May 6 07:53:33 2003 +++ php4/main/streams.c Mon May 12 20:18:27 2003 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.125.2.53 2003/05/06 11:53:33 sas Exp $ */ +/* $Id: streams.c,v 1.125.2.54 2003/05/13 00:18:27 wez Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -1563,6 +1563,16 @@ data->fd = -1; } return SUCCESS; + + case PHP_STREAM_AS_FD_FOR_SELECT: + PHP_STDIOP_GET_FD(fd, data); + if (fd < 0) { + return FAILURE; + } + if (ret) { + *(int*)ret = fd; + } + return SUCCESS; case PHP_STREAM_AS_FD: PHP_STDIOP_GET_FD(fd, data); @@ -2112,7 +2122,7 @@ castas &= ~PHP_STREAM_CAST_MASK; /* synchronize our buffer (if possible) */ - if (ret) { + if (ret && castas != PHP_STREAM_AS_FD_FOR_SELECT) { php_stream_flush(stream); if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) { off_t dummy;

« previous php.cvs (#20848) next »