Skip to content

Commit

Permalink
removed some retried functions and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ivcosla committed Jun 26, 2019
1 parent 8d5765e commit 679e144
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 17 deletions.
5 changes: 1 addition & 4 deletions cmd/apps/skychat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ func messageHandler(w http.ResponseWriter, req *http.Request) {
go handleConn(conn)
}

err := r.Do(func() error {
_, err := conn.Write([]byte(data["message"]))
return err
})
_, err := conn.Write([]byte(data["message"]))
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
connsMu.Lock()
Expand Down
3 changes: 2 additions & 1 deletion internal/netutil/retrier.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func NewRetrier(exponentialBackoff time.Duration, times, factor uint32) *Retrier
}
}

// WithErrWhitelist sets a list of errors into the retrier, if the RetryFunc provided to Do() fails with one of them it will return inmediatelly with such error
// WithErrWhitelist sets a list of errors into the retrier, if the RetryFunc provided to Do() fails with one of them it will return inmediatelly with such error. Calling
// this function is not thread-safe, and is advised to only use it when initializing the Retrier
func (r *Retrier) WithErrWhitelist(errors ...error) *Retrier {
m := make(map[error]struct{})
for _, err := range errors {
Expand Down
10 changes: 1 addition & 9 deletions internal/therealproxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ import (
"io"
"log"
"net"
"time"

"github.com/skycoin/skywire/internal/netutil"

"github.com/hashicorp/yamux"
)

var r = netutil.NewRetrier(50*time.Millisecond, 3, 2)

// Client implement multiplexing proxy client using yamux.
type Client struct {
session *yamux.Session
Expand Down Expand Up @@ -48,10 +43,7 @@ func (c *Client) ListenAndServe(addr string) error {
return fmt.Errorf("accept: %s", err)
}

err = r.Do(func() error {
stream, err = c.session.Open()
return err
})
stream, err = c.session.Open()
if err != nil {
return fmt.Errorf("yamux: %s", err)
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,11 @@ func (app *App) Dial(raddr *Addr) (net.Conn, error) {
if err != nil {
return nil, err
}
fmt.Println("loop created")
addr := &LoopAddr{laddr.Port, *raddr}
conn, out := net.Pipe()
fmt.Println("locking mux...")
app.mu.Lock()
app.conns[*addr] = conn
app.mu.Unlock()
fmt.Println("serving conn...")
go app.serveConn(addr, conn)
return newAppConn(out, laddr, raddr), nil
}
Expand Down

0 comments on commit 679e144

Please sign in to comment.