-
Notifications
You must be signed in to change notification settings - Fork 54
Closed
Description
This function only works on unix, and not on windows. Make it cross platform.
humanlog/cmd/humanlog/localhost.go
Lines 35 to 52 in 4aff753
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
Labels
No labels