From: "Lin Jen-Shin (godfat)" <godfat-hOE/xeEBYYIdnm+yROfE0A@public.gmane.org>
To: "Rainbows! list" <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: negative timeout in Rainbows::Fiber::Base
Date: Fri, 24 Aug 2012 04:36:24 +0800 [thread overview]
Message-ID: <CAA2_N1unOXb7Z4Jr8oKoSLu266O9Ko4o=oWzAcMA1w3=9X74KA@mail.gmail.com> (raw)
Greetings Unicorns,
I am writing some stupid benchmarks, trying FiberSpawn and
FiberPool, and seeing this error:
listen loop error: time interval must be positive (ArgumentError)
Looking into the code, in this line:
http://bogomips.org/rainbows.git/tree/lib/rainbows/fiber/base.rb#n55
Isn't that possible `max <= (now + 1)` and `now > max`?
Whenever this is the case, then timeout passed to `select`
could be negative. I am not sure how to fix this correctly,
but a blind `abs` could resolve this error.
Hope this could give some hints, thank you!
commit b599374ef10c7847445f29f80e74cde3e4d3b940
Author: Lin Jen-Shin <godfat-hOE/xeEBYYIdnm+yROfE0A@public.gmane.org>
Date: Fri Aug 24 04:33:38 2012 +0800
fiber/base.rb: make timeout never be negative.
In the case where `max <= (now + 1)` and `now > max`,
we need to make sure that timeout is positive.
diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb
index 00af214..7bd43cb 100644
--- a/lib/rainbows/fiber/base.rb
+++ b/lib/rainbows/fiber/base.rb
@@ -52,7 +52,7 @@ module Rainbows::Fiber::Base
}
fibs.each { |fib| fib.resume }
now = Time.now
- max.nil? || max > (now + 1) ? 1 : max - now
+ max.nil? || max > (now + 1) ? 1 : (max - now).abs
end
def process(client)
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying
next reply other threads:[~2012-08-23 20:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-23 20:36 Lin Jen-Shin (godfat) [this message]
[not found] ` <CAA2_N1unOXb7Z4Jr8oKoSLu266O9Ko4o=oWzAcMA1w3=9X74KA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-25 2:45 ` negative timeout in Rainbows::Fiber::Base Eric Wong
[not found] ` <20120825024556.GA25977-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-08-26 0:12 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1uhfcHDbTvY+ke0Cid6=i7KEhFn8jvEirx+ptYVDacdvA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-26 1:15 ` Eric Wong
2012-08-29 16:00 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1thakAOVp7ibCNic+TjEVvXE0OGLgzXH3fJ1c2UTs68oQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-29 21:17 ` Eric Wong
[not found] ` <20120829211707.GA22726-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-08-30 21:33 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1tc=Xx8WHaM8H=EWshyzGEyX04PnkdBGj9Jdb7cSzmbRQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-31 1:37 ` Eric Wong
[not found] ` <20120831013731.GA16613-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-09-05 20:06 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1vfWXGw_CaaMWMijUSdMN2Pz882SYDtNEW2_6YWffgTKQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-05 23:27 ` Eric Wong
[not found] ` <20120905232739.GA25153-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-09-22 9:52 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1v460utbL31Qu-JbGuUxav1hY4X5+cEf=Mp2rOC5efzMw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-22 19:42 ` Eric Wong
[not found] ` <20120922194222.GA6839-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-09-28 15:14 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1usHJVZgn5n7RaTyDCbK7eu6G4ocZAsvqsVeL6cPERskw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-09-28 19:11 ` Eric Wong
[not found] ` <20120928191132.GA14292-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-09-28 19:24 ` Eric Wong
[not found] ` <20120928192449.GB14292-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2012-10-31 0:14 ` Lin Jen-Shin (godfat)
2012-12-18 11:09 ` Lin Jen-Shin (godfat)
[not found] ` <CAA2_N1tcA-HK20C8Ok1Lv9KWwMD4fctCOPHTLeD9ayRJqWby1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-18 19:19 ` Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://yhbt.net/rainbows/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA2_N1unOXb7Z4Jr8oKoSLu266O9Ko4o=oWzAcMA1w3=9X74KA@mail.gmail.com' \
--to=godfat-hoe/xeebyyidnm+yrofe0a@public.gmane.org \
--cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhbt.net/rainbows.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).