diff -Naur php-src-orig/ext/curl/streams.c php-src/ext/curl/streams.c --- php-src-orig/ext/curl/streams.c 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/curl/streams.c 2005-12-22 10:56:12.000000000 -0500 @@ -156,8 +156,8 @@ curl_multi_fdset(curlstream->multi, &curlstream->readfds, &curlstream->writefds, &curlstream->excfds, &curlstream->maxfd); /* if we are in blocking mode, set a timeout */ - tv.tv_usec = 0; - tv.tv_sec = 15; /* TODO: allow this to be configured from the script */ + tv.tv_sec = floor(FG(default_socket_timeout)); + tv.tv_usec = (1000000.0 * (FG(default_socket_timeout) - floor(FG(default_socket_timeout))) ); /* wait for data */ switch (select(curlstream->maxfd + 1, &curlstream->readfds, &curlstream->writefds, &curlstream->excfds, &tv)) { diff -Naur php-src-orig/ext/ftp/ftp.c php-src/ext/ftp/ftp.c --- php-src-orig/ext/ftp/ftp.c 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/ftp/ftp.c 2005-12-22 10:52:57.000000000 -0500 @@ -121,7 +121,7 @@ /* {{{ ftp_open */ ftpbuf_t* -ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC) +ftp_open(const char *host, short port, double timeout_sec TSRMLS_DC) { ftpbuf_t *ftp; socklen_t size; @@ -131,8 +131,8 @@ /* alloc the ftp structure */ ftp = ecalloc(1, sizeof(*ftp)); - tv.tv_sec = timeout_sec; - tv.tv_usec = 0; + tv.tv_sec = floor(timeout_sec); + tv.tv_usec = (1000000.0 * (timeout_sec-floor(timeout_sec)) ); ftp->fd = php_network_connect_socket_to_host(host, (unsigned short) (port ? port : 21), SOCK_STREAM, @@ -1229,7 +1229,7 @@ size = len; while (size) { - n = php_pollfd_for_ms(s, POLLOUT, ftp->timeout_sec * 1000); + n = php_pollfd_for_ms(s, POLLOUT, ftp->timeout_sec * 1000.0); if (n < 1) { @@ -1271,7 +1271,7 @@ { int n, nr_bytes; - n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000); + n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000.0); if (n < 1) { #if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) { @@ -1344,7 +1344,7 @@ { int n; - n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000); + n = php_pollfd_for_ms(s, PHP_POLLREADABLE, ftp->timeout_sec * 1000.0); if (n < 1) { #if !defined(PHP_WIN32) && !(defined(NETWARE) && defined(USE_WINSOCK)) if (n == 0) { @@ -1398,8 +1398,8 @@ /* connect */ /* Win 95/98 seems not to like size > sizeof(sockaddr_in) */ size = php_sockaddr_size(&ftp->pasvaddr); - tv.tv_sec = ftp->timeout_sec; - tv.tv_usec = 0; + tv.tv_sec = floor(ftp->timeout_sec); + tv.tv_usec = (1000000.0 * (ftp->timeout_sec - floor(ftp->timeout_sec)) ); if (php_connect_nonb(fd, (struct sockaddr*) &ftp->pasvaddr, size, &tv) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "php_connect_nonb() failed: %s (%d)", strerror(errno), errno); goto bail; diff -Naur php-src-orig/ext/ftp/ftp.h php-src/ext/ftp/ftp.h --- php-src-orig/ext/ftp/ftp.h 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/ftp/ftp.h 2005-12-22 10:53:41.000000000 -0500 @@ -29,8 +29,8 @@ #include #endif -#define FTP_DEFAULT_TIMEOUT 90 -#define FTP_DEFAULT_AUTOSEEK 1 +#define FTP_DEFAULT_TIMEOUT 90.0 +#define FTP_DEFAULT_AUTOSEEK 1 #define PHP_FTP_FAILED 0 #define PHP_FTP_FINISHED 1 #define PHP_FTP_MOREDATA 2 @@ -69,7 +69,7 @@ ftptype_t type; /* current transfer type */ int pasv; /* 0=off; 1=pasv; 2=ready */ php_sockaddr_storage pasvaddr; /* passive mode address */ - long timeout_sec; /* User configureable timeout (seconds) */ + double timeout_sec; /* User configureable timeout (seconds) */ int autoseek; /* User configureable autoseek flag */ int nb; /* "nonblocking" transfer in progress */ @@ -93,7 +93,7 @@ /* open a FTP connection, returns ftpbuf (NULL on error) * port is the ftp port in network byte order, or 0 for the default */ -ftpbuf_t* ftp_open(const char *host, short port, long timeout_sec TSRMLS_DC); +ftpbuf_t* ftp_open(const char *host, short port, double timeout_sec TSRMLS_DC); /* quits from the ftp session (it still needs to be closed) * return true on success, false on error diff -Naur php-src-orig/ext/ftp/php_ftp.c php-src/ext/ftp/php_ftp.c --- php-src-orig/ext/ftp/php_ftp.c 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/ftp/php_ftp.c 2005-12-22 10:49:30.000000000 -0500 @@ -123,7 +123,7 @@ REGISTER_LONG_CONSTANT("FTP_BINARY", FTPTYPE_IMAGE, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("FTP_IMAGE", FTPTYPE_IMAGE, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("FTP_AUTORESUME", PHP_FTP_AUTORESUME, CONST_PERSISTENT | CONST_CS); - REGISTER_LONG_CONSTANT("FTP_TIMEOUT_SEC", PHP_FTP_OPT_TIMEOUT_SEC, CONST_PERSISTENT | CONST_CS); + REGISTER_DOUBLE_CONSTANT("FTP_TIMEOUT_SEC", PHP_FTP_OPT_TIMEOUT_SEC, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("FTP_AUTOSEEK", PHP_FTP_OPT_AUTOSEEK, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("FTP_FAILED", PHP_FTP_FAILED, CONST_PERSISTENT | CONST_CS); REGISTER_LONG_CONSTANT("FTP_FINISHED", PHP_FTP_FINISHED, CONST_PERSISTENT | CONST_CS); @@ -147,7 +147,7 @@ } -/* {{{ proto resource ftp_connect(string host [, int port [, int timeout]]) +/* {{{ proto resource ftp_connect(string host [, int port [, double timeout]]) Opens a FTP stream */ PHP_FUNCTION(ftp_connect) { @@ -155,14 +155,14 @@ char *host; int host_len; long port = 0; - long timeout_sec = FTP_DEFAULT_TIMEOUT; + double timeout_sec = FTP_DEFAULT_TIMEOUT; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ld", &host, &host_len, &port, &timeout_sec) == FAILURE) { return; } - if (timeout_sec <= 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timeout has to be greater than 0"); + if (timeout_sec <= 0.0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timeout has to be greater than 0.0"); RETURN_FALSE; } @@ -183,7 +183,7 @@ /* }}} */ #if HAVE_OPENSSL_EXT -/* {{{ proto resource ftp_ssl_connect(string host [, int port [, int timeout]]) +/* {{{ proto resource ftp_ssl_connect(string host [, int port [, double timeout]]) Opens a FTP-SSL stream */ PHP_FUNCTION(ftp_ssl_connect) { @@ -191,9 +191,9 @@ char *host; int host_len; long port = 0; - long timeout_sec = FTP_DEFAULT_TIMEOUT; + double timeout_sec = FTP_DEFAULT_TIMEOUT; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ll", &host, &host_len, &port, &timeout_sec) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ld", &host, &host_len, &port, &timeout_sec) == FAILURE) { return; } @@ -1184,16 +1184,16 @@ switch (option) { case PHP_FTP_OPT_TIMEOUT_SEC: - if (Z_TYPE_P(z_value) != IS_LONG) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option TIMEOUT_SEC expects value of type long, %s given", + if (Z_TYPE_P(z_value) != IS_DOUBLE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option TIMEOUT_SEC expects value of type double, %s given", zend_zval_type_name(z_value)); RETURN_FALSE; } - if (Z_LVAL_P(z_value) <= 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timeout has to be greater than 0"); + if (Z_DVAL_P(z_value) <= 0.0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Timeout has to be greater than 0.0"); RETURN_FALSE; } - ftp->timeout_sec = Z_LVAL_P(z_value); + ftp->timeout_sec = Z_DVAL_P(z_value); RETURN_TRUE; break; case PHP_FTP_OPT_AUTOSEEK: @@ -1229,7 +1229,7 @@ switch (option) { case PHP_FTP_OPT_TIMEOUT_SEC: - RETURN_LONG(ftp->timeout_sec); + RETURN_DOUBLE(ftp->timeout_sec); break; case PHP_FTP_OPT_AUTOSEEK: RETURN_BOOL(ftp->autoseek); diff -Naur php-src-orig/ext/imap/php_imap.c php-src/ext/imap/php_imap.c --- php-src-orig/ext/imap/php_imap.c 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/imap/php_imap.c 2005-12-22 11:02:59.000000000 -0500 @@ -426,7 +426,8 @@ PHP_MINIT_FUNCTION(imap) { unsigned long sa_all = SA_MESSAGES | SA_RECENT | SA_UNSEEN | SA_UIDNEXT | SA_UIDVALIDITY; - + double timeout = FG(default_socket_timeout); + ZEND_INIT_MODULE_GLOBALS(imap, php_imap_init_globals, NULL) #ifndef PHP_WIN32 @@ -460,17 +461,17 @@ /* lets allow NIL */ REGISTER_LONG_CONSTANT("NIL", NIL, CONST_PERSISTENT | CONST_CS); - /* set default timeout values */ - mail_parameters(NIL, SET_OPENTIMEOUT, (void *) FG(default_socket_timeout)); - mail_parameters(NIL, SET_READTIMEOUT, (void *) FG(default_socket_timeout)); - mail_parameters(NIL, SET_WRITETIMEOUT, (void *) FG(default_socket_timeout)); - mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) FG(default_socket_timeout)); + /* set default timeout values - use only second part */ + mail_parameters(NIL, SET_OPENTIMEOUT, (void *) timeout); + mail_parameters(NIL, SET_READTIMEOUT, (void *) timeout); + mail_parameters(NIL, SET_WRITETIMEOUT, (void *) timeout); + mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) timeout); /* timeout constants */ - REGISTER_LONG_CONSTANT("IMAP_OPENTIMEOUT", 1, CONST_PERSISTENT | CONST_CS); - REGISTER_LONG_CONSTANT("IMAP_READTIMEOUT", 2, CONST_PERSISTENT | CONST_CS); - REGISTER_LONG_CONSTANT("IMAP_WRITETIMEOUT", 3, CONST_PERSISTENT | CONST_CS); - REGISTER_LONG_CONSTANT("IMAP_CLOSETIMEOUT", 4, CONST_PERSISTENT | CONST_CS); + REGISTER_DOUBLE_CONSTANT("IMAP_OPENTIMEOUT", 1, CONST_PERSISTENT | CONST_CS); + REGISTER_DOUBLE_CONSTANT("IMAP_READTIMEOUT", 2, CONST_PERSISTENT | CONST_CS); + REGISTER_DOUBLE_CONSTANT("IMAP_WRITETIMEOUT", 3, CONST_PERSISTENT | CONST_CS); + REGISTER_DOUBLE_CONSTANT("IMAP_CLOSETIMEOUT", 4, CONST_PERSISTENT | CONST_CS); /* Open Options */ @@ -4089,18 +4090,19 @@ } /* }}} */ -/* {{{ proto mixed imap_timeout(int timeout_type [, int timeout]) +/* {{{ proto mixed imap_timeout(int timeout_type [, double timeout]) Set or fetch imap timeout */ PHP_FUNCTION(imap_timeout) { - long ttype, timeout=-1; + long ttype; + double timeout = -1.0; int timeout_type; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &ttype, &timeout) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|d", &ttype, &timeout) == FAILURE) { RETURN_FALSE; } - if (timeout == -1) { + if (timeout < 0.0) { switch (ttype) { case 1: timeout_type = GET_OPENTIMEOUT; @@ -4119,9 +4121,9 @@ break; } - timeout = (long) mail_parameters(NIL, timeout_type, NIL); - RETURN_LONG(timeout); - } else if (timeout >= 0) { + timeout = (double) mail_parameters(NIL, timeout_type, NIL); + RETURN_DOUBLE(timeout); + } else if (timeout >= 0.0) { switch (ttype) { case 1: timeout_type = SET_OPENTIMEOUT; @@ -4140,7 +4142,7 @@ break; } - timeout = (long) mail_parameters(NIL, timeout_type, (void *) timeout); + timeout = (double) mail_parameters(NIL, timeout_type, (void *) timeout); RETURN_TRUE; } else { RETURN_FALSE; diff -Naur php-src-orig/ext/openssl/xp_ssl.c php-src/ext/openssl/xp_ssl.c --- php-src-orig/ext/openssl/xp_ssl.c 2005-12-22 09:17:42.000000000 -0500 +++ php-src/ext/openssl/xp_ssl.c 2005-12-22 10:41:53.000000000 -0500 @@ -517,8 +517,8 @@ if (value == -1) { if (sslsock->s.timeout.tv_sec == -1) { - tv.tv_sec = FG(default_socket_timeout); - tv.tv_usec = 0; + tv.tv_sec = floor(FG(default_socket_timeout)); + tv.tv_usec = (1000000.0 * (FG(default_socket_timeout) - floor(FG(default_socket_timeout))) ); } else { tv = sslsock->s.timeout; } @@ -678,8 +678,8 @@ memset(sslsock, 0, sizeof(*sslsock)); sslsock->s.is_blocked = 1; - sslsock->s.timeout.tv_sec = FG(default_socket_timeout); - sslsock->s.timeout.tv_usec = 0; + sslsock->s.timeout.tv_sec = floor(FG(default_socket_timeout)); + sslsock->s.timeout.tv_usec = (1000000.0 * (FG(default_socket_timeout) - floor(FG(default_socket_timeout))) ); /* we don't know the socket until we have determined if we are binding or * connecting */ diff -Naur php-src-orig/ext/soap/php_http.c php-src/ext/soap/php_http.c --- php-src-orig/ext/soap/php_http.c 2005-12-22 09:17:40.000000000 -0500 +++ php-src/ext/soap/php_http.c 2005-12-22 09:37:18.000000000 -0500 @@ -129,11 +129,12 @@ host = phpurl->host; port = phpurl->port; } + if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_connection_timeout", sizeof("_connection_timeout"), (void **) &tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) { - tv.tv_sec = Z_LVAL_PP(tmp); - tv.tv_usec = 0; - timeout = &tv; + Z_TYPE_PP(tmp) == IS_DOUBLE && Z_DVAL_PP(tmp) > 0.0) { + tv.tv_sec = floor(Z_DVAL_PP(tmp)); + tv.tv_usec = (1000000.0*(Z_DVAL_PP(tmp)-floor(Z_DVAL_PP(tmp)))); + timeout = &tv; } old_error_reporting = EG(error_reporting); diff -Naur php-src-orig/ext/soap/soap.c php-src/ext/soap/soap.c --- php-src-orig/ext/soap/soap.c 2005-12-22 09:17:41.000000000 -0500 +++ php-src/ext/soap/soap.c 2005-12-22 09:36:21.000000000 -0500 @@ -2190,8 +2190,8 @@ } if (zend_hash_find(ht, "connection_timeout", sizeof("connection_timeout"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_LONG && Z_LVAL_PP(tmp) > 0) { - add_property_long(this_ptr, "_connection_timeout", Z_LVAL_PP(tmp)); + Z_TYPE_PP(tmp) == IS_DOUBLE && Z_DVAL_PP(tmp) > 0.0) { + add_property_double(this_ptr, "_connection_timeout", Z_DVAL_PP(tmp)); } if (context) { diff -Naur php-src-orig/ext/standard/file.c php-src/ext/standard/file.c --- php-src-orig/ext/standard/file.c 2005-12-22 09:17:42.000000000 -0500 +++ php-src/ext/standard/file.c 2005-12-22 09:52:52.000000000 -0500 @@ -172,7 +172,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("user_agent", NULL, PHP_INI_ALL, OnUpdateString, user_agent, php_file_globals, file_globals) - STD_PHP_INI_ENTRY("default_socket_timeout", "60", PHP_INI_ALL, OnUpdateLong, default_socket_timeout, php_file_globals, file_globals) + STD_PHP_INI_ENTRY("default_socket_timeout", "60.0", PHP_INI_ALL, OnUpdateReal, default_socket_timeout, php_file_globals, file_globals) STD_PHP_INI_ENTRY("auto_detect_line_endings", "0", PHP_INI_ALL, OnUpdateLong, auto_detect_line_endings, php_file_globals, file_globals) PHP_INI_END() diff -Naur php-src-orig/ext/standard/file.h php-src/ext/standard/file.h --- php-src-orig/ext/standard/file.h 2005-12-22 09:17:42.000000000 -0500 +++ php-src/ext/standard/file.h 2005-12-22 09:47:55.000000000 -0500 @@ -110,7 +110,7 @@ int pclose_ret; size_t def_chunk_size; long auto_detect_line_endings; - long default_socket_timeout; + double default_socket_timeout; char *user_agent; char *user_stream_current_filename; /* for simple recursion protection */ php_stream_context *default_context; diff -Naur php-src-orig/main/network.c php-src/main/network.c --- php-src-orig/main/network.c 2005-12-22 09:17:43.000000000 -0500 +++ php-src/main/network.c 2005-12-22 09:41:34.000000000 -0500 @@ -983,8 +983,8 @@ memset(sock, 0, sizeof(php_netstream_data_t)); sock->is_blocked = 1; - sock->timeout.tv_sec = FG(default_socket_timeout); - sock->timeout.tv_usec = 0; + sock->timeout.tv_sec = floor(FG(default_socket_timeout)); + sock->timeout.tv_usec = (1000000.0 * (FG(default_socket_timeout)-floor(FG(default_socket_timeout))) ); sock->socket = socket; stream = php_stream_alloc_rel(&php_stream_generic_socket_ops, sock, persistent_id, "r+"); diff -Naur php-src-orig/main/streams/transports.c php-src/main/streams/transports.c --- php-src-orig/main/streams/transports.c 2005-12-22 09:17:43.000000000 -0500 +++ php-src/main/streams/transports.c 2005-12-22 10:42:52.000000000 -0500 @@ -64,7 +64,8 @@ char *error_text = NULL; struct timeval default_timeout = { 0, 0 }; - default_timeout.tv_sec = FG(default_socket_timeout); + default_timeout.tv_sec = floor(FG(default_socket_timeout)); + default_timeout.tv_usec = (1000000.0 * (FG(default_socket_timeout) - floor(FG(default_socket_timeout))) ); if (timeout == NULL) { timeout = &default_timeout; diff -Naur php-src-orig/main/streams/xp_socket.c php-src/main/streams/xp_socket.c --- php-src-orig/main/streams/xp_socket.c 2005-12-22 09:17:43.000000000 -0500 +++ php-src/main/streams/xp_socket.c 2005-12-22 09:43:26.000000000 -0500 @@ -260,8 +260,8 @@ if (value == -1) { if (sock->timeout.tv_sec == -1) { - tv.tv_sec = FG(default_socket_timeout); - tv.tv_usec = 0; + tv.tv_sec = floor(FG(default_socket_timeout)); + tv.tv_usec = (1000000.0 * (FG(default_socket_timeout)-floor(FG(default_socket_timeout)))); } else { tv = sock->timeout; } @@ -769,8 +769,8 @@ memset(sock, 0, sizeof(php_netstream_data_t)); sock->is_blocked = 1; - sock->timeout.tv_sec = FG(default_socket_timeout); - sock->timeout.tv_usec = 0; + sock->timeout.tv_sec = floor(FG(default_socket_timeout)); + sock->timeout.tv_usec = (1000000.0 * (FG(default_socket_timeout)-floor(FG(default_socket_timeout)))); /* we don't know the socket until we have determined if we are binding or * connecting */