mirror of https://github.com/status-im/consul.git
commit
e5ea4ad54a
|
@ -274,7 +274,7 @@ func (d *DNSServer) handleTest(resp dns.ResponseWriter, req *dns.Msg) {
|
|||
m.Authoritative = true
|
||||
m.RecursionAvailable = true
|
||||
header := dns.RR_Header{Name: q.Name, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 0}
|
||||
txt := &dns.TXT{header, []string{"ok"}}
|
||||
txt := &dns.TXT{Hdr: header, Txt: []string{"ok"}}
|
||||
m.Answer = append(m.Answer, txt)
|
||||
d.addSOA(consulDomain, m)
|
||||
if err := resp.WriteMsg(m); err != nil {
|
||||
|
|
|
@ -144,14 +144,18 @@ func (c *WatchCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Setup handler
|
||||
errExit := false
|
||||
|
||||
// errExit:
|
||||
// 0: false
|
||||
// 1: true
|
||||
errExit := 0
|
||||
if script == "" {
|
||||
wp.Handler = func(idx uint64, data interface{}) {
|
||||
defer wp.Stop()
|
||||
buf, err := json.MarshalIndent(data, "", " ")
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error encoding output: %s", err))
|
||||
errExit = true
|
||||
errExit = 1
|
||||
}
|
||||
c.Ui.Output(string(buf))
|
||||
}
|
||||
|
@ -186,7 +190,7 @@ func (c *WatchCommand) Run(args []string) int {
|
|||
return
|
||||
ERR:
|
||||
wp.Stop()
|
||||
errExit = true
|
||||
errExit = 1
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,12 +207,7 @@ func (c *WatchCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
// Handle an error exit
|
||||
if errExit {
|
||||
return 1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
return errExit
|
||||
}
|
||||
|
||||
func (c *WatchCommand) Synopsis() string {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package consul
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -164,8 +165,9 @@ func (c *consulFSM) applyKVSOperation(buf []byte, index uint64) interface{} {
|
|||
return act
|
||||
}
|
||||
default:
|
||||
c.logger.Printf("[WARN] consul.fsm: Invalid KVS operation '%s'", req.Op)
|
||||
return fmt.Errorf("Invalid KVS operation '%s'", req.Op)
|
||||
err := errors.New(fmt.Sprintf("Invalid KVS operation '%s'", req.Op))
|
||||
c.logger.Printf("[WARN] consul.fsm: %v", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -259,27 +259,28 @@ func (p *ConnPool) getNewConn(addr net.Addr, version int) (*Conn, error) {
|
|||
}
|
||||
|
||||
// Wrap the connection
|
||||
c := &Conn{
|
||||
refCount: 1,
|
||||
addr: addr,
|
||||
session: session,
|
||||
clients: list.New(),
|
||||
lastUsed: time.Now(),
|
||||
version: version,
|
||||
pool: p,
|
||||
}
|
||||
var c *Conn
|
||||
|
||||
// Track this connection, handle potential race condition
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
if existing := p.pool[addr.String()]; existing != nil {
|
||||
c.Close()
|
||||
p.Unlock()
|
||||
return existing, nil
|
||||
c = existing
|
||||
} else {
|
||||
c = &Conn{
|
||||
refCount: 1,
|
||||
addr: addr,
|
||||
session: session,
|
||||
clients: list.New(),
|
||||
lastUsed: time.Now(),
|
||||
version: version,
|
||||
pool: p,
|
||||
}
|
||||
p.pool[addr.String()] = c
|
||||
p.Unlock()
|
||||
return c, nil
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// clearConn is used to clear any cached connection, potentially in response to an erro
|
||||
|
|
Loading…
Reference in New Issue