Skip to content

make cross-platform EADDRINUSE check #85

@aybabtme

Description

@aybabtme

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions