Skip to content
This repository
Browse code

Merge pull request #211 from phiggins/fix_warnings

Fix indentation warnings in EM::DNS::Resolver.
  • Loading branch information...
commit 61239dd386cc2a0f8280e300e990ac4c316a5d05 2 parents 5fc6fdb + 3f7ae87
Aman Gupta authored May 23, 2011

Showing 1 changed file with 64 additions and 64 deletions. Show diff stats Hide diff stats

  1. 128  lib/em/resolver.rb
128  lib/em/resolver.rb
@@ -105,88 +105,88 @@ def receive_data(data)
105 105
         begin
106 106
           msg = Resolv::DNS::Message.decode data
107 107
         rescue
108  
-          else
109  
-            req = @requests[msg.id]
110  
-            if req
111  
-              @requests.delete(msg.id)
112  
-              req.receive_answer(msg)
113  
-            end
  108
+        else
  109
+          req = @requests[msg.id]
  110
+          if req
  111
+            @requests.delete(msg.id)
  112
+            req.receive_answer(msg)
114 113
           end
115 114
         end
116 115
       end
  116
+    end
117 117
 
118  
-      class Request
119  
-        include Deferrable
120  
-        attr_accessor :retry_interval, :max_tries
  118
+    class Request
  119
+      include Deferrable
  120
+      attr_accessor :retry_interval, :max_tries
121 121
 
122  
-        def initialize(socket, hostname)
123  
-          @socket = socket
124  
-          @hostname = hostname
125  
-          @tries = 0
126  
-          @last_send = Time.at(0)
127  
-          @retry_interval = 3
128  
-          @max_tries = 5
  122
+      def initialize(socket, hostname)
  123
+        @socket = socket
  124
+        @hostname = hostname
  125
+        @tries = 0
  126
+        @last_send = Time.at(0)
  127
+        @retry_interval = 3
  128
+        @max_tries = 5
129 129
 
130  
-          if addrs = Resolver.hosts[hostname]
131  
-            succeed addrs
132  
-          else
133  
-            EM.next_tick { tick }
134  
-          end
  130
+        if addrs = Resolver.hosts[hostname]
  131
+          succeed addrs
  132
+        else
  133
+          EM.next_tick { tick }
135 134
         end
  135
+      end
136 136
 
137  
-        def tick
138  
-          # Break early if nothing to do
139  
-          return if @last_send + @retry_interval > Time.now
140  
-          if @tries < @max_tries
141  
-            send
142  
-          else
143  
-            fail 'retries exceeded'
144  
-          end
  137
+      def tick
  138
+        # Break early if nothing to do
  139
+        return if @last_send + @retry_interval > Time.now
  140
+        if @tries < @max_tries
  141
+          send
  142
+        else
  143
+          fail 'retries exceeded'
145 144
         end
  145
+      end
146 146
 
147  
-        def receive_answer(msg)
148  
-          addrs = []
149  
-          msg.each_answer do |name,ttl,data|
150  
-            if data.kind_of?(Resolv::DNS::Resource::IN::A) ||
151  
-                data.kind_of?(Resolv::DNS::Resource::IN::AAAA)
152  
-              addrs << data.address.to_s
153  
-            end
  147
+      def receive_answer(msg)
  148
+        addrs = []
  149
+        msg.each_answer do |name,ttl,data|
  150
+          if data.kind_of?(Resolv::DNS::Resource::IN::A) ||
  151
+              data.kind_of?(Resolv::DNS::Resource::IN::AAAA)
  152
+            addrs << data.address.to_s
154 153
           end
  154
+        end
155 155
 
156  
-          if addrs.empty?
157  
-            fail "rcode=#{msg.rcode}"
158  
-          else
159  
-            succeed addrs
160  
-          end
  156
+        if addrs.empty?
  157
+          fail "rcode=#{msg.rcode}"
  158
+        else
  159
+          succeed addrs
161 160
         end
  161
+      end
162 162
 
163  
-        private
  163
+      private
164 164
 
165  
-          def send
166  
-            @tries += 1
167  
-            @last_send = Time.now
168  
-            @socket.send_packet(packet.encode)
169  
-          end
  165
+        def send
  166
+          @tries += 1
  167
+          @last_send = Time.now
  168
+          @socket.send_packet(packet.encode)
  169
+        end
170 170
 
171  
-          def id
172  
-            begin
173  
-              @id = rand(65535)
174  
-              @socket.register_request(@id, self)
175  
-            rescue RequestIdAlreadyUsed
176  
-              retry
177  
-            end unless defined?(@id)
  171
+        def id
  172
+          begin
  173
+            @id = rand(65535)
  174
+            @socket.register_request(@id, self)
  175
+          rescue RequestIdAlreadyUsed
  176
+            retry
  177
+          end unless defined?(@id)
178 178
 
179  
-            @id
180  
-          end
  179
+          @id
  180
+        end
181 181
 
182  
-          def packet
183  
-            msg = Resolv::DNS::Message.new
184  
-            msg.id = id
185  
-            msg.rd = 1
186  
-            msg.add_question @hostname, Resolv::DNS::Resource::IN::A
187  
-            msg
188  
-          end
  182
+        def packet
  183
+          msg = Resolv::DNS::Message.new
  184
+          msg.id = id
  185
+          msg.rd = 1
  186
+          msg.add_question @hostname, Resolv::DNS::Resource::IN::A
  187
+          msg
  188
+        end
189 189
 
190  
-      end
191 190
     end
192 191
   end
  192
+end

0 notes on commit 61239dd

Please sign in to comment.
Something went wrong with that request. Please try again.