[#5219] Segmentation fault in timeout.rb — Michel Pastor <K@...>

Hi,

18 messages 2005/06/16
[#5220] Re: Segmentation fault in timeout.rb — Eric Hodel <drbrain@...7.net> 2005/06/16

[#5221] Re: Segmentation fault in timeout.rb — Michel Pastor <K@...> 2005/06/16

On Fri, 17 Jun 2005 05:03:18 +0900

[#5223] Re: Segmentation fault in timeout.rb — nobu.nokada@... 2005/06/17

Hi,

[#5296] Subversion — Shugo Maeda <shugo@...>

Hi,

64 messages 2005/06/30
[#5297] Re: Subversion — Curt Hibbs <curt@...> 2005/06/30

Shugo Maeda wrote:

[#5298] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/06/30

Curt Hibbs wrote:

[#5301] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, Nikolai Weibull

[#5304] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/06/30

Austin Ziegler wrote:

[#5305] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, Nikolai Weibull

[#5307] Re: Subversion — mathew <meta@...> 2005/06/30

Austin Ziegler wrote:

[#5308] Re: Subversion — Austin Ziegler <halostatue@...> 2005/06/30

On 6/30/05, mathew <meta@pobox.com> wrote:

[#5311] Re: Subversion — mathew <meta@...> 2005/07/01

Austin Ziegler wrote:

[#5323] Re: Subversion — Austin Ziegler <halostatue@...> 2005/07/01

On 7/1/05, mathew <meta@pobox.com> wrote:

[#5325] Re: Subversion — Nikolai Weibull <mailing-lists.ruby-core@...> 2005/07/01

Austin Ziegler wrote:

[PATCH] Resolv and TTL

From: Eric Hodel <drbrain@...7.net>
Date: 2005-06-10 09:39:16 UTC
List: ruby-core #5190
I would like to retrieve the TTL values from Resolv, but they seem to  
get thrown away long before they're near the public API, and digging  
through the guts of Resolv::DNS would only result in much duplicate  
code.

The following patch adds #ttl to Resolv::DNS::Resource.  I also  
changed #== and #hash because the TTL changes every time a new  
resource is requested.


-- 
Eric Hodel - drbrain@segment7.net - http://segment7.net
FEC2 57F1 D465 EB15 5D6E  7C11 332A 551C 796C 9F04

Index: lib/resolv.rb
===================================================================
RCS file: /src/ruby/lib/resolv.rb,v
retrieving revision 1.29
diff -u -r1.29 resolv.rb
--- lib/resolv.rb       9 Jun 2005 22:47:35 -0000       1.29
+++ lib/resolv.rb       10 Jun 2005 08:57:09 -0000
@@ -1406,7 +1406,10 @@
            name = self.get_name
            type, klass, ttl = self.get_unpack('nnN')
            typeclass = Resource.get_class(type, klass)
-          return name, ttl, self.get_length16 {typeclass.decode_rdata 
(self)}
+          res = self.get_length16 { typeclass.decode_rdata self }
+          res.instance_variable_set :@ttl, ttl
+
+          return name, ttl, res
          end
        end
      end
@@ -1429,6 +1432,11 @@

      class Resource < Query

+      ##
+      # Remaining Time To Live for this Resource.
+
+      attr_reader :ttl
+
        ClassHash = {} # :nodoc:

        def encode_rdata(msg) # :nodoc:
@@ -1440,10 +1448,13 @@
        end

        def ==(other) # :nodoc:
-        return self.class == other.class &&
-          self.instance_variables == other.instance_variables &&
-          self.instance_variables.collect {|name| self.instance_eval  
name} ==
-            other.instance_variables.collect {|name|  
other.instance_eval name}
+        return false unless self.class == other.class
+        s_ivars = self.instance_variables.reject { |name| name ==  
"@ttl" }
+        o_ivars = other.instance_variables.reject { |name| name ==  
"@ttl" }
+
+        return s_ivars == o_ivars &&
+          s_ivars.collect {|name| self.instance_eval name} ==
+            o_ivars.collect {|name| other.instance_eval name}
        end

        def eql?(other) # :nodoc:
@@ -1452,7 +1463,7 @@

        def hash # :nodoc:
          h = 0
-        self.instance_variables.each {|name|
+        self.instance_variables.reject { |name| name ==  
"@ttl" }.each {|name|
            h ^= self.instance_eval("#{name}.hash")
          }
          return h



In This Thread

Prev Next