fix an error at shutdown on Windows.
tamaoo authored 5 years ago
Carl Jackson committed 5 years ago
8 | 8 | |
9 | 9 | import ( |
10 | 10 | "net" |
11 | "runtime" | |
12 | 11 | "sync/atomic" |
13 | 12 | |
14 | 13 | "github.com/zenazn/goji/graceful/listener" |
49 | 48 | // Unfortunately Go doesn't really give us a better way to select errors |
50 | 49 | // than this, so *shrug*. |
51 | 50 | 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 | } | |
58 | 61 | } |
59 | 62 | } |
60 | 63 | return err |