diff options
-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; } |