[PHP-CVS] cvs: php-src /ext/sockets sockets.c
andrei Thu Jun 4 18:18:24 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: MFB http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.214r2=1.215diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.214 php-src/ext/sockets/sockets.c:1.215 --- php-src/ext/sockets/sockets.c:1.214 Tue May 19 11:57:52 2009 +++ php-src/ext/sockets/sockets.c Thu Jun 4 18:18:24 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.214 2009/05/19 11:57:52 lbarnaud Exp $ */ +/* $Id: sockets.c,v 1.215 2009/06/04 18:18:24 andrei Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1601,10 +1601,11 @@ zval_dtor(arg5); zval_dtor(arg6); + memset(addr6, 0, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, sin6.sin6_addr, addr6, INET6_ADDRSTRLEN); ZVAL_STRINGL(arg2, recv_buf, retval, 0); - ZVAL_STRING(arg5, addr6 ? addr6 : ::, 1); + ZVAL_STRING(arg5, addr6[0] ? addr6 : ::, 1); ZVAL_LONG(arg6, ntohs(sin6.sin6_port)); break; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
lbarnaudTue May 19 11:57:52 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: Fixed bug #48326 (constant MSG_DONTWAIT not defined) http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.213r2=1.214diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.213 php-src/ext/sockets/sockets.c:1.214 --- php-src/ext/sockets/sockets.c:1.213 Sun May 10 01:00:15 2009 +++ php-src/ext/sockets/sockets.c Tue May 19 11:57:52 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.213 2009/05/10 01:00:15 felipe Exp $ */ +/* $Id: sockets.c,v 1.214 2009/05/19 11:57:52 lbarnaud Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -620,6 +620,9 @@ REGISTER_LONG_CONSTANT(SOCK_RDM, SOCK_RDM, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_OOB, MSG_OOB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_WAITALL, MSG_WAITALL,CONST_CS | CONST_PERSISTENT); +#ifdef MSG_DONTWAIT + REGISTER_LONG_CONSTANT(MSG_DONTWAIT, MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT(MSG_PEEK, MSG_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_DONTROUTE, MSG_DONTROUTE, CONST_CS | CONST_PERSISTENT); #ifdef MSG_EOR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
I didn't quite understand why you didn't add this in PHP_5_2 and PHP_5_3. It's just a constant. Would even consider a bug since this should have been added with the other MSG_* constants. :) --Jani Arnaud Le Blanc kirjoitti: lbarnaudTue May 19 11:57:52 2009 UTC Modified files: /php-src/ext/sockets sockets.c Log: Fixed bug #48326 (constant MSG_DONTWAIT not defined) http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.213r2=1.214diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.213 php-src/ext/sockets/sockets.c:1.214 --- php-src/ext/sockets/sockets.c:1.213 Sun May 10 01:00:15 2009 +++ php-src/ext/sockets/sockets.c Tue May 19 11:57:52 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.213 2009/05/10 01:00:15 felipe Exp $ */ +/* $Id: sockets.c,v 1.214 2009/05/19 11:57:52 lbarnaud Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -620,6 +620,9 @@ REGISTER_LONG_CONSTANT(SOCK_RDM,SOCK_RDM, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_OOB, MSG_OOB, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_WAITALL, MSG_WAITALL,CONST_CS | CONST_PERSISTENT); +#ifdef MSG_DONTWAIT + REGISTER_LONG_CONSTANT(MSG_DONTWAIT,MSG_DONTWAIT, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT(MSG_PEEK,MSG_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_DONTROUTE, MSG_DONTROUTE,CONST_CS | CONST_PERSISTENT); #ifdef MSG_EOR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
felipe Sun May 10 01:00:15 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: - Fixed memory leak (patch by Christian Weiske) http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.212r2=1.213diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.212 php-src/ext/sockets/sockets.c:1.213 --- php-src/ext/sockets/sockets.c:1.212 Thu Apr 16 05:32:58 2009 +++ php-src/ext/sockets/sockets.c Sun May 10 01:00:15 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.212 2009/04/16 05:32:58 pajoye Exp $ */ +/* $Id: sockets.c,v 1.213 2009/05/10 01:00:15 felipe Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1553,6 +1553,7 @@ sin.sin_family = AF_INET; if (arg6 == NULL) { + efree(recv_buf); WRONG_PARAM_COUNT; } @@ -1581,6 +1582,7 @@ sin6.sin6_family = AF_INET6; if (arg6 == NULL) { + efree(recv_buf); WRONG_PARAM_COUNT; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pajoye Thu Apr 16 05:32:58 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: - #47978, typo in ext/sockets/sockets.c http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.211r2=1.212diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.211 php-src/ext/sockets/sockets.c:1.212 --- php-src/ext/sockets/sockets.c:1.211 Tue Mar 10 23:39:34 2009 +++ php-src/ext/sockets/sockets.c Thu Apr 16 05:32:58 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.211 2009/03/10 23:39:34 helly Exp $ */ +/* $Id: sockets.c,v 1.212 2009/04/16 05:32:58 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -365,7 +365,7 @@ sock-type = PF_INET; if (bind(sock-bsd_socket, (struct sockaddr *)la, sizeof(la)) 0) { - PHP_SOCKET_ERROR(sock, unable to bind to given adress, errno); + PHP_SOCKET_ERROR(sock, unable to bind to given address, errno); close(sock-bsd_socket); efree(sock); return 0; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
iliaa Tue Feb 3 19:23:12 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: MFB: Return empty string when recv() does not fetch any data http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.209r2=1.210diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.209 php-src/ext/sockets/sockets.c:1.210 --- php-src/ext/sockets/sockets.c:1.209 Sat Jan 24 13:09:13 2009 +++ php-src/ext/sockets/sockets.c Tue Feb 3 19:23:12 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.209 2009/01/24 13:09:13 tony2001 Exp $ */ +/* $Id: sockets.c,v 1.210 2009/02/03 19:23:12 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1036,6 +1036,9 @@ efree(tmpbuf); RETURN_FALSE; + } else if (!retval) { + efree(tmpbuf); + RETURN_EMPTY_STRING(); } tmpbuf = erealloc(tmpbuf, retval + 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Sat Jan 24 13:09:15 2009 UTC Modified files: /php-src/ext/socketssockets.c Log: fix build http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.208r2=1.209diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.208 php-src/ext/sockets/sockets.c:1.209 --- php-src/ext/sockets/sockets.c:1.208 Fri Jan 23 15:48:55 2009 +++ php-src/ext/sockets/sockets.c Sat Jan 24 13:09:13 2009 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.208 2009/01/23 15:48:55 kalle Exp $ */ +/* $Id: sockets.c,v 1.209 2009/01/24 13:09:13 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -51,7 +51,6 @@ # define set_errno(a) WSASetLastError(a) # define close(a) closesocket(a) #else -# include php_sockets.h # include sys/types.h # include sys/socket.h # include netdb.h @@ -67,6 +66,7 @@ # include sys/uio.h # define IS_INVALID_SOCKET(a) (a-bsd_socket 0) # define set_errno(a) (errno = a) +# include php_sockets.h #endif ZEND_DECLARE_MODULE_GLOBALS(sockets) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
lbarnaudWed Oct 22 18:58:43 2008 UTC Modified files: /php-src/ext/socketssockets.c Log: Fixed bug #46360 (TCP_NODELAY constant for socket_{get,set}_option) http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.201r2=1.202diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.201 php-src/ext/sockets/sockets.c:1.202 --- php-src/ext/sockets/sockets.c:1.201 Tue Oct 21 23:36:17 2008 +++ php-src/ext/sockets/sockets.c Wed Oct 22 18:58:43 2008 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.201 2008/10/21 23:36:17 lbarnaud Exp $ */ +/* $Id: sockets.c,v 1.202 2008/10/22 18:58:43 lbarnaud Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -661,6 +661,9 @@ REGISTER_LONG_CONSTANT(SO_ERROR, SO_ERROR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOL_SOCKET,SOL_SOCKET, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SOMAXCONN, SOMAXCONN, CONST_CS | CONST_PERSISTENT); +#ifdef TCP_NODELAY + REGISTER_LONG_CONSTANT(TCP_NODELAY, TCP_NODELAY,CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT(PHP_NORMAL_READ, PHP_NORMAL_READ, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(PHP_BINARY_READ, PHP_BINARY_READ, CONST_CS | CONST_PERSISTENT); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Wed Sep 26 10:54:56 2007 UTC Modified files: /php-src/ext/socketssockets.c Log: fix proto http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.194r2=1.195diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.194 php-src/ext/sockets/sockets.c:1.195 --- php-src/ext/sockets/sockets.c:1.194 Tue Jul 24 11:33:47 2007 +++ php-src/ext/sockets/sockets.c Wed Sep 26 10:54:56 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.194 2007/07/24 11:33:47 jani Exp $ */ +/* $Id: sockets.c,v 1.195 2007/09/26 10:54:56 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -616,7 +616,7 @@ } /* }}} */ -/* {{{ proto int socket_select(array read_fds, array write_fds, array except_fds, int tv_sec[, int tv_usec]) U +/* {{{ proto int socket_select(array read_fds, array write_fds, array except_fds, int tv_sec[, int tv_usec]) U Runs the select() system call on the sets mentioned with a timeout specified by tv_sec and tv_usec */ PHP_FUNCTION(socket_select) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
janiTue Jul 24 11:33:47 2007 UTC Modified files: /php-src/ext/socketssockets.c Log: - Added missing constants for MSG_EOR and MSG_EOF http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.193r2=1.194diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.193 php-src/ext/sockets/sockets.c:1.194 --- php-src/ext/sockets/sockets.c:1.193 Sun Jul 22 23:00:14 2007 +++ php-src/ext/sockets/sockets.c Tue Jul 24 11:33:47 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.193 2007/07/22 23:00:14 jani Exp $ */ +/* $Id: sockets.c,v 1.194 2007/07/24 11:33:47 jani Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -68,6 +68,12 @@ #endif #endif +#ifndef MSG_EOF +#ifdef MSG_FIN +#define MSG_EOF MSG_FIN +#endif +#endif + #ifndef SUN_LEN #define SUN_LEN(su) (sizeof(*(su)) - sizeof((su)-sun_path) + strlen((su)-sun_path)) #endif @@ -480,6 +486,12 @@ REGISTER_LONG_CONSTANT(MSG_WAITALL, MSG_WAITALL,CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_PEEK, MSG_PEEK, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(MSG_DONTROUTE, MSG_DONTROUTE, CONST_CS | CONST_PERSISTENT); +#ifdef MSG_EOR + REGISTER_LONG_CONSTANT(MSG_EOR, MSG_EOR, CONST_CS | CONST_PERSISTENT); +#endif +#ifdef MSG_EOF + REGISTER_LONG_CONSTANT(MSG_EOF, MSG_EOF, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_LONG_CONSTANT(SO_DEBUG, SO_DEBUG, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SO_REUSEADDR, SO_REUSEADDR, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT(SO_KEEPALIVE, SO_KEEPALIVE, CONST_CS | CONST_PERSISTENT); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
janiSun Jul 22 22:46:52 2007 UTC Modified files: /php-src/ext/socketssockets.c Log: WS fix http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.191r2=1.192diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.191 php-src/ext/sockets/sockets.c:1.192 --- php-src/ext/sockets/sockets.c:1.191 Sun Jul 22 22:17:51 2007 +++ php-src/ext/sockets/sockets.c Sun Jul 22 22:46:52 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.191 2007/07/22 22:17:51 jani Exp $ */ +/* $Id: sockets.c,v 1.192 2007/07/22 22:46:52 jani Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -101,7 +101,7 @@ ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -static +static ZEND_BEGIN_ARG_INFO(second_fifth_and_sixth_args_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(1) @@ -143,11 +143,11 @@ #endif PHP_FE(socket_last_error, NULL) PHP_FE(socket_clear_error, NULL) - + /* for downwards compatability */ PHP_FALIAS(socket_getopt, socket_get_option, NULL) PHP_FALIAS(socket_setopt, socket_set_option, NULL) - + {NULL, NULL, NULL} }; /* }}} */ @@ -205,7 +205,7 @@ efree(sock); return 0; } - + memcpy((char *) la.sin_addr, hp-h_addr, hp-h_length); la.sin_family = hp-h_addrtype; la.sin_port = htons((unsigned short) port); @@ -242,7 +242,7 @@ { socklen_t salen; php_socket *out_sock = (php_socket*)emalloc(sizeof(php_socket)); - + *new_sock = out_sock; salen = sizeof(*la); @@ -253,7 +253,7 @@ efree(out_sock); return 0; } - + return 1; } /* }}} */ @@ -290,24 +290,24 @@ * in the first pass. no_read becomes 2 in the second pass, * and if this is nonblocking, we should return.. */ } - + if (no_read 200) { set_errno(ECONNRESET); return -1; } } - + if (n maxlen) { m = recv(bsd_socket, (void *) t, 1, flags); } - + if (errno != 0 errno != ESPIPE errno != EAGAIN) { return -1; } - + set_errno(0); } - + if (n maxlen) { n++; /* The only reasons it makes it to here is @@ -316,7 +316,7 @@ * '\n' or '\r' in the count (since read() takes * place at the end of the loop..) */ } - + return n; } /* }}} */ @@ -344,26 +344,26 @@ } else { buf = strerror(error); } -#else +#else { LPTSTR tmp = NULL; buf = NULL; if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL)) { - + NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL) + ) { if (SOCKETS_G(strerror_buf)) { efree(SOCKETS_G(strerror_buf)); } SOCKETS_G(strerror_buf) = estrdup(tmp); LocalFree(tmp); - + buf = SOCKETS_G(strerror_buf); } } #endif - + return (buf ? (char *) buf : ); } /* }}} */ @@ -508,7 +508,7 @@ if ((pe = getprotobyname(udp))) { REGISTER_LONG_CONSTANT(SOL_UDP, pe-p_proto, CONST_CS | CONST_PERSISTENT); } - + return SUCCESS; } /* }}} */ @@ -540,7 +540,7 @@ zval**element; php_socket *php_sock; int num = 0; - + if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0; for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(sock_array)); @@ -607,8 +607,8 @@ struct timeval tv; struct timeval *tv_p = NULL; fd_set rfds, wfds, efds; - PHP_SOCKET max_fd = 0; - int retval, sets = 0; + PHP_SOCKET max_fd = 0; + int retval, sets = 0; longusec = 0; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a!a!a!z!|l, r_array, w_array, e_array,
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Sun Feb 25 22:58:57 2007 UTC Modified files: /php-src/ext/socketssockets.c Log: zerofill socket structs http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.188r2=1.189diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.188 php-src/ext/sockets/sockets.c:1.189 --- php-src/ext/sockets/sockets.c:1.188 Wed Jan 10 21:26:09 2007 +++ php-src/ext/sockets/sockets.c Sun Feb 25 22:58:57 2007 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.188 2007/01/10 21:26:09 bjori Exp $ */ +/* $Id: sockets.c,v 1.189 2007/02/25 22:58:57 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1138,6 +1138,8 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Socket of type AF_INET6 requires 3 arguments); RETURN_FALSE; } + + memset(sin6, 0, sizeof(struct sockaddr_in6)); sin6.sin6_family = AF_INET6; sin6.sin6_port = htons((unsigned short int)port); @@ -1154,6 +1156,8 @@ php_error_docref(NULL TSRMLS_CC, E_WARNING, Socket of type AF_INET requires 3 arguments); RETURN_FALSE; } + + memset(sin, 0, sizeof(struct sockaddr_in)); sin.sin_family = AF_INET; sin.sin_port = htons((unsigned short int)port); @@ -1166,6 +1170,8 @@ break; case AF_UNIX: + memset(s_un, 0, sizeof(struct sockaddr_un)); + s_un.sun_family = AF_UNIX; snprintf(s_un.sun_path, 108, %s, addr); retval = connect(php_sock-bsd_socket, (struct sockaddr *) s_un, SUN_LEN(s_un)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c /ext/standard reg.c
tony2001Thu Dec 28 14:17:09 2006 UTC Modified files: /php-src/ext/socketssockets.c /php-src/ext/standard reg.c Log: minor improvements http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.185r2=1.186diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.185 php-src/ext/sockets/sockets.c:1.186 --- php-src/ext/sockets/sockets.c:1.185 Mon Dec 25 19:34:00 2006 +++ php-src/ext/sockets/sockets.c Thu Dec 28 14:17:09 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.185 2006/12/25 19:34:00 tony2001 Exp $ */ +/* $Id: sockets.c,v 1.186 2006/12/28 14:17:09 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1627,11 +1627,12 @@ { zval*arg1, **arg4; struct linger lv; - struct timeval tv; php_socket *php_sock; int ov, optlen, retval; #ifdef PHP_WIN32 int timeout; +#else + struct timeval tv; #endif longlevel, optname; void*opt_ptr; http://cvs.php.net/viewvc.cgi/php-src/ext/standard/reg.c?r1=1.84r2=1.85diff_format=u Index: php-src/ext/standard/reg.c diff -u php-src/ext/standard/reg.c:1.84 php-src/ext/standard/reg.c:1.85 --- php-src/ext/standard/reg.c:1.84 Sun Jan 1 13:09:55 2006 +++ php-src/ext/standard/reg.c Thu Dec 28 14:17:09 2006 @@ -17,7 +17,7 @@ | Jaakko Hyvätti [EMAIL PROTECTED] | +--+ */ -/* $Id: reg.c,v 1.84 2006/01/01 13:09:55 sniper Exp $ */ +/* $Id: reg.c,v 1.85 2006/12/28 14:17:09 tony2001 Exp $ */ #include stdio.h #include ctype.h @@ -425,7 +425,7 @@ buf = nbuf; } /* stick that last bit of string on our output */ - strcat(buf, string[pos]); + strlcat(buf, string[pos], buf_len); } } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Mon Dec 25 19:34:00 2006 UTC Modified files: /php-src/ext/socketssockets.c Log: fix CS, add missing folding markers mark Unicode safe functions as they are http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.184r2=1.185diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.184 php-src/ext/sockets/sockets.c:1.185 --- php-src/ext/sockets/sockets.c:1.184 Sun Oct 8 13:34:23 2006 +++ php-src/ext/sockets/sockets.c Mon Dec 25 19:34:00 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.184 2006/10/08 13:34:23 bjori Exp $ */ +/* $Id: sockets.c,v 1.185 2006/12/25 19:34:00 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -176,15 +176,16 @@ /* inet_ntop should be used instead of inet_ntoa */ int inet_ntoa_lock = 0; -static void php_destroy_socket(zend_rsrc_list_entry *rsrc TSRMLS_DC) +static void php_destroy_socket(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */ { php_socket *php_sock = (php_socket *) rsrc-ptr; close(php_sock-bsd_socket); efree(php_sock); } +/* }}} */ -static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC) +static int php_open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC) /* {{{ */ { struct sockaddr_in la; struct hostent *hp; @@ -231,8 +232,9 @@ return 1; } +/* }}} */ -static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC) +static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct sockaddr *la TSRMLS_DC) /* {{{ */ { socklen_t salen; php_socket *out_sock = (php_socket*)emalloc(sizeof(php_socket)); @@ -250,6 +252,7 @@ return 1; } +/* }}} */ /* {{{ php_read -- wrapper around read() so that it only reads to a \r or \n. */ static int php_read(int bsd_socket, void *buf, size_t maxlen, int flags) @@ -314,7 +317,7 @@ } /* }}} */ -static char *php_strerror(int error TSRMLS_DC) +static char *php_strerror(int error TSRMLS_DC) /* {{{ */ { const char *buf; @@ -359,10 +362,11 @@ return (buf ? (char *) buf : ); } +/* }}} */ #if HAVE_IPV6 /* Sets addr by hostname, or by ip in string form (AF_INET6) */ -static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) +static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ { struct in6_addr tmp; #if HAVE_GETADDRINFO @@ -405,10 +409,11 @@ return 1; } +/* }}} */ #endif /* Sets addr by hostname, or by ip in string form (AF_INET) */ -static int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_sock TSRMLS_DC) +static int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_sock TSRMLS_DC) /* {{{ */ { struct in_addr tmp; struct hostent *host_entry; @@ -434,12 +439,15 @@ return 1; } +/* }}} */ +/* {{{ PHP_GINIT_FUNCTION */ static PHP_GINIT_FUNCTION(sockets) { sockets_globals-last_error = 0; sockets_globals-strerror_buf = NULL; } +/* }}} */ /* {{{ PHP_MINIT_FUNCTION */ @@ -530,7 +538,7 @@ } /* }}} */ -static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *max_fd TSRMLS_DC) +static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *max_fd TSRMLS_DC) /* {{{ */ { zval**element; php_socket *php_sock; @@ -554,8 +562,9 @@ return num ? 1 : 0; } +/* }}} */ -static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) +static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) /* {{{ */ { zval**element; zval**dest_element; @@ -591,8 +600,9 @@ return num ? 1 : 0; } +/* }}} */ -/* {{{ proto int socket_select(array read_fds, array write_fds, array except_fds, int tv_sec[, int tv_usec]) +/* {{{ proto int socket_select(array read_fds, array write_fds, array except_fds, int tv_sec[, int tv_usec]) U Runs the select() system call on the sets mentioned with a timeout specified by tv_sec and tv_usec */ PHP_FUNCTION(socket_select) { @@ -604,8 +614,9 @@ int retval, sets = 0; longusec = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a!a!a!z!|l, r_array, w_array, e_array, sec, usec) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, a!a!a!z!|l, r_array, w_array, e_array, sec, usec) == FAILURE) { return; + } FD_ZERO(rfds); FD_ZERO(wfds); @@ -665,15 +676,16 @@ } /* }}} */ -/* {{{ proto resource socket_create_listen(int port[, int backlog]) +/*
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Sun Jul 30 11:54:11 2006 UTC Modified files: /php-src/ext/socketssockets.c Log: improve checks and fix #38251 http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.180r2=1.181diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.180 php-src/ext/sockets/sockets.c:1.181 --- php-src/ext/sockets/sockets.c:1.180 Tue Jun 13 13:12:19 2006 +++ php-src/ext/sockets/sockets.c Sun Jul 30 11:54:11 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.180 2006/06/13 13:12:19 dmitry Exp $ */ +/* $Id: sockets.c,v 1.181 2006/07/30 11:54:11 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -534,6 +534,7 @@ { zval**element; php_socket *php_sock; + int num = 0; if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0; @@ -548,9 +549,10 @@ if (php_sock-bsd_socket *max_fd) { *max_fd = php_sock-bsd_socket; } + num++; } - return 1; + return num ? 1 : 0; } static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) @@ -559,6 +561,7 @@ zval**dest_element; php_socket *php_sock; HashTable *new_hash; + int num = 0; if (Z_TYPE_P(sock_array) != IS_ARRAY) return 0; @@ -576,6 +579,7 @@ zend_hash_next_index_insert(new_hash, (void *)element, sizeof(zval *), (void **)dest_element); if (dest_element) zval_add_ref(dest_element); } + num++; } /* Destroy old array, add new one */ @@ -585,7 +589,7 @@ zend_hash_internal_pointer_reset(new_hash); Z_ARRVAL_P(sock_array) = new_hash; - return 1; + return num ? 1 : 0; } /* {{{ proto int socket_select(array read_fds, array write_fds, array except_fds, int tv_sec[, int tv_usec]) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pajoye Fri Apr 7 13:34:53 2006 UTC Modified files: /php-src/ext/socketssockets.c Log: - MFB: fix leak when an error occured in socket_read, free tmpbuf http://cvs.php.net/viewcvs.cgi/php-src/ext/sockets/sockets.c?r1=1.177r2=1.178diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.177 php-src/ext/sockets/sockets.c:1.178 --- php-src/ext/sockets/sockets.c:1.177 Sun Jan 1 13:09:54 2006 +++ php-src/ext/sockets/sockets.c Fri Apr 7 13:34:53 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.177 2006/01/01 13:09:54 sniper Exp $ */ +/* $Id: sockets.c,v 1.178 2006/04/07 13:34:53 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -869,6 +869,7 @@ php_sock-error = errno; SOCKETS_G(last_error) = errno; } else { + efree(tmpbuf); PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pajoye Fri Apr 7 14:05:21 2006 UTC Modified files: /php-src/ext/socketssockets.c Log: - MFB: revert leak fix, something else went wrong http://cvs.php.net/viewcvs.cgi/php-src/ext/sockets/sockets.c?r1=1.178r2=1.179diff_format=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.178 php-src/ext/sockets/sockets.c:1.179 --- php-src/ext/sockets/sockets.c:1.178 Fri Apr 7 13:34:53 2006 +++ php-src/ext/sockets/sockets.c Fri Apr 7 14:05:21 2006 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.178 2006/04/07 13:34:53 pajoye Exp $ */ +/* $Id: sockets.c,v 1.179 2006/04/07 14:05:21 pajoye Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -869,7 +869,6 @@ php_sock-error = errno; SOCKETS_G(last_error) = errno; } else { - efree(tmpbuf); PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
iliaa Sun Dec 4 12:31:41 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: MFB51: Fixed bug #35062 (socket_read() produces warnings on non blocking sockets). http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.174r2=1.175ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.174 php-src/ext/sockets/sockets.c:1.175 --- php-src/ext/sockets/sockets.c:1.174 Sat Dec 3 18:24:07 2005 +++ php-src/ext/sockets/sockets.c Sun Dec 4 12:31:40 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.174 2005/12/03 23:24:07 tony2001 Exp $ */ +/* $Id: sockets.c,v 1.175 2005/12/04 17:31:40 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -859,7 +859,19 @@ } if (retval == -1) { - PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); + /* if the socket is in non-blocking mode and there's no data to read, + don't output any error, as this is a normal situation, and not an error */ + if (errno == EAGAIN +#ifdef EWOULDBLOCK + || errno == EWOULDBLOCK +#endif + ) { + php_sock-error = errno; + SOCKETS_G(last_error) = errno; + } else { + PHP_SOCKET_ERROR(php_sock, unable to read from socket, errno); + } + efree(tmpbuf); RETURN_FALSE; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Sat Dec 3 18:24:09 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: yet another compile warning http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.173r2=1.174ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.173 php-src/ext/sockets/sockets.c:1.174 --- php-src/ext/sockets/sockets.c:1.173 Thu Dec 1 09:03:51 2005 +++ php-src/ext/sockets/sockets.c Sat Dec 3 18:24:07 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.173 2005/12/01 14:03:51 tony2001 Exp $ */ +/* $Id: sockets.c,v 1.174 2005/12/03 23:24:07 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1504,7 +1504,9 @@ zval*arg1; struct linger linger_val; struct timeval tv; +#ifdef PHP_WIN32 int timeout = 0; +#endif socklen_t optlen; php_socket *php_sock; int other_val; @@ -1579,7 +1581,10 @@ struct linger lv; struct timeval tv; php_socket *php_sock; - int ov, optlen, retval, timeout; + int ov, optlen, retval; +#ifdef PHP_WIN32 + int timeout; +#endif longlevel, optname; void*opt_ptr; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
mikeThu Nov 3 10:01:31 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: - MFB44: #34851 (SO_RECVTIMEO and SO_SNDTIMEO socket options expect integer parameter on Windows) http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.171r2=1.172ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.171 php-src/ext/sockets/sockets.c:1.172 --- php-src/ext/sockets/sockets.c:1.171 Wed Aug 3 10:07:52 2005 +++ php-src/ext/sockets/sockets.c Thu Nov 3 10:01:31 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.171 2005/08/03 14:07:52 sniper Exp $ */ +/* $Id: sockets.c,v 1.172 2005/11/03 15:01:31 mike Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1504,6 +1504,7 @@ zval*arg1; struct linger linger_val; struct timeval tv; + int timeout = 0; socklen_t optlen; php_socket *php_sock; int other_val; @@ -1531,12 +1532,24 @@ break; case SO_RCVTIMEO: case SO_SNDTIMEO: +#ifndef PHP_WIN32 optlen = sizeof(tv); if (getsockopt(php_sock-bsd_socket, level, optname, (char*)tv, optlen) != 0) { PHP_SOCKET_ERROR(php_sock, unable to retrieve socket option, errno); RETURN_FALSE; } +#else + optlen = sizeof(int); + + if (getsockopt(php_sock-bsd_socket, level, optname, (char*)timeout, optlen) != 0) { + PHP_SOCKET_ERROR(php_sock, unable to retrieve socket option, errno); + RETURN_FALSE; + } + + tv.tv_sec = timeout ? timeout / 1000 : 0; + tv.tv_usec = timeout ? (timeout * 1000) % 100 : 0; +#endif array_init(return_value); @@ -1566,7 +1579,7 @@ struct linger lv; struct timeval tv; php_socket *php_sock; - int ov, optlen, retval; + int ov, optlen, retval, timeout; longlevel, optname; void*opt_ptr; @@ -1626,11 +1639,16 @@ convert_to_long_ex(sec); convert_to_long_ex(usec); +#ifndef PHP_WIN32 tv.tv_sec = Z_LVAL_PP(sec); tv.tv_usec = Z_LVAL_PP(usec); - optlen = sizeof(tv); opt_ptr = tv; +#else + timeout = Z_LVAL_PP(sec) * 1000 + Z_LVAL_PP(usec) / 1000; + optlen = sizeof(int); + opt_ptr = timeout; +#endif break; default: convert_to_long_ex(arg4); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
tony2001Thu May 12 12:26:27 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: fix #33019 (socket errors cause memory leaks in php_strerror()) patch by jwozniak23 at poczta dot onet dot pl http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.169r2=1.170ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.169 php-src/ext/sockets/sockets.c:1.170 --- php-src/ext/sockets/sockets.c:1.169 Mon Feb 14 18:44:23 2005 +++ php-src/ext/sockets/sockets.c Thu May 12 12:26:26 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.169 2005/02/14 23:44:23 sniper Exp $ */ +/* $Id: sockets.c,v 1.170 2005/05/12 16:26:26 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -321,6 +321,10 @@ buf = hstrerror(error); #else { + if (SOCKETS_G(strerror_buf)) { + efree(SOCKETS_G(strerror_buf)); + } + spprintf((SOCKETS_G(strerror_buf)), 0, Host lookup error %d, error); buf = SOCKETS_G(strerror_buf); } @@ -335,6 +339,11 @@ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL)) { + + if (SOCKETS_G(strerror_buf)) { + efree(SOCKETS_G(strerror_buf)); + } + SOCKETS_G(strerror_buf) = estrdup(tmp); LocalFree(tmp); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
sniper Mon Feb 14 17:16:06 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: - Removed duplicate error + reset error in new sockets http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.167r2=1.168ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.167 php-src/ext/sockets/sockets.c:1.168 --- php-src/ext/sockets/sockets.c:1.167 Sat Feb 12 13:14:03 2005 +++ php-src/ext/sockets/sockets.c Mon Feb 14 17:16:06 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.167 2005/02/12 18:14:03 sniper Exp $ */ +/* $Id: sockets.c,v 1.168 2005/02/14 22:16:06 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -663,6 +663,8 @@ RETURN_FALSE; } + php_sock-error = 0; + ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket); } /* }}} */ @@ -681,9 +683,10 @@ ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket); if (!php_accept_connect(php_sock, new_sock, (struct sockaddr *) sa TSRMLS_CC)) { - PHP_SOCKET_ERROR(new_sock, unable to accept socket connection, errno); RETURN_FALSE; } + + new_sock-error = 0; ZEND_REGISTER_RESOURCE(return_value, new_sock, le_socket); } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
sniper Mon Feb 14 18:44:24 2005 EDT Modified files: /php-src/ext/socketssockets.c Log: - More sock-error resets http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.168r2=1.169ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.168 php-src/ext/sockets/sockets.c:1.169 --- php-src/ext/sockets/sockets.c:1.168 Mon Feb 14 17:16:06 2005 +++ php-src/ext/sockets/sockets.c Mon Feb 14 18:44:23 2005 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.168 2005/02/14 22:16:06 sniper Exp $ */ +/* $Id: sockets.c,v 1.169 2005/02/14 23:44:23 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -1052,6 +1052,8 @@ RETURN_FALSE; } + php_sock-error = 0; + ZEND_REGISTER_RESOURCE(return_value, php_sock, le_socket); } /* }}} */ @@ -1688,6 +1690,8 @@ php_sock[1]-bsd_socket = fds_array[1]; php_sock[0]-type = domain; php_sock[1]-type = domain; + php_sock[0]-error = 0; + php_sock[1]-error = 0; ZEND_REGISTER_RESOURCE(retval[0], php_sock[0], le_socket); ZEND_REGISTER_RESOURCE(retval[1], php_sock[1], le_socket); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pollita Mon Jun 7 01:00:38 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: MFB: Missing length limit parameter. http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.164r2=1.165ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.164 php-src/ext/sockets/sockets.c:1.165 --- php-src/ext/sockets/sockets.c:1.164 Wed May 26 02:53:04 2004 +++ php-src/ext/sockets/sockets.c Mon Jun 7 01:00:37 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.164 2004/05/26 06:53:04 derick Exp $ */ +/* $Id: sockets.c,v 1.165 2004/06/07 05:00:37 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -322,7 +322,7 @@ buf = hstrerror(error); #else { - spprintf((SOCKETS_G(strerror_buf)), Host lookup error %d, error); + spprintf((SOCKETS_G(strerror_buf)), 0, Host lookup error %d, error); buf = SOCKETS_G(strerror_buf); } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
derick Wed May 26 02:53:04 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: - Fixed bug #28523 (Typo in ext/sockets/sockets.c) http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.163r2=1.164ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.163 php-src/ext/sockets/sockets.c:1.164 --- php-src/ext/sockets/sockets.c:1.163 Tue May 18 06:49:06 2004 +++ php-src/ext/sockets/sockets.c Wed May 26 02:53:04 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.163 2004/05/18 10:49:06 edink Exp $ */ +/* $Id: sockets.c,v 1.164 2004/05/26 06:53:04 derick Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -322,7 +322,7 @@ buf = hstrerror(error); #else { - spprintf((SOCKETS_G(strerror_buf), Host lookup error %d, error); + spprintf((SOCKETS_G(strerror_buf)), Host lookup error %d, error); buf = SOCKETS_G(strerror_buf); } #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
edink Tue May 18 06:49:06 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: No length parameter - estrdup() http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.162r2=1.163ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.162 php-src/ext/sockets/sockets.c:1.163 --- php-src/ext/sockets/sockets.c:1.162 Sun May 16 11:34:53 2004 +++ php-src/ext/sockets/sockets.c Tue May 18 06:49:06 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.162 2004/05/16 15:34:53 iliaa Exp $ */ +/* $Id: sockets.c,v 1.163 2004/05/18 10:49:06 edink Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -336,7 +336,7 @@ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL)) { - SOCKETS_G(strerror_buf) = estrndup(tmp); + SOCKETS_G(strerror_buf) = estrdup(tmp); LocalFree(tmp); buf = SOCKETS_G(strerror_buf); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
iliaa Sun May 16 11:34:53 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: Do not allocate error buffer at the start of every request. http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.161r2=1.162ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.161 php-src/ext/sockets/sockets.c:1.162 --- php-src/ext/sockets/sockets.c:1.161 Sun Mar 14 12:53:28 2004 +++ php-src/ext/sockets/sockets.c Sun May 16 11:34:53 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.161 2004/03/14 17:53:28 jan Exp $ */ +/* $Id: sockets.c,v 1.162 2004/05/16 15:34:53 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -322,7 +322,7 @@ buf = hstrerror(error); #else { - sprintf(SOCKETS_G(strerror_buf), Host lookup error %d, error); + spprintf((SOCKETS_G(strerror_buf), Host lookup error %d, error); buf = SOCKETS_G(strerror_buf); } #endif @@ -336,7 +336,7 @@ if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL)) { - strlcpy(SOCKETS_G(strerror_buf), (char *) tmp, 1); + SOCKETS_G(strerror_buf) = estrndup(tmp); LocalFree(tmp); buf = SOCKETS_G(strerror_buf); @@ -503,8 +503,6 @@ /* {{{ PHP_RINIT_FUNCTION */ PHP_RINIT_FUNCTION(sockets) { - SOCKETS_G(strerror_buf) = emalloc(16384); - return SUCCESS; } /* }}} */ @@ -512,8 +510,11 @@ /* {{{ PHP_RSHUTDOWN_FUNCTION */ PHP_RSHUTDOWN_FUNCTION(sockets) { - efree(SOCKETS_G(strerror_buf)); - + if (SOCKETS_G(strerror_buf)) { + efree(SOCKETS_G(strerror_buf)); + SOCKETS_G(strerror_buf) = NULL; + } + return SUCCESS; } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
msopacuaSun Mar 14 06:42:18 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: Fix a typo, dating back from 1.145. http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.159r2=1.160ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.159 php-src/ext/sockets/sockets.c:1.160 --- php-src/ext/sockets/sockets.c:1.159 Wed Feb 25 17:10:09 2004 +++ php-src/ext/sockets/sockets.c Sun Mar 14 06:42:17 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.159 2004/02/25 22:10:09 iliaa Exp $ */ +/* $Id: sockets.c,v 1.160 2004/03/14 11:42:17 msopacua Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -385,7 +385,7 @@ #else /* No IPv6 specific hostname resolution is available on this system? */ php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: getaddrinfo() not available on system.); - reurn 0; + return 0; #endif } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
jan Sun Mar 14 12:53:29 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: - improve error message http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.160r2=1.161ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.160 php-src/ext/sockets/sockets.c:1.161 --- php-src/ext/sockets/sockets.c:1.160 Sun Mar 14 06:42:17 2004 +++ php-src/ext/sockets/sockets.c Sun Mar 14 12:53:28 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.160 2004/03/14 11:42:17 msopacua Exp $ */ +/* $Id: sockets.c,v 1.161 2004/03/14 17:53:28 jan Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -384,7 +384,7 @@ #else /* No IPv6 specific hostname resolution is available on this system? */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: getaddrinfo() not available on system.); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: getaddrinfo() not available on this system.); return 0; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
iliaa Wed Feb 25 17:10:10 2004 EDT Modified files: /php-src/ext/socketssockets.c Log: Fixed bug #21760 (Use of uninitialized pointer inside php_read()). Fixed 3 possible crashes due to integer overflow or invalid user input inside the sockets extension. http://cvs.php.net/diff.php/php-src/ext/sockets/sockets.c?r1=1.158r2=1.159ty=u Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.158 php-src/ext/sockets/sockets.c:1.159 --- php-src/ext/sockets/sockets.c:1.158 Thu Jan 8 03:17:27 2004 +++ php-src/ext/sockets/sockets.c Wed Feb 25 17:10:09 2004 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.158 2004/01/08 08:17:27 andi Exp $ */ +/* $Id: sockets.c,v 1.159 2004/02/25 22:10:09 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -266,6 +266,7 @@ set_errno(0); + *t = '\0'; while (*t != '\n' *t != '\r' n maxlen) { if (m 0) { t++; @@ -828,6 +829,11 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rl|l, arg1, length, type) == FAILURE) return; + /* overflow check */ + if ((length + 1) 2) { + RETURN_FALSE; + } + tmpbuf = emalloc(length + 1); ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket); @@ -1225,6 +1231,11 @@ ZEND_FETCH_RESOURCE(php_sock, php_socket *, php_sock_res, -1, le_socket_name, le_socket); + /* overflow check */ + if ((len + 1) 2) { + RETURN_FALSE; + } + recv_buf = emalloc(len + 1); memset(recv_buf, 0, len + 1); @@ -1301,6 +1312,11 @@ ZEND_FETCH_RESOURCE(php_sock, php_socket *, arg1, -1, le_socket_name, le_socket); + /* overflow check */ + if ((arg3 + 2) 3) { + RETURN_FALSE; + } + recv_buf = emalloc(arg3 + 2); memset(recv_buf, 0, arg3 + 2); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
sniper Tue Dec 16 15:39:41 2003 EDT Modified files: /php-src/ext/socketssockets.c Log: nuke unused code Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.156 php-src/ext/sockets/sockets.c:1.157 --- php-src/ext/sockets/sockets.c:1.156 Fri Dec 5 19:00:29 2003 +++ php-src/ext/sockets/sockets.c Tue Dec 16 15:39:40 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.156 2003/12/06 00:00:29 wez Exp $ */ +/* $Id: sockets.c,v 1.157 2003/12/16 20:39:40 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -111,17 +111,6 @@ ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -static - ZEND_BEGIN_ARG_INFO(third_through_seventh_args_force_ref, 0) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(0) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) - ZEND_ARG_PASS_INFO(1) - ZEND_END_ARG_INFO(); - /* {{{ sockets_functions[] */ function_entry sockets_functions[] = { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c ZendEngine2 ZEND_CHANGES zend_API.c zend_execute_API.c
helly Fri Oct 24 14:24:29 2003 EDT Modified files: /ZendEngine2ZEND_CHANGES zend_API.c zend_execute_API.c /php-src/ext/socketssockets.c Log: Zend/ZEND_CHANGES Index: ZendEngine2/ZEND_CHANGES diff -u ZendEngine2/ZEND_CHANGES:1.61 ZendEngine2/ZEND_CHANGES:1.62 --- ZendEngine2/ZEND_CHANGES:1.61 Tue Oct 21 02:41:26 2003 +++ ZendEngine2/ZEND_CHANGESFri Oct 24 14:24:27 2003 @@ -651,6 +651,79 @@ TBD: Respect visibility: Show protected only when inside class method and only otherwise public properties only. + Each class whose instances can be iterated with foreach should + implement the empty interface 'Traversable'. Hence any object + that says it implements 'Traversable' can be used with forach. + + The interfaces 'IteratorAggregate' and 'Iterator' allow to specify + how class objects are iterated in PHP code. The first of them simply + has a method 'getIterator' which must return an array or an object + that either implements the interface 'Iterator' or is instantiated + from an internal class that can be iterated. + + Example: + +?php +class ObjectIterator implements Iterator { + +private $obj; +private $num; + +function __construct($obj) { +$this-obj = $obj; +} +function rewind() { +$this-num = 0; +} +function hasMore() { +return $this-num $this-obj-max; +} +function key() { +return $this-num; +} +function current() { +switch($this-num) { +case 0: return 1st; +case 1: return 2nd; +case 2: return 3rd; +default: return $this-num.th; +} +} +function next() { +$this-num++; +} +} + +class Oject implements IteratorAggregate { + +public $max = 3; + +function getIterator() { +return new ObjectIterator($this); +} +} + +$obj = new Object; + +// this foreach ... +foreach($obj as $key = $val) { +echo $key = $val\n; +} + +// matches the following 7 lines with the for directive. +$it = $obj-getIterator(); +for($it-rewind(); $it-hasMore(); $it-next) { +$key = $it-current(); +$val = $it-key(); +echo $key = $val\n; +} +unset($it); +? + + The matching for directive is very intersting here since it shows + the use of all abstract methods declared in the interfaces Iterator + and IteratorAggregate respectively. + * __METHOD__ The pseudo constant __METHOD__ shows the current class and method Index: ZendEngine2/zend_API.c diff -u ZendEngine2/zend_API.c:1.221 ZendEngine2/zend_API.c:1.222 --- ZendEngine2/zend_API.c:1.221Wed Oct 22 15:59:58 2003 +++ ZendEngine2/zend_API.c Fri Oct 24 14:24:27 2003 @@ -18,7 +18,7 @@ +--+ */ -/* $Id: zend_API.c,v 1.221 2003/10/22 19:59:58 helly Exp $ */ +/* $Id: zend_API.c,v 1.222 2003/10/24 18:24:27 helly Exp $ */ #include zend.h #include zend_execute.h @@ -1588,8 +1588,23 @@ return 1; lcname = zend_str_tolower_dup(Z_STRVAL_P(callable), Z_STRLEN_P(callable)); - if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(callable)+1)) + if (zend_hash_exists(EG(function_table), lcname, Z_STRLEN_P(callable)+1)) { retval = 1; + } else { + char *func_pos; + if ((func_pos=strstr(lcname, ::))) { + int lcclass_len = (int)(func_pos - lcname); + char *lcclass = estrndup(lcname, lcclass_len); + zend_class_entry **ce; + + if (zend_lookup_class(lcclass, lcclass_len, ce TSRMLS_CC) == SUCCESS) { + int func_len = Z_STRLEN_P(callable) - lcclass_len - 2; + func_pos += 2; + retval = zend_hash_exists((*ce)-function_table, func_pos, func_len + 1) ? 1 : 0; + } +
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c ZendEngine2 ZEND_CHANGES zend_API.c zend_execute_API.c
Hello Marcus, Friday, October 24, 2003, 8:24:29 PM, you wrote: FUCK cvs! -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
helly Fri Oct 24 14:44:42 2003 EDT Modified files: /php-src/ext/socketssockets.c Log: Revert accidential commit Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.154 php-src/ext/sockets/sockets.c:1.155 --- php-src/ext/sockets/sockets.c:1.154 Fri Oct 24 14:24:28 2003 +++ php-src/ext/sockets/sockets.c Fri Oct 24 14:44:40 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.154 2003/10/24 18:24:28 helly Exp $ */ +/* $Id: sockets.c,v 1.155 2003/10/24 18:44:40 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -107,6 +107,17 @@ ZEND_ARG_PASS_INFO(1) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) + ZEND_ARG_PASS_INFO(1) + ZEND_END_ARG_INFO(); + +static + ZEND_BEGIN_ARG_INFO(third_through_seventh_args_force_ref, 0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) + ZEND_ARG_PASS_INFO(1) + ZEND_ARG_PASS_INFO(1) ZEND_ARG_PASS_INFO(1) ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
helly Sun Aug 3 14:55:51 2003 EDT Modified files: /php-src/ext/socketssockets.c Log: Fix build Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.148 php-src/ext/sockets/sockets.c:1.149 --- php-src/ext/sockets/sockets.c:1.148 Sun Aug 3 13:44:37 2003 +++ php-src/ext/sockets/sockets.c Sun Aug 3 14:55:51 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.148 2003/08/03 17:44:37 zeev Exp $ */ +/* $Id: sockets.c,v 1.149 2003/08/03 18:55:51 helly Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -110,7 +110,7 @@ ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -static unsigned char second_fifth_and_sixth_args_force_ref[] = +static ZEND_BEGIN_ARG_INFO(second_fifth_and_sixth_args_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(1) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c /ext/standardstreamsfuncs.c
MFH (to PHP_4_3 branch). And try to use the bug numbers in the commit messages. And add news entry in the NEWS file (in PHP_4_3 branch). --Jani On Tue, 22 Jul 2003, Jason Greene wrote: jason Tue Jul 22 03:20:56 2003 EDT Modified files: /php-src/ext/sockets sockets.c /php-src/ext/standard streamsfuncs.c Log: Fix EINVAL errors for OS's (Solaris + BSD) that do not appreciate microseconds = 1 second Patch submitted from [EMAIL PROTECTED] Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.146 php-src/ext/sockets/sockets.c:1.147 --- php-src/ext/sockets/sockets.c:1.146Tue Jul 8 01:00:13 2003 +++ php-src/ext/sockets/sockets.c Tue Jul 22 03:20:55 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.146 2003/07/08 05:00:13 pollita Exp $ */ +/* $Id: sockets.c,v 1.147 2003/07/22 07:20:55 jason Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -641,8 +641,16 @@ convert_to_long(tmp); sec = tmp; } - tv.tv_sec = Z_LVAL_P(sec); - tv.tv_usec = usec; + + /* Solaris + BSD do not like microsecond values which are = 1 sec */ + if (usec 99) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 100); + tv.tv_usec = usec % 100; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = tv; if (sec == tmp) { Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.24 php-src/ext/standard/streamsfuncs.c:1.25 --- php-src/ext/standard/streamsfuncs.c:1.24 Sat Jun 28 07:24:46 2003 +++ php-src/ext/standard/streamsfuncs.cTue Jul 22 03:20:55 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.24 2003/06/28 11:24:46 wez Exp $ */ +/* $Id: streamsfuncs.c,v 1.25 2003/07/22 07:20:55 jason Exp $ */ #include php.h #include php_globals.h @@ -563,8 +563,16 @@ /* If seconds is not set to null, build the timeval, else we wait indefinitely */ if (sec != NULL) { convert_to_long_ex(sec); - tv.tv_sec = Z_LVAL_P(sec); - tv.tv_usec = usec; + + /* Solaris + BSD do not like microsecond values which are = 1 sec */ + if (usec 99) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 100); + tv.tv_usec = usec % 100; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = tv; } -- https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c /ext/standard streamsfuncs.c
jason Tue Jul 22 03:20:56 2003 EDT Modified files: /php-src/ext/socketssockets.c /php-src/ext/standard streamsfuncs.c Log: Fix EINVAL errors for OS's (Solaris + BSD) that do not appreciate microseconds = 1 second Patch submitted from [EMAIL PROTECTED] Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.146 php-src/ext/sockets/sockets.c:1.147 --- php-src/ext/sockets/sockets.c:1.146 Tue Jul 8 01:00:13 2003 +++ php-src/ext/sockets/sockets.c Tue Jul 22 03:20:55 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.146 2003/07/08 05:00:13 pollita Exp $ */ +/* $Id: sockets.c,v 1.147 2003/07/22 07:20:55 jason Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -641,8 +641,16 @@ convert_to_long(tmp); sec = tmp; } - tv.tv_sec = Z_LVAL_P(sec); - tv.tv_usec = usec; + + /* Solaris + BSD do not like microsecond values which are = 1 sec */ + if (usec 99) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 100); + tv.tv_usec = usec % 100; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = tv; if (sec == tmp) { Index: php-src/ext/standard/streamsfuncs.c diff -u php-src/ext/standard/streamsfuncs.c:1.24 php-src/ext/standard/streamsfuncs.c:1.25 --- php-src/ext/standard/streamsfuncs.c:1.24Sat Jun 28 07:24:46 2003 +++ php-src/ext/standard/streamsfuncs.c Tue Jul 22 03:20:55 2003 @@ -17,7 +17,7 @@ +--+ */ -/* $Id: streamsfuncs.c,v 1.24 2003/06/28 11:24:46 wez Exp $ */ +/* $Id: streamsfuncs.c,v 1.25 2003/07/22 07:20:55 jason Exp $ */ #include php.h #include php_globals.h @@ -563,8 +563,16 @@ /* If seconds is not set to null, build the timeval, else we wait indefinitely */ if (sec != NULL) { convert_to_long_ex(sec); - tv.tv_sec = Z_LVAL_P(sec); - tv.tv_usec = usec; + + /* Solaris + BSD do not like microsecond values which are = 1 sec */ + if (usec 99) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 100); + tv.tv_usec = usec % 100; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = tv; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
This is correct. -Jason On Mon, 2003-07-07 at 19:51, Jani Taskinen wrote: And you're sure getaddrinfo() is always available (whenever IPV6 is) ?? --Jani On Mon, 7 Jul 2003, Sara Golemon wrote: pollita Mon Jul 7 18:27:32 2003 EDT Modified files: /php-src/ext/sockets sockets.c Log: Fix non-GNU build. Use getaddrinfo() rather than gethostbyname2() Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.143 php-src/ext/sockets/sockets.c:1.144 --- php-src/ext/sockets/sockets.c:1.143 Tue Jun 17 00:44:30 2003 +++ php-src/ext/sockets/sockets.cMon Jul 7 18:27:32 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.143 2003/06/17 04:44:30 sterling Exp $ */ +/* $Id: sockets.c,v 1.144 2003/07/07 22:27:32 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -378,12 +378,16 @@ static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) { struct in6_addr tmp; -struct hostent *host_entry; +struct addrinfo hints; +struct addrinfo *addrinfo = NULL; if (inet_pton(AF_INET6, string, tmp)) { memcpy((sin6-sin6_addr.s6_addr), (tmp.s6_addr), sizeof(struct in6_addr)); } else { -if (! (host_entry = gethostbyname2(string, AF_INET6))) { +memset(hints, 0, sizeof(struct addrinfo)); +hints.ai_family = PF_INET6; +getaddrinfo(string, NULL, hints, addrinfo); +if (!addrinfo) { #ifdef PHP_WIN32 PHP_SOCKET_ERROR(php_sock, Host lookup failed, WSAGetLastError()); #else @@ -391,11 +395,14 @@ #endif return 0; } -if (host_entry-h_addrtype != AF_INET6) { +if (addrinfo-ai_family != PF_INET6 || addrinfo-ai_addrlen != sizeof(struct sockaddr_in6)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket); +freeaddrinfo(addrinfo); return 0; } -memcpy((sin6-sin6_addr.s6_addr), host_entry-h_addr_list[0], host_entry-h_length); + +memcpy((sin6-sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo-ai_addr))-sin6_addr.s6_addr, sizeof(struct in6_addr)); +freeaddrinfo(addrinfo); } return 1; -- https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR -- Jason Greene [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
On Tue, 2003-07-08 at 08:15, Sascha Schumann wrote: On Tue, 8 Jul 2003, Jason Greene wrote: If the platform supports gethostbyname_r(most i know do), that is thread safe. Note the 2 in the name. - Sascha I should have been more specific, we should change the ipv4 resolver code in sockets to use either getaddrinfo or gethostbyname_r, as it is currently not thread safe. The Ipv6 resolver code should just always use getaddrinfo -Jason -- Jason Greene [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
FYI: gethostbyname() is thread-safe under win32. I have some code hanging around in my libwstreams repository that implements getaddrinfo() using all the possible variations of gethostbyname() or gethostbyname_r() (there are 3 possible prototypes accepting 3, 5 or 6 parameters respectively!) for IPV4 only systems. I will be merging it into PHP once I've tidied it up fully, and it should make for some nice readable resolving code at last. --Wez. - Original Message - From: Jason Greene [EMAIL PROTECTED] To: Sascha Schumann [EMAIL PROTECTED] Cc: Sara Golemon [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 08, 2003 2:22 PM Subject: Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c On Tue, 2003-07-08 at 08:15, Sascha Schumann wrote: On Tue, 8 Jul 2003, Jason Greene wrote: If the platform supports gethostbyname_r(most i know do), that is thread safe. Note the 2 in the name. - Sascha I should have been more specific, we should change the ipv4 resolver code in sockets to use either getaddrinfo or gethostbyname_r, as it is currently not thread safe. The Ipv6 resolver code should just always use getaddrinfo -Jason -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
On Tue, 2003-07-08 at 08:59, Wez Furlong wrote: FYI: gethostbyname() is thread-safe under win32. I thought so but wasn't sure I have some code hanging around in my libwstreams repository that implements getaddrinfo() using all the possible variations of gethostbyname() or gethostbyname_r() (there are 3 possible prototypes accepting 3, 5 or 6 parameters respectively!) for IPV4 only systems. I will be merging it into PHP once I've tidied it up fully, and it should make for some nice readable resolving code at last. sounds good -Jason --Wez. - Original Message - From: Jason Greene [EMAIL PROTECTED] To: Sascha Schumann [EMAIL PROTECTED] Cc: Sara Golemon [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, July 08, 2003 2:22 PM Subject: Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c On Tue, 2003-07-08 at 08:15, Sascha Schumann wrote: On Tue, 8 Jul 2003, Jason Greene wrote: If the platform supports gethostbyname_r(most i know do), that is thread safe. Note the 2 in the name. - Sascha I should have been more specific, we should change the ipv4 resolver code in sockets to use either getaddrinfo or gethostbyname_r, as it is currently not thread safe. The Ipv6 resolver code should just always use getaddrinfo -Jason -- Jason Greene [EMAIL PROTECTED] [EMAIL PROTECTED] -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pollita Mon Jul 7 18:27:32 2003 EDT Modified files: /php-src/ext/socketssockets.c Log: Fix non-GNU build. Use getaddrinfo() rather than gethostbyname2() Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.143 php-src/ext/sockets/sockets.c:1.144 --- php-src/ext/sockets/sockets.c:1.143 Tue Jun 17 00:44:30 2003 +++ php-src/ext/sockets/sockets.c Mon Jul 7 18:27:32 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.143 2003/06/17 04:44:30 sterling Exp $ */ +/* $Id: sockets.c,v 1.144 2003/07/07 22:27:32 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -378,12 +378,16 @@ static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) { struct in6_addr tmp; - struct hostent *host_entry; + struct addrinfo hints; + struct addrinfo *addrinfo = NULL; if (inet_pton(AF_INET6, string, tmp)) { memcpy((sin6-sin6_addr.s6_addr), (tmp.s6_addr), sizeof(struct in6_addr)); } else { - if (! (host_entry = gethostbyname2(string, AF_INET6))) { + memset(hints, 0, sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; + getaddrinfo(string, NULL, hints, addrinfo); + if (!addrinfo) { #ifdef PHP_WIN32 PHP_SOCKET_ERROR(php_sock, Host lookup failed, WSAGetLastError()); #else @@ -391,11 +395,14 @@ #endif return 0; } - if (host_entry-h_addrtype != AF_INET6) { + if (addrinfo-ai_family != PF_INET6 || addrinfo-ai_addrlen != sizeof(struct sockaddr_in6)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket); + freeaddrinfo(addrinfo); return 0; } - memcpy((sin6-sin6_addr.s6_addr), host_entry-h_addr_list[0], host_entry-h_length); + + memcpy((sin6-sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo-ai_addr))-sin6_addr.s6_addr, sizeof(struct in6_addr)); + freeaddrinfo(addrinfo); } return 1; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/sockets sockets.c
And you're sure getaddrinfo() is always available (whenever IPV6 is) ?? --Jani On Mon, 7 Jul 2003, Sara Golemon wrote: pollitaMon Jul 7 18:27:32 2003 EDT Modified files: /php-src/ext/sockets sockets.c Log: Fix non-GNU build. Use getaddrinfo() rather than gethostbyname2() Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.143 php-src/ext/sockets/sockets.c:1.144 --- php-src/ext/sockets/sockets.c:1.143Tue Jun 17 00:44:30 2003 +++ php-src/ext/sockets/sockets.c Mon Jul 7 18:27:32 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.143 2003/06/17 04:44:30 sterling Exp $ */ +/* $Id: sockets.c,v 1.144 2003/07/07 22:27:32 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -378,12 +378,16 @@ static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock TSRMLS_DC) { struct in6_addr tmp; - struct hostent *host_entry; + struct addrinfo hints; + struct addrinfo *addrinfo = NULL; if (inet_pton(AF_INET6, string, tmp)) { memcpy((sin6-sin6_addr.s6_addr), (tmp.s6_addr), sizeof(struct in6_addr)); } else { - if (! (host_entry = gethostbyname2(string, AF_INET6))) { + memset(hints, 0, sizeof(struct addrinfo)); + hints.ai_family = PF_INET6; + getaddrinfo(string, NULL, hints, addrinfo); + if (!addrinfo) { #ifdef PHP_WIN32 PHP_SOCKET_ERROR(php_sock, Host lookup failed, WSAGetLastError()); #else @@ -391,11 +395,14 @@ #endif return 0; } - if (host_entry-h_addrtype != AF_INET6) { + if (addrinfo-ai_family != PF_INET6 || addrinfo-ai_addrlen != sizeof(struct sockaddr_in6)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket); + freeaddrinfo(addrinfo); return 0; } - memcpy((sin6-sin6_addr.s6_addr), host_entry-h_addr_list[0], host_entry-h_length); + + memcpy((sin6-sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo-ai_addr))-sin6_addr.s6_addr, sizeof(struct in6_addr)); + freeaddrinfo(addrinfo); } return 1; -- https://www.paypal.com/xclick/[EMAIL PROTECTED]no_note=1tax=0currency_code=EUR -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/sockets sockets.c
pollita Tue Jul 8 01:00:15 2003 EDT Modified files: /php-src/ext/socketssockets.c Log: gethostbyname2() not thread safe. Use getaddrinfo() or nothing at all. Index: php-src/ext/sockets/sockets.c diff -u php-src/ext/sockets/sockets.c:1.145 php-src/ext/sockets/sockets.c:1.146 --- php-src/ext/sockets/sockets.c:1.145 Mon Jul 7 23:38:00 2003 +++ php-src/ext/sockets/sockets.c Tue Jul 8 01:00:13 2003 @@ -19,7 +19,7 @@ +--+ */ -/* $Id: sockets.c,v 1.145 2003/07/08 03:38:00 pollita Exp $ */ +/* $Id: sockets.c,v 1.146 2003/07/08 05:00:13 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include config.h @@ -381,8 +381,6 @@ #ifdef HAVE_GETADDRINFO struct addrinfo hints; struct addrinfo *addrinfo = NULL; -#elif defined(HAVE_GETHOSTBYNAME2) - struct hostent *host_entry; #endif if (inet_pton(AF_INET6, string, tmp)) { @@ -410,25 +408,9 @@ memcpy((sin6-sin6_addr.s6_addr), ((struct sockaddr_in6*)(addrinfo-ai_addr))-sin6_addr.s6_addr, sizeof(struct in6_addr)); freeaddrinfo(addrinfo); -#elif defined(HAVE_GETHOSTBYNAME2) - - if (! (host_entry = gethostbyname2(string, AF_INET6))) { -#ifdef PHP_WIN32 - PHP_SOCKET_ERROR(php_sock, Host lookup failed, WSAGetLastError()); -#else - PHP_SOCKET_ERROR(php_sock, Host lookup failed, (-1 - h_errno)); -#endif - return 0; - } - if (host_entry-h_addrtype != AF_INET6) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: Non AF_INET6 domain returned on AF_INET6 socket); - return 0; - } - memcpy((sin6-sin6_addr.s6_addr), host_entry-h_addr_list[0], host_entry-h_length); - #else /* No IPv6 specific hostname resolution is available on this system? */ - php_error_docref(NULL TSRMLS_CC, E_WARNING, No IPv6 compatable hostname resolution available on system.); + php_error_docref(NULL TSRMLS_CC, E_WARNING, Host lookup failed: getaddrinfo() not available on system.); reurn 0; #endif -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php