[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c php_network.h

2005-01-04 Thread Jani Taskinen
sniper  Tue Jan  4 05:35:57 2005 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c php_network.h 
  Log:
  - Fix bug #31403 (php_hostconnect not defined as PHPAPI)
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.83.2.26r2=1.83.2.27ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.26 php-src/main/network.c:1.83.2.27
--- php-src/main/network.c:1.83.2.26Fri Jul  2 13:23:07 2004
+++ php-src/main/network.c  Tue Jan  4 05:35:56 2005
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.26 2004/07/02 17:23:07 wez Exp $ */
+/* $Id: network.c,v 1.83.2.27 2005/01/04 10:35:56 sniper Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -430,7 +430,7 @@
  * port, returns the created socket on success, else returns -1.
  * timeout gives timeout in seconds, 0 means blocking mode.
  */
-int php_hostconnect(const char *host, unsigned short port, int socktype, 
struct timeval *timeout TSRMLS_DC)
+PHPAPI int php_hostconnect(const char *host, unsigned short port, int 
socktype, struct timeval *timeout TSRMLS_DC)
 {  
int n, repeatto, s;
struct sockaddr **sal, **psal;
http://cvs.php.net/diff.php/php-src/main/php_network.h?r1=1.37.2.4r2=1.37.2.5ty=u
Index: php-src/main/php_network.h
diff -u php-src/main/php_network.h:1.37.2.4 php-src/main/php_network.h:1.37.2.5
--- php-src/main/php_network.h:1.37.2.4 Sat Nov 29 07:02:40 2003
+++ php-src/main/php_network.h  Tue Jan  4 05:35:56 2005
@@ -15,7 +15,7 @@
| Author: Stig Venaas [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: php_network.h,v 1.37.2.4 2003/11/29 12:02:40 wez Exp $ */
+/* $Id: php_network.h,v 1.37.2.5 2005/01/04 10:35:56 sniper Exp $ */
 
 #ifndef _PHP_NETWORK_H
 #define _PHP_NETWORK_H
@@ -109,7 +109,7 @@
 #endif
 
 
-int php_hostconnect(const char *host, unsigned short port, int socktype, 
struct timeval *timeout TSRMLS_DC);
+PHPAPI int php_hostconnect(const char *host, unsigned short port, int 
socktype, struct timeval *timeout TSRMLS_DC);
 PHPAPI int php_connect_nonb(int sockfd, const struct sockaddr *addr, socklen_t 
addrlen, struct timeval *timeout);
 
 #ifdef PHP_WIN32

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c

2004-05-23 Thread Wez Furlong
wez Sun May 23 06:43:15 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c 
  Log:
  MFH: Bugfix for #23220: IIS messes up SSL shutdown
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.83.2.24r2=1.83.2.25ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.24 php-src/main/network.c:1.83.2.25
--- php-src/main/network.c:1.83.2.24Mon Apr 19 08:43:26 2004
+++ php-src/main/network.c  Sun May 23 06:43:15 2004
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.24 2004/04/19 12:43:26 wez Exp $ */
+/* $Id: network.c,v 1.83.2.25 2004/05/23 10:43:15 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -746,6 +746,8 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, 
php_stream_sock_ssl_activate_with_method: failed to create an SSL context);
return FAILURE;
}
+   
+   SSL_CTX_set_options(ctx, SSL_OP_ALL);
 
sock-ssl_handle = php_SSL_new_from_context(ctx, stream TSRMLS_CC);
 
@@ -846,6 +848,30 @@
}
 }
 
+/* it doesn't matter that we do some hash traversal here, since it is done only
+ * in an error condition arising from a network connection problem */
+static int is_http_stream_talking_to_iis(php_stream *stream TSRMLS_DC)
+{
+   if (stream-wrapperdata  stream-wrapper  
strcmp(stream-wrapper-wops-label, HTTP) == 0) {
+   /* the wrapperdata is an array zval containing the headers */
+   zval **tmp;
+
+#define SERVER_MICROSOFT_IIS   Server: Microsoft-IIS
+   
+   zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream-wrapperdata));
+   while (SUCCESS == 
zend_hash_get_current_data(Z_ARRVAL_P(stream-wrapperdata), (void**)tmp)) {
+
+   if (strncasecmp(Z_STRVAL_PP(tmp), SERVER_MICROSOFT_IIS, 
sizeof(SERVER_MICROSOFT_IIS)-1) == 0) {
+   return 1;
+   }
+   
+   zend_hash_move_forward(Z_ARRVAL_P(stream-wrapperdata));
+   }
+   }
+   return 0;
+}
+
+
 static int handle_ssl_error(php_stream *stream, int nr_bytes TSRMLS_DC)
 {
php_netstream_data_t *sock = (php_netstream_data_t*)stream-abstract;
@@ -870,8 +896,11 @@
case SSL_ERROR_SYSCALL:
if (ERR_peek_error() == 0) {
if (nr_bytes == 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING,
-   SSL: fatal protocol error);
+   if (!is_http_stream_talking_to_iis(stream 
TSRMLS_CC)) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING,
+   SSL: fatal protocol 
error);
+   }
+   SSL_set_shutdown(sock-ssl_handle, 
SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
stream-eof = 1;
retry = 0;
} else {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c

2004-04-19 Thread Wez Furlong
wez Mon Apr 19 08:43:27 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c 
  Log:
  MFH: timeout duration too long in liveness checks for sockets.
  Fixes Bug #28055
  
  
http://cvs.php.net/diff.php/php-src/main/network.c?r1=1.83.2.23r2=1.83.2.24ty=u
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.23 php-src/main/network.c:1.83.2.24
--- php-src/main/network.c:1.83.2.23Wed Jan 14 09:54:14 2004
+++ php-src/main/network.c  Mon Apr 19 08:43:26 2004
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.23 2004/01/14 14:54:14 wez Exp $ */
+/* $Id: network.c,v 1.83.2.24 2004/04/19 12:43:26 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1155,15 +1155,9 @@
int alive = 1;
int fd = sock-socket;
fd_set rfds;
-   struct timeval tv;
+   struct timeval tv = {0, 0};
char buf;

-   if (sock-timeout.tv_sec == -1) {
-   tv.tv_sec = FG(default_socket_timeout);
-   } else {
-   tv = sock-timeout;
-   }
-
/* logic: if the select call indicates that there is data to
 * be read, but a read returns 0 bytes of data, then the socket
 * has been closed.

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c

2004-01-14 Thread Wez Furlong
wez Wed Jan 14 09:54:15 2004 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c 
  Log:
  Probable fix for:
  Bug #25575 stream_set_blocking with STDIN doesnt block 
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.22 php-src/main/network.c:1.83.2.23
--- php-src/main/network.c:1.83.2.22Sat Nov 29 07:02:40 2003
+++ php-src/main/network.c  Wed Jan 14 09:54:14 2004
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.22 2003/11/29 12:02:40 wez Exp $ */
+/* $Id: network.c,v 1.83.2.23 2004/01/14 14:54:14 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -628,6 +628,22 @@
memset(sock, 0, sizeof(php_netstream_data_t));
 
sock-is_blocked = 1;
+
+#if !defined(PHP_WIN32)  (defined(O_NONBLOCK) || defined(O_NDELAY))
+   if (socket = 0  socket  3) {
+   /* mini-hack: if we are opening stdin, stdout or stderr,
+* we need to check to see if they are currently in
+* blocking or non-blocking mode. */
+   int flags = fcntl(socket, F_GETFL);
+
+#ifdef O_NONBLOCK
+   sock-is_blocked = !(flags  O_NONBLOCK);
+#else
+   sock-is_blocked = !(flags  O_NDELAY);
+#endif
+   }
+#endif
+   
sock-timeout.tv_sec = FG(default_socket_timeout);
sock-timeout.tv_usec = 0;
sock-socket = socket;

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c streams.c

2003-11-28 Thread Wez Furlong
wez Fri Nov 28 17:11:35 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c streams.c 
  Log:
  Fix for bug #25939; feof not working correctly for sockets.
  Possibly also fixes #23220; warnings issued by fgets on ssl sockets.
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.20 php-src/main/network.c:1.83.2.21
--- php-src/main/network.c:1.83.2.20Fri Oct 17 07:09:49 2003
+++ php-src/main/network.c  Fri Nov 28 17:11:34 2003
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.20 2003/10/17 11:09:49 sas Exp $ */
+/* $Id: network.c,v 1.83.2.21 2003/11/28 22:11:34 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1139,8 +1139,14 @@
int alive = 1;
int fd = sock-socket;
fd_set rfds;
-   struct timeval tv = {0, 0};
+   struct timeval tv;
char buf;
+   
+   if (sock-timeout.tv_sec == -1) {
+   tv.tv_sec = FG(default_socket_timeout);
+   } else {
+   tv = sock-timeout;
+   }
 
/* logic: if the select call indicates that there is data to
 * be read, but a read returns 0 bytes of data, then the socket
Index: php-src/main/streams.c
diff -u php-src/main/streams.c:1.125.2.83 php-src/main/streams.c:1.125.2.84
--- php-src/main/streams.c:1.125.2.83   Thu Nov 27 19:00:34 2003
+++ php-src/main/streams.c  Fri Nov 28 17:11:34 2003
@@ -20,7 +20,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.125.2.83 2003/11/28 00:00:34 iliaa Exp $ */
+/* $Id: streams.c,v 1.125.2.84 2003/11/28 22:11:34 wez Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -659,6 +659,10 @@
if (stream-writepos - stream-readpos  0)
return 0;
 
+   if (!stream-eof  php_stream_is(stream, PHP_STREAM_IS_SOCKET)) {
+   stream-eof = !_php_network_is_stream_alive(stream);
+   }
+   
return stream-eof;
 }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c

2003-10-17 Thread Sascha Schumann
sas Fri Oct 17 07:09:53 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c 
  Log:
  Fix comment
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.19 php-src/main/network.c:1.83.2.20
--- php-src/main/network.c:1.83.2.19Wed Oct  8 07:22:47 2003
+++ php-src/main/network.c  Fri Oct 17 07:09:49 2003
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.19 2003/10/08 11:22:47 wez Exp $ */
+/* $Id: network.c,v 1.83.2.20 2003/10/17 11:09:49 sas Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1070,7 +1070,7 @@
 
/* try to make sure that the OS sends all data before we close the 
connection.
 * Essentially, we are waiting for the socket to become writeable, 
which means
-* that all pending data has been sent.
+* that some (not all) pending data has been sent.
 * We use a small timeout which should encourage the OS to send the 
data,
 * but at the same time avoid hanging indefintely.
 * */

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_4_3) /main network.c

2003-10-08 Thread Wez Furlong
wez Wed Oct  8 07:22:47 2003 EDT

  Modified files:  (Branch: PHP_4_3)
/php-src/main   network.c 
  Log:
  Don't forget these EOF flags either...
  
  
Index: php-src/main/network.c
diff -u php-src/main/network.c:1.83.2.18 php-src/main/network.c:1.83.2.19
--- php-src/main/network.c:1.83.2.18Fri Jun 27 12:42:51 2003
+++ php-src/main/network.c  Wed Oct  8 07:22:47 2003
@@ -16,7 +16,7 @@
| Streams work by Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: network.c,v 1.83.2.18 2003/06/27 16:42:51 sniper Exp $ */
+/* $Id: network.c,v 1.83.2.19 2003/10/08 11:22:47 wez Exp $ */
 
 /*#define DEBUG_MAIN_NETWORK 1*/
 
@@ -1013,9 +1013,7 @@
 
if (nr_bytes = 0) {
retry = handle_ssl_error(stream, nr_bytes TSRMLS_CC);
-   if (retry == 0  !SSL_pending(sock-ssl_handle)) {
-   stream-eof = 1;
-   }
+   stream-eof = (retry == 0  
!SSL_pending(sock-ssl_handle));
} else {
/* we got the data */
break;
@@ -1034,9 +1032,7 @@
 
nr_bytes = recv(sock-socket, buf, count, 0);
 
-   if (nr_bytes == 0 || (nr_bytes == -1  php_socket_errno() != 
EWOULDBLOCK)) {
-   stream-eof = 1;
-   }
+   stream-eof = (nr_bytes == 0 || (nr_bytes == -1  php_socket_errno() 
!= EWOULDBLOCK));
}
 
if (nr_bytes  0) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php