Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Also check sockets bind to tcp6 and fail on all closed sockets #824

Merged
merged 4 commits into from
Sep 30, 2019

Conversation

juanjux
Copy link
Contributor

@juanjux juanjux commented Sep 19, 2019

  • Also parse /proc/net/tcp6 because go will bind to it (too) on Listen() if TCP v6 is enabled on the system, and then the socket will only show on /proc/net/tcp6. This fixes Failing test for connection handler in Linux #821.

  • Fail on all kinds of closed sockets, even if they were closed correctly, before the query completion, thus ensuring that the query is cancelled.

  • Two explicit channel closings to ensure the goroutines exit ASAP.

Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@juanjux juanjux force-pushed the fail-on-all-closed-sockets branch 2 times, most recently from 18c5e2f to 6082b9c Compare September 19, 2019 13:18
internal/sockstate/netstat_darwin.go Outdated Show resolved Hide resolved
internal/sockstate/netstat_linux.go Show resolved Hide resolved
Copy link
Contributor

@agarciamontoro agarciamontoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a tricky one... Good that you found the cause! 🎉

internal/sockstate/netstat_darwin.go Outdated Show resolved Hide resolved
@erizocosmico
Copy link
Contributor

@juanjux remember to sign de DCO

Juanjo Alvarez added 3 commits September 19, 2019 16:23
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
Signed-off-by: Juanjo Alvarez <juanjo@sourced.tech>
@juanjux
Copy link
Contributor Author

juanjux commented Sep 19, 2019

@erizocosmico yep, that's what happen when you commit code from VMs or other people machines without all your git/gpg config scaffolding :/

@ajnavarro ajnavarro merged commit 6ee998b into src-d:master Sep 30, 2019
@TheWinds
Copy link

TheWinds commented Jan 6, 2021

On linux system,if TCP v6 is disabled on the system, open /proc/net/tcp6 will produce the error /proc/net/tcp6: No such file or directory.
How to slove this bug?

func tcpSocks(accept AcceptFn) ([]sockTabEntry, error) {
	paths := [2]string{pathTCP4Tab, pathTCP6Tab}
	var allTabs []sockTabEntry
	for _, p := range paths {
		f, err := os.Open(p)
		defer func() {
			_ = f.Close()
		}()
		if err != nil {
			return nil, err
		}

		t, err := parseSocktab(f, accept)
		if err != nil {
			return nil, err
		}
		allTabs = append(allTabs, t...)

	}
	extractProcInfo(allTabs)
	return allTabs, nil
}

@erizocosmico
Copy link
Contributor

@TheWinds this project is no longer maintained, you can report this on it's new home: https://github.com/dolthub/go-mysql-server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing test for connection handler in Linux
5 participants