summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-23 12:18:44 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-23 12:18:44 +0000
commitef8f24d06ebb9a4c4964d265d9be459249efc9ac (patch)
tree59cdbb9b0192c261e73ef9677165619404380e5d /thread.c
parente7ec68a456b57365e32cb519a48287ecd6dcca04 (diff)
merges r27930 from trunk into ruby_1_9_2.
-- * thread.c (subtract_tv): if the rest is zero, should finish waiting immediately. * win32/win32.c (subtract): ditto. based on a patch from Roger Pack in [ruby-core:27957]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@27975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/thread.c b/thread.c
index f6b3b67df4..1956721da7 100644
--- a/thread.c
+++ b/thread.c
@@ -2411,6 +2411,9 @@ cmp_tv(const struct timeval *a, const struct timeval *b)
static int
subtract_tv(struct timeval *rest, const struct timeval *wait)
{
+ if (rest->tv_sec < wait->tv_sec) {
+ return 0;
+ }
while (rest->tv_usec < wait->tv_usec) {
if (rest->tv_sec <= wait->tv_sec) {
return 0;
@@ -2420,7 +2423,7 @@ subtract_tv(struct timeval *rest, const struct timeval *wait)
}
rest->tv_sec -= wait->tv_sec;
rest->tv_usec -= wait->tv_usec;
- return 1;
+ return rest->tv_sec != 0 || rest->tv_usec != 0;
}
#endif