Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make cross-platform EADDRINUSE check #85

Closed
1 task done
aybabtme opened this issue Oct 21, 2024 · 1 comment
Closed
1 task done

make cross-platform EADDRINUSE check #85

aybabtme opened this issue Oct 21, 2024 · 1 comment

Comments

@aybabtme
Copy link
Collaborator

aybabtme commented Oct 21, 2024

This function only works on unix, and not on windows. Make it cross platform.

func isEADDRINUSE(err error) bool {
nerr, ok := err.(*net.OpError)
if !ok {
return false
}
nserr, ok := nerr.Err.(*os.SyscallError)
if !ok {
return false
}
if nserr.Syscall != "bind" {
return false
}
nserrno, ok := nserr.Err.(syscall.Errno)
if !ok {
return false
}
return nserrno == unix.EADDRINUSE
}

We want to know when we're trying to use an already used port, because that's how we find who's the localhost leader in a multi-process scenario (e.g. if multiple humanlog processes are running concurrently). The leader is whoever has the port.

  • enable CI (commented out in b7110ad)
aybabtme added a commit that referenced this issue Oct 25, 2024
aybabtme added a commit that referenced this issue Oct 25, 2024
@aybabtme
Copy link
Collaborator Author

aybabtme commented Nov 7, 2024

solved by #121

@aybabtme aybabtme closed this as completed Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant