summaryrefslogtreecommitdiff
path: root/ext/sockets
diff options
context:
space:
mode:
authorJason Greene <jason@php.net>2003-07-22 07:20:55 +0000
committerJason Greene <jason@php.net>2003-07-22 07:20:55 +0000
commit7eea6525a795fc7372384bb05270dbd65ed308d9 (patch)
treeec5035b53062bd29dfa2ac459d4dc2f1d8a3e752 /ext/sockets
parent1e92b5e7a36dbd8f1627328d87c51401632b5487 (diff)
downloadphp-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
Diffstat (limited to 'ext/sockets')
-rw-r--r--ext/sockets/sockets.c12
1 files changed, 10 insertions, 2 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) {