Git Product home page Git Product logo

Comments (4)

shabbyrobe avatar shabbyrobe commented on July 2, 2024 5

I don't see a neat way to close cmux down at all. I could be misreading the docs but even though it says ErrListenerClosed is supposed to be returned, I get a net.OpError instead that says "use of closed network connection".

from cmux.

wood-jp avatar wood-jp commented on July 2, 2024 2

Any progress on this? I'm using cmux to share HTTP/REST and gRPC on the same port as I slowly transition from the former to the later. Both of those have graceful shutdown options, but I find that cmux.Serve() does not throw a clear error (I get the same thing as @shabbyrobe), making my life difficult.

from cmux.

chandradeepak avatar chandradeepak commented on July 2, 2024

may be some thing like a Stop method which not only does the m.root.Close() and also make sure it closes other connections .

`defer func() {
close(m.donec)
wg.Wait()

	for _, sl := range m.sls {
		close(sl.l.connc)
		// Drain the connections enqueued for the listener.
		for c := range sl.l.connc {
			_ = c.Close()
		}
	}
}()`

Most of it is there in defer func of Serve.

so we need to make sure it doesn't happen at two places .

from cmux.

puellanivis avatar puellanivis commented on July 2, 2024

So, while a “graceful shutdown” is in part available through PR-69 to call a Close() function, the unexported muxListener type that wraps the net.Listener that is the actual net.Listener set during the cmux.New(), does not implement its own Close() function, so when either a gRPC or HTTP server is told to gracefully shutdown, it will passthrough close the main net.Listener port, breaking cmux.CMux.Serve and any other service also setup.

Ideally, the cmux.CMux.Close() would handle closing the actual net.Listener (so new connections are rejected) and then the Close() from each of the muxListener children will only close their own individual acceptance channels, which will then allow all pending Accept to be drained, and then the server shutdown once all the outstanding handlers finish.

from cmux.

Related Issues (20)

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.