Giter Site home page Giter Site logo

go-netwrap's People

Contributors

cryptix avatar decentral1se avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

decentral1se

go-netwrap's Issues

There are no timeouts for network operations.

I think you can set a deadline on net.Conn instances like conn.SetDeadline(time.Now().add(Duration{100000000})). The Go devs in their infinite wisdom make you call "SetDuration" over again every time there is a timeout error which is kind of dumb, but without any sort of timeout, I think every network operation that has a failure on the remote end leaves its goroutine hanging forever waiting for that dead connection to work again.

I noticed this trying out "go-ssb." When I left it running for a while, it accumulated a gigabyte of RAM doing basically nothing, and then when I killed the program, tens of thousands of identical error messages flooded the console, along the lines of "fetchFeed(%s:%d) gossip pump failed: %w" in plugins/gossip/handler.go of go-ssb. Then I had to hard kill the program, getting just as many tens of thousands of stack traces from goroutines going belly up in the process. Many of them had been sitting idle for an hour. I think every time "gossip pump" fails, it just hangs the goroutine and leaves all that memory leaking out like a sieve, since there are no timeouts for network operations anywhere I can see.

WithDialer?

In some cases you need to ioctl something on the filedescriptor or simply don't want to use std net.Dial. ConnWrappers only take effect after the fact the connection was opened. ioctl also doesn't work for the Serve() case.

type Dialer interface{
  Dial(net, addr string) (net.Conn, error)
}

func DialWithDialer(d Dialer, addr net.Addr, wrappers ...netwrap.ConnWrapper) (net.Conn, error) {
	conn, err := d.Dial(addr.Network(), addr.String())
	if err != nil {
		return nil, errors.Wrap(err, "error dialing")
	}

	for _, cw := range wrappers {
		conn, err = cw(conn)
		if err != nil {
			return nil, errors.Wrap(err, "error wrapping connection")
		}
	}

	return conn, nil
}

I exported the Dialer func as a type in v0.0.2 as quick remedy but would like a more general solution.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.