summaryrefslogtreecommitdiff
path: root/ext/standard/streamsfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/streamsfuncs.c')
-rw-r--r--ext/standard/streamsfuncs.c12
1 files changed, 10 insertions, 2 deletions
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;
}