[PHP-CVS] cvs: php4 /ext/sockets sockets.c
moriyoshi Fri Apr 4 09:16:59 2003 EDT Modified files: /php4/ext/sockets sockets.c Log: Fixed memleak in socket_select Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.134 php4/ext/sockets/sockets.c:1.135 --- php4/ext/sockets/sockets.c:1.134Fri Apr 4 08:02:43 2003 +++ php4/ext/sockets/sockets.c Fri Apr 4 09:16:59 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.134 2003/04/04 13:02:43 moriyoshi Exp $ */ +/* $Id: sockets.c,v 1.135 2003/04/04 14:16:59 moriyoshi Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -576,10 +576,21 @@ /* If seconds is not set to null, build the timeval, else we wait indefinitely */ if (sec != NULL) { - convert_to_long_ex(sec); + zval tmp; + + if (Z_TYPE_P(sec) != IS_LONG) { + tmp = *sec; + zval_copy_ctor(tmp); + convert_to_long(tmp); + sec = tmp; + } tv.tv_sec = Z_LVAL_P(sec); tv.tv_usec = usec; tv_p = tv; + + if (sec == tmp) { + zval_dtor(tmp); + } } retval = select(max_fd+1, rfds, wfds, efds, tv_p); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/sockets sockets.c
sterlingFri Dec 20 10:44:51 2002 EDT Modified files: /php4/ext/sockets sockets.c Log: silly error, will MFH Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.127 php4/ext/sockets/sockets.c:1.128 --- php4/ext/sockets/sockets.c:1.127Mon Dec 9 08:35:57 2002 +++ php4/ext/sockets/sockets.c Fri Dec 20 10:44:51 2002 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.127 2002/12/09 13:35:57 edink Exp $ */ +/* $Id: sockets.c,v 1.128 2002/12/20 15:44:51 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -747,7 +747,7 @@ ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket); - if (ZEND_NUM_ARGS() 4) { + if (ZEND_NUM_ARGS() 3) { length = str_len; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 /ext/sockets sockets.c
Ya, I was hoping on redoing this because it greatly abuses the kernels network buffering. -Jason On Sun, 2002-10-27 at 21:05, Sterling Hughes wrote: sterling Sun Oct 27 22:05:05 2002 EDT Modified files: /php4/ext/sockets sockets.c Log: make one-line read work on win32... # The implementation of this function is brain-dead, but at least # now its brain-dead on win32 too... ;-) Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.124 php4/ext/sockets/sockets.c:1.125 --- php4/ext/sockets/sockets.c:1.124 Fri Oct 4 14:01:52 2002 +++ php4/ext/sockets/sockets.cSun Oct 27 22:05:04 2002 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.124 2002/10/04 18:01:52 rasmus Exp $ */ +/* $Id: sockets.c,v 1.125 2002/10/28 03:05:04 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -272,7 +272,7 @@ } /* {{{ php_read -- wrapper around read() so that it only reads to a \r or \n. */ -int php_read(int bsd_socket, void *buf, int maxlen) +int php_read(int bsd_socket, void *buf, size_t maxlen, int flags) { int m = 0, n = 0; int no_read = 0; @@ -309,7 +309,7 @@ } if (n maxlen) { - m = read(bsd_socket, (void *) t, 1); + m = recv(bsd_socket, (void *) t, 1, flags); } if (errno != 0 errno != ESPIPE errno != EAGAIN) { @@ -766,7 +766,7 @@ } /* }}} */ -typedef int (*read_func)(int, void *, int); +typedef int (*read_func)(int, void *, size_t, int); /* {{{ proto string socket_read(resource socket, int length [, int type]) Reads a maximum of length bytes from socket */ @@ -774,7 +774,7 @@ { zval*arg1; php_socket *php_sock; - read_func read_function = (read_func) read; + read_func read_function = (read_func) recv; char*tmpbuf; int retval, length, type = PHP_BINARY_READ; @@ -789,12 +789,7 @@ tmpbuf = emalloc(length + 1); -#ifndef PHP_WIN32 - retval = (*read_function)(php_sock-bsd_socket, tmpbuf, length); -#else - retval = recv(php_sock-bsd_socket, tmpbuf, length, 0); -#endif - + retval = (*read_function)(php_sock-bsd_socket, tmpbuf, length, 0); if (retval == -1) { PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); efree(tmpbuf); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Jason Greene [EMAIL PROTECTED] [EMAIL PROTECTED] People seem to think that the blanket phrase, I only work here, absolves them utterly from any moral obligation in terms of the public -- but this was precisely Eichmann's excuse for his job in the concentration camps. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/sockets sockets.c
sterlingSun Oct 27 22:05:05 2002 EDT Modified files: /php4/ext/sockets sockets.c Log: make one-line read work on win32... # The implementation of this function is brain-dead, but at least # now its brain-dead on win32 too... ;-) Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.124 php4/ext/sockets/sockets.c:1.125 --- php4/ext/sockets/sockets.c:1.124Fri Oct 4 14:01:52 2002 +++ php4/ext/sockets/sockets.c Sun Oct 27 22:05:04 2002 -19,7 +19,7 +--+ */ -/* $Id: sockets.c,v 1.124 2002/10/04 18:01:52 rasmus Exp $ */ +/* $Id: sockets.c,v 1.125 2002/10/28 03:05:04 sterling Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -272,7 +272,7 } /* {{{ php_read -- wrapper around read() so that it only reads to a \r or \n. */ -int php_read(int bsd_socket, void *buf, int maxlen) +int php_read(int bsd_socket, void *buf, size_t maxlen, int flags) { int m = 0, n = 0; int no_read = 0; -309,7 +309,7 } if (n maxlen) { - m = read(bsd_socket, (void *) t, 1); + m = recv(bsd_socket, (void *) t, 1, flags); } if (errno != 0 errno != ESPIPE errno != EAGAIN) { -766,7 +766,7 } /* }}} */ -typedef int (*read_func)(int, void *, int); +typedef int (*read_func)(int, void *, size_t, int); /* {{{ proto string socket_read(resource socket, int length [, int type]) Reads a maximum of length bytes from socket */ -774,7 +774,7 { zval*arg1; php_socket *php_sock; - read_func read_function = (read_func) read; + read_func read_function = (read_func) recv; char*tmpbuf; int retval, length, type = PHP_BINARY_READ; -789,12 +789,7 tmpbuf = emalloc(length + 1); -#ifndef PHP_WIN32 - retval = (*read_function)(php_sock-bsd_socket, tmpbuf, length); -#else - retval = recv(php_sock-bsd_socket, tmpbuf, length, 0); -#endif - + retval = (*read_function)(php_sock-bsd_socket, tmpbuf, length, 0); if (retval == -1) { PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); efree(tmpbuf); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/sockets sockets.c
rasmus Fri Oct 4 14:01:53 2002 EDT Modified files: /php4/ext/sockets sockets.c Log: Kill warning Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.123 php4/ext/sockets/sockets.c:1.124 --- php4/ext/sockets/sockets.c:1.123Sun Sep 29 22:09:42 2002 +++ php4/ext/sockets/sockets.c Fri Oct 4 14:01:52 2002 -19,7 +19,7 +--+ */ -/* $Id: sockets.c,v 1.123 2002/09/30 02:09:42 jason Exp $ */ +/* $Id: sockets.c,v 1.124 2002/10/04 18:01:52 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -474,7 +474,7 /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(sockets) { - if (SOCKETS_G(strerror_buf) = emalloc(16384)) + if ((SOCKETS_G(strerror_buf) = emalloc(16384))) return SUCCESS; return FAILURE; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php