Skip to content

Commit

Permalink
Even more debug logs. Fix skychat
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Nov 26, 2019
1 parent bcfe394 commit f11e065
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func main() {
log.Fatal("Setup failure: ", err)
}
defer a.Close()
log.Println("Successfully created skychat app")

chatApp = a

Expand Down Expand Up @@ -86,6 +87,7 @@ func listenLoop() {
log.Println("Failed to accept conn:", err)
return
}
log.Println("Accepted skychat conn")

raddr := conn.RemoteAddr().(appnet.Addr)
connsMu.Lock()
Expand Down
7 changes: 6 additions & 1 deletion pkg/app/appnet/skywire_networker.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,23 @@ func (r *SkywireNetworker) ListenContext(ctx context.Context, addr Addr) (net.Li
// serve accepts and serves routes.
func (r *SkywireNetworker) serve(ctx context.Context) error {
for {
r.log.Infoln("Trying to accept routing group...")
rg, err := r.r.AcceptRoutes(ctx)
if err != nil {
r.log.Infof("Error accepting routing group: %v", err)
return err
}

r.log.Infoln("Accepted routing group")

go r.serveRG(rg)
}
}

// serveRG passes accepted router group to the corresponding listener.
func (r *SkywireNetworker) serveRG(rg *router.RouteGroup) {
localAddr, ok := rg.LocalAddr().(routing.Addr)
// TODO: local? remote? decide on this
localAddr, ok := rg.RemoteAddr().(routing.Addr)
if !ok {
r.closeRG(rg)
r.log.Error("wrong type of addr in accepted conn")
Expand Down
7 changes: 7 additions & 0 deletions pkg/app/appserver/rpc_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,29 @@ type AcceptResp struct {

// Accept accepts connection from the listener specified by `lisID`.
func (r *RPCGateway) Accept(lisID *uint16, resp *AcceptResp) error {
r.log.Infoln("Inside RPC Accept on server side")
lis, err := r.getListener(*lisID)
if err != nil {
r.log.Infoln("Error getting listener on RPC Accept server side")
return err
}

r.log.Infoln("Reserving next ID on RPC Accept server side")
connID, free, err := r.cm.ReserveNextID()
if err != nil {
r.log.Infoln("Error reserving next ID on RPC Accept server side")
return err
}

r.log.Infoln("Accepting conn on RPC Accept server side")
conn, err := lis.Accept()
if err != nil {
r.log.Infoln("Error accepting conn on RPC Accept server side")
free()
return err
}

r.log.Infoln("Wrapping conn on RPC Accept server side")
wrappedConn, err := appnet.WrapConn(conn)
if err != nil {
free()
Expand Down
2 changes: 2 additions & 0 deletions pkg/app/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ type Listener struct {
}

func (l *Listener) Accept() (net.Conn, error) {
l.log.Infoln("Calling app RPC Accept")
connID, remote, err := l.rpc.Accept(l.id)
if err != nil {
return nil, err
}
l.log.Infoln("Accepted conn from app RPC")

conn := &Conn{
id: connID,
Expand Down
12 changes: 8 additions & 4 deletions pkg/router/rpc_gateway.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package router

import (
"time"

"github.com/SkycoinProject/skycoin/src/util/logging"

"github.com/SkycoinProject/skywire-mainnet/pkg/routing"
Expand All @@ -19,15 +21,17 @@ func NewRPCGateway(router Router) *RPCGateway {
}

func (r *RPCGateway) AddEdgeRules(rules routing.EdgeRules, ok *bool) error {
/*if err := r.router.IntroduceRules(rules); err != nil {
if err := r.router.IntroduceRules(rules); err != nil {
*ok = false

r.logger.WithError(err).Warnf("Request completed with error.")

return routing.Failure{Code: routing.FailureAddRules, Msg: err.Error()}
}*/
}

time.Sleep(1 * time.Second)

r.logger.Infof("Adding Edge rules: forward: %s, reverse: %s", rules.Forward, rules.Reverse)
/*r.logger.Infof("Adding Edge rules: forward: %s, reverse: %s", rules.Forward, rules.Reverse)
if err := r.router.SaveRoutingRules(rules.Forward, rules.Reverse); err != nil {
*ok = false
Expand All @@ -40,7 +44,7 @@ func (r *RPCGateway) AddEdgeRules(rules routing.EdgeRules, ok *bool) error {
if !assertOk {
panic("Wrong router type")
}
router.saveRouteGroupRules(rules)
router.saveRouteGroupRules(rules)*/

/*if err := r.router.SaveRoutingRules(rules.Forward, rules.Reverse); err != nil {
*ok = false
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/SkycoinProject/dmsg/disc/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f11e065

Please sign in to comment.