mirror of https://github.com/status-im/consul.git
Merge pull request #2358 from hashicorp/b-windows-spam
Makes Windows error check case-insensitive, runs go fmt.
This commit is contained in:
commit
b5da193b6b
|
@ -29,28 +29,28 @@ func (w *GatedWriter) Flush() {
|
|||
}
|
||||
|
||||
func (w *GatedWriter) Write(p []byte) (n int, err error) {
|
||||
// Once we flush we no longer synchronize writers since there's
|
||||
// no use of the internal buffer. This is the happy path.
|
||||
w.lock.RLock()
|
||||
if w.flush {
|
||||
w.lock.RUnlock()
|
||||
return w.Writer.Write(p)
|
||||
}
|
||||
w.lock.RUnlock()
|
||||
// Once we flush we no longer synchronize writers since there's
|
||||
// no use of the internal buffer. This is the happy path.
|
||||
w.lock.RLock()
|
||||
if w.flush {
|
||||
w.lock.RUnlock()
|
||||
return w.Writer.Write(p)
|
||||
}
|
||||
w.lock.RUnlock()
|
||||
|
||||
// Now take the write lock.
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
// Now take the write lock.
|
||||
w.lock.Lock()
|
||||
defer w.lock.Unlock()
|
||||
|
||||
// Things could have changed between the locking operations, so we
|
||||
// have to check one more time.
|
||||
if w.flush {
|
||||
return w.Writer.Write(p)
|
||||
}
|
||||
// Things could have changed between the locking operations, so we
|
||||
// have to check one more time.
|
||||
if w.flush {
|
||||
return w.Writer.Write(p)
|
||||
}
|
||||
|
||||
// Buffer up the written data.
|
||||
p2 := make([]byte, len(p))
|
||||
copy(p2, p)
|
||||
w.buf = append(w.buf, p2)
|
||||
return len(p), nil
|
||||
// Buffer up the written data.
|
||||
p2 := make([]byte, len(p))
|
||||
copy(p2, p)
|
||||
w.buf = append(w.buf, p2)
|
||||
return len(p), nil
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ func (i *AgentRPC) handleClient(client *rpcClient) {
|
|||
// The second part of this if is to block socket
|
||||
// errors from Windows which appear to happen every
|
||||
// time there is an EOF.
|
||||
if err != io.EOF && !strings.Contains(err.Error(), "WSARecv") {
|
||||
if err != io.EOF && !strings.Contains(strings.ToLower(err.Error()), "wsarecv") {
|
||||
i.logger.Printf("[ERR] agent.rpc: failed to decode request header: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue