AsyncDNS-cr  Check-in [e71ccf3e48]

Overview
Comment:Fix leftover IO and missing rescue
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e71ccf3e48515c4f0688d89a4f7f0e523d084717a26bda20d5180091b4af2766
User & Date: js on 2021-03-06 22:28:08
Other Links: manifest | tags
Context
2021-03-06
22:36
Read everything in handle_packet via IO Leaf check-in: 86ae1b8057 user: js tags: trunk
22:28
Fix leftover IO and missing rescue check-in: e71ccf3e48 user: js tags: trunk
22:25
Initial response handling check-in: 7b363d4985 user: js tags: trunk
Changes

Modified src/resolver.cr from [aab61a4f26] to [b25ecb3e05].

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
139
140
141
142
143
144
145


146
147
148
149
150
151
152







-
-







          end
          handle_packet(buf[0, len], addr)
        end
      end
    end

    def handle_packet(packet : Bytes, sender : Socket::IPAddress) : Nil
      io = IO::Memory.new(packet, writeable: false)

      begin
        id = packet[0].to_u16 << 8 | packet[1]

        begin
          context = @queries[id]
        rescue KeyError
          return
209
210
211
212
213
214
215

216
217
218
219
220
221
222
223
224
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223







+










        io = IO::Memory.new(packet[4, packet.size - 4], writeable: false)
        qdcount = io.read_bytes(UInt16, IO::ByteFormat::BigEndian)
        adcount = io.read_bytes(UInt16, IO::ByteFormat::BigEndian)
        nscount = io.read_bytes(UInt16, IO::ByteFormat::BigEndian)
        arcount = io.read_bytes(UInt16, IO::ByteFormat::BigEndian)
      rescue IndexError
      rescue IO::EOFError
      end
    end

    def stop : Nil
      @v6_sock.try { |s| s.close }
      @v4_sock.try { |s| s.close }
    end
  end
end