[#7872] Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...>

All, I needed a nonblocking socket connect for my asynchronous-event

18 messages 2006/05/14
[#7873] Re: Nonblocking socket-connect — Tanaka Akira <akr@...17n.org> 2006/05/14

In article <3a94cf510605140559l7baa0205le341dac4f47d424b@mail.gmail.com>,

[#7874] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

How about introducing the method Socket#set_nonblocking, or alternatively

[#7875] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

[#7876] Re: Nonblocking socket-connect — "Francis Cianfrocca" <garbagecat10@...> 2006/05/15

Well, it's ok then. I'm comfortable adding in the nonblocking

[#7877] Re: Nonblocking socket-connect — Yukihiro Matsumoto <matz@...> 2006/05/15

Hi,

Fwd: Bug: Time#-(1e-6) doesn't substract one microsecond.

From: Dave Burt <dave@...>
Date: 2006-05-17 15:01:59 UTC
List: ruby-core #7896
Hi,

The following minor patch proposal was recently posted on comp.lang.ruby.

Cheers,
Dave

-----Original Message-----
Subject: Bug: Time#-(1e-6) doesn't substract one microsecond.
From: Dmitry Maksyoma <ledestin@gmail.com>
Date: 17 May 2006 15:53
Newsgroups: comp.lang.ruby

Hello,

Please consider the following test:

t = Time.mktime(2006, 5, 1)
puts t, "sec: #{t.sec}, usec: #{t.usec}"
t2 = t - 1e-6
puts t2, "sec: #{t2.sec}, usec: #{t2.usec}"
t2 = t - 2e-6
puts t2, "sec: #{t2.sec}, usec: #{t2.usec}"

Mon May 01 00:00:00 NZST 2006
sec: 0, usec: 0
Mon May 01 00:00:00 NZST 2006
sec: 0, usec: 0
Sun Apr 30 23:59:59 NZST 2006
sec: 59, usec: 999999

Substracting one microsecond doesn't do anything, substracting 2
microseconds
actually substracts one microsecond.

The problem is that (time_t)1e-6*1e6 yields 0, so I changed it to
(time_t)lround(1e-6*1e6). This way the same Ruby code yields:

Mon May 01 00:00:00 NZST 2006
sec: 0, usec: 0
Sun Apr 30 23:59:59 NZST 2006
sec: 59, usec: 999999
Sun Apr 30 23:59:59 NZST 2006
sec: 59, usec: 999998

--- /home/dmaks/time.c  2006-05-16 19:50:35.000000000 +1200
+++ ruby-1.8.2/time.c   2006-05-17 13:29:50.000000000 +1200
@@ -1285,7 +1285,7 @@
     if (f != (double)sec_off)
         rb_raise(rb_eRangeError, "time %s %f out of Time range",
             sign < 0 ? "-" : "+", v);
-    usec_off = (time_t)(d*1e6);
+    usec_off = (time_t)lround(d*1e6);

     if (sign < 0) {
         sec = tobj->tv.tv_sec - sec_off;

Attachments (1)

In This Thread

Prev Next