Skip to content

Commit

Permalink
enabled commented out debugging, preparing for a A/B test for IPv4 vs…
Browse files Browse the repository at this point in the history
… IPv6
  • Loading branch information
spikebike committed Oct 3, 2014
1 parent 5fb97dc commit 1c9a274
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions krpc.go
Expand Up @@ -83,7 +83,7 @@ func parseNodesString(nodes string,proto string) (parsed map[string]string) {
if len(nodes)%nodeContactLen > 0 {
log.V(3).Infof("DHT: Invalid length of nodes.")
log.V(3).Infof("DHT: Should be a multiple of %d, got %d", nodeContactLen, len(nodes))
fmt.Printf("%T %#v\n",nodes,nodes)
log.V(5).Infof("%T %#v\n",nodes,nodes)
return
}
for i := 0; i < len(nodes); i += nodeContactLen {
Expand Down Expand Up @@ -166,7 +166,7 @@ func sendMsg(conn *net.UDPConn, raddr net.UDPAddr, query interface{}) {
return
}
if n, err := conn.WriteToUDP(b.Bytes(), &raddr); err != nil {
// debug.Println("DHT: node write failed:", err)
log.V(3).Infof("DHT: node write failed:", err)
} else {
totalWrittenBytes.Add(int64(n))
}
Expand All @@ -178,14 +178,14 @@ func readResponse(p packetType) (response responseType, err error) {
// The calls to bencode.Unmarshal() can be fragile.
defer func() {
if x := recover(); x != nil {
// debug.Printf("DHT: !!! Recovering from panic() after bencode.Unmarshal %q, %v", string(p.b), x)
log.V(3).Infof("DHT: !!! Recovering from panic() after bencode.Unmarshal %q, %v", string(p.b), x)
}
}()
if e2 := bencode.Unmarshal(bytes.NewBuffer(p.b), &response); e2 == nil {
err = nil
return
} else {
// debug.Printf("DHT: unmarshal error, odd or partial data during UDP read? %v, err=%s", string(p.b), e2)
log.V(3).Infof("DHT: unmarshal error, odd or partial data during UDP read? %v, err=%s", string(p.b), e2)
return response, e2
}
return
Expand All @@ -211,11 +211,10 @@ type packetType struct {
}

func listen(addr string, listenPort int, proto string) (socket *net.UDPConn, err error) {
// debug.Printf("DHT: Listening for peers on port: %d\n", listenPort)
log.V(3).Infof("DHT: Listening for peers on IP: %s port: %d Protocol=%s\n", addr,listenPort,proto)
listener, err := net.ListenPacket(proto, addr+":"+strconv.Itoa(listenPort))
if err != nil {
// debug.Println("DHT: Listen failed:", err)
log.V(3).Infof("DHT: Listen failed:", err)
}
if listener != nil {
socket = listener.(*net.UDPConn)
Expand All @@ -228,9 +227,12 @@ func readFromSocket(socket *net.UDPConn, conChan chan packetType, bytesArena are
for {
b := bytesArena.Pop()
n, addr, err := socket.ReadFromUDP(b)
if err != nil {
log.V(3).Infof("DHT: readResponse error:", err)
}
b = b[0:n]
if n == maxUDPPacketSize {
// debug.Printf("DHT: Warning. Received packet with len >= %d, some data may have been discarded.\n", maxUDPPacketSize)
log.V(3).Infof("DHT: Warning. Received packet with len >= %d, some data may have been discarded.\n", maxUDPPacketSize)
}
totalReadBytes.Add(int64(n))
if n > 0 && err == nil {
Expand All @@ -242,8 +244,6 @@ func readFromSocket(socket *net.UDPConn, conChan chan packetType, bytesArena are
return
}
}
// debug.Println("DHT: readResponse error:", err)

// Do a non-blocking read of the stop channel and stop this goroutine if the channel
// has been closed.
select {
Expand Down
4 changes: 2 additions & 2 deletions routing.go
Expand Up @@ -213,8 +213,8 @@ func (n *nTree) isOK(ih InfoHash) bool {
r := n.value

if len(r.pendingQueries) > maxNodePendingQueries {
// debug.Println("DHT: Skipping because there are too many queries pending for this dude.")
// debug.Println("DHT: This shouldn't happen because we should have stopped trying already. Might be a BUG.")
log.V(3).Infof("DHT: Skipping because there are too many queries pending for this dude.")
log.V(3).Infof("DHT: This shouldn't happen because we should have stopped trying already. Might be a BUG.")
return false
}

Expand Down

0 comments on commit 1c9a274

Please sign in to comment.