Codebase list golang-github-zenazn-goji / d82cdd8
fix an error at shutdown on Windows. tamaoo authored 5 years ago Carl Jackson committed 5 years ago
1 changed file(s) with 10 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
88
99 import (
1010 "net"
11 "runtime"
1211 "sync/atomic"
1312
1413 "github.com/zenazn/goji/graceful/listener"
4948 // Unfortunately Go doesn't really give us a better way to select errors
5049 // than this, so *shrug*.
5150 if oe, ok := err.(*net.OpError); ok {
52 errOp := "accept"
53 if runtime.GOOS == "windows" {
54 errOp = "AcceptEx"
55 }
56 if oe.Op == errOp && oe.Err.Error() == errClosing {
57 return nil
51 switch oe.Op {
52 // backward compatibility: older golang returns AcceptEx on Windows.
53 // Current golang returns "accept" consistently. It's platform independent.
54 // See https://github.com/golang/go/commit/b0f4ee533a875c258ac1030ee382f0ffe2de304b
55 case "AcceptEx":
56 fallthrough
57 case "accept":
58 if oe.Err.Error() == errClosing {
59 return nil
60 }
5861 }
5962 }
6063 return err