Skip to content

Commit

Permalink
More debug logs and fixes on setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Nov 26, 2019
1 parent 2ade0f9 commit bcfe394
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ func listenLoop() {
}

for {
log.Println("Accepting skychat conn...")
conn, err := l.Accept()
if err != nil {
log.Println("Failed to accept conn:", err)
Expand All @@ -90,6 +91,7 @@ func listenLoop() {
connsMu.Lock()
chatConns[raddr.PubKey] = conn
connsMu.Unlock()
log.Printf("Accepted skychat conn on %s from %s\n", conn.LocalAddr(), raddr.PubKey)

go handleConn(conn)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/router/route_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func NewRouteGroup(cfg *RouteGroupConfig, rt routing.Table, desc routing.RouteDe
// just in case the read buffer is short.
func (r *RouteGroup) Read(p []byte) (n int, err error) {
if r.readTimedOut.IsSet() {
r.logger.Infoln("TIMEOUT ERROR?")
return 0, timeoutError{}
}

Expand All @@ -126,21 +127,27 @@ func (r *RouteGroup) Read(p []byte) (n int, err error) {

r.mu.Lock()
if r.readBuf.Len() > 0 {
r.logger.Infoln("BLOCKING BEFORE BUF READ")
data, err := r.readBuf.Read(p)
r.logger.Infoln("GOT SOME FROM BUF READ")
r.mu.Unlock()

return data, err
}
r.mu.Unlock()

r.logger.Infoln("BLOCKING BEFORE READ CHAN")
data, ok := <-r.readCh
if !ok {
r.logger.Infof("COULDN'T READ DATA")
return 0, io.ErrClosedPipe
}

r.mu.Lock()
defer r.mu.Unlock()

r.logger.Infof("READ DATA FROM CHAN: %s", data)

return ioutil.BufRead(&r.readBuf, data, p)
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,15 @@ func (r *router) handleDataPacket(ctx context.Context, packet routing.Packet) er
}

r.logger.Infof("Got new remote packet with route ID %d. Using rule: %s", packet.RouteID(), rule)
r.logger.Infof("Packet contents: %s", packet.Payload())

// TODO: maybe move this up along the execution flow? `rg` doesn't seem to be necessary here
if t := rule.Type(); t == routing.RuleForward {
return r.forwardPacket(ctx, packet.Payload(), rule)
}

if rg.isClosed() {
r.logger.Infoln("RG IS CLOSED")
return io.ErrClosedPipe
}

Expand All @@ -355,8 +357,10 @@ func (r *router) handleDataPacket(ctx context.Context, packet routing.Packet) er

select {
case <-rg.done:
r.logger.Infof("RG IS DONE")
return io.ErrClosedPipe
case rg.readCh <- packet.Payload():
r.logger.Infof("PUT PAYLOAD INTO RG READ CHAN")
return nil
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/setup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net/rpc"
"sync"

"github.com/SkycoinProject/dmsg/cipher"

"github.com/SkycoinProject/dmsg"
"github.com/SkycoinProject/dmsg/disc"
"github.com/SkycoinProject/skycoin/src/util/logging"
Expand Down Expand Up @@ -162,7 +164,7 @@ func (sn *Node) handleDialRouteGroup(ctx context.Context, route routing.Bidirect
Reverse: consumeRules[route.Desc.SrcPK()],
}
respRouteRules := routing.EdgeRules{
Desc: forwardRoute.Desc,
Desc: routing.NewRouteDescriptor(cipher.PubKey{}, forwardRoute.Desc.DstPK(), forwardRoute.Desc.SrcPort(), forwardRoute.Desc.DstPort()),
Forward: forwardRules[route.Desc.DstPK()],
Reverse: consumeRules[route.Desc.DstPK()],
}
Expand Down

0 comments on commit bcfe394

Please sign in to comment.