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