edink Mon Dec 9 08:35:58 2002 EDT
Modified files:
/php4/ext/sockets sockets.c
Log:
MFB: Fix for #20894.
Index: php4/ext/sockets/sockets.c
diff -u php4/ext/sockets/sockets.c:1.126 php4/ext/sockets/sockets.c:1.127
--- php4/ext/sockets/sockets.c:1.126 Sun Dec 1 17:15:39 2002
+++ php4/ext/sockets/sockets.c Mon Dec 9 08:35:57 2002
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sockets.c,v 1.126 2002/12/01 22:15:39 sterling Exp $ */
+/* $Id: sockets.c,v 1.127 2002/12/09 13:35:57 edink Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -766,30 +766,28 @@
}
/* }}} */
-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 */
PHP_FUNCTION(socket_read)
{
zval *arg1;
php_socket *php_sock;
- read_func read_function = (read_func) recv;
char *tmpbuf;
int retval, length, type = PHP_BINARY_READ;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, &length,
&type) == FAILURE)
return;
+ tmpbuf = emalloc(length + 1);
+
ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name,
le_socket);
if (type == PHP_NORMAL_READ) {
- read_function = (read_func) php_read;
+ retval = php_read(php_sock->bsd_socket, tmpbuf, length, 0);
+ } else {
+ retval = recv(php_sock->bsd_socket, tmpbuf, length, 0);
}
- tmpbuf = emalloc(length + 1);
-
- 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