diff options
author | Jason Greene <jason@php.net> | 2003-07-22 07:20:55 +0000 |
---|---|---|
committer | Jason Greene <jason@php.net> | 2003-07-22 07:20:55 +0000 |
commit | 7eea6525a795fc7372384bb05270dbd65ed308d9 (patch) | |
tree | ec5035b53062bd29dfa2ac459d4dc2f1d8a3e752 | |
parent | 1e92b5e7a36dbd8f1627328d87c51401632b5487 (diff) | |
download | php-git-7eea6525a795fc7372384bb05270dbd65ed308d9.tar.gz |
Fix EINVAL errors for OS's (Solaris + BSD) that do not appreciate microseconds >= 1 second
Patch submitted from meebery@php.net
-rw-r--r-- | ext/sockets/sockets.c | 12 | ||||
-rw-r--r-- | ext/standard/streamsfuncs.c | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index 9b1d3ad0d8..c45ff687f2 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -641,8 +641,16 @@ PHP_FUNCTION(socket_select) 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 > 999999) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 1000000); + tv.tv_usec = usec % 1000000; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = &tv; if (sec == &tmp) { diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 74d7701d2d..e6db9e8138 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -563,8 +563,16 @@ PHP_FUNCTION(stream_select) /* 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 > 999999) { + tv.tv_sec = Z_LVAL_P(sec) + (usec / 1000000); + tv.tv_usec = usec % 1000000; + } else { + tv.tv_sec = Z_LVAL_P(sec); + tv.tv_usec = usec; + } + tv_p = &tv; } |