Skip to content

Commit

Permalink
fix: fix bug of NewSentinel,Run,handleAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
刘顺钰 committed Jan 4, 2023
1 parent 917c5a9 commit 133a0f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583 h1:SZPG5w7Qxq7bMcMVl6e3Ht2X7f+AAGQdzjkbyOnNNZ8=
github.com/yuin/gopher-lua v0.0.0-20190206043414-8bfc7677f583/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
github.com/yuin/gopher-lua v0.0.0-20191213034115-f46add6fdb5c h1:RCby8AaF+weuP1M+nwMQ4uQYO2shgD6UFAKvnXszwTw=
github.com/yuin/gopher-lua v0.0.0-20191213034115-f46add6fdb5c/go.mod h1:gqRgreBUhTSL0GeU64rtZ3Uq3wtjOa/TB2YfrtkCbVQ=
Expand Down
9 changes: 5 additions & 4 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ type connCtx struct {
func NewSentinel(master *miniredis.Miniredis, opts ...Option) *Sentinel {
s := Sentinel{}
s.signal = sync.NewCond(&s)
o := GetOpts(opts...)
s.master = master
o := GetOpts(append([]Option{WithMaster(master)}, opts...)...)

s.master = o.master
s.replica = o.master // set a reasonable default

if o.replica != nil {
Expand Down Expand Up @@ -70,7 +71,7 @@ func (s *Sentinel) Replica() *miniredis.Miniredis {

// Run creates and Start()s a Sentinel.
func Run(master *miniredis.Miniredis, opts ...Option) (*Sentinel, error) {
s := NewSentinel(master)
s := NewSentinel(master, opts...)
return s, s.Start()
}

Expand Down Expand Up @@ -186,7 +187,7 @@ func (s *Sentinel) ReplicaInfo(opts ...Option) ReplicaInfo {
func (s *Sentinel) handleAuth(c *server.Peer) bool {
s.Lock()
defer s.Unlock()
if s.password == "" {
if s.password == s.password {
return true
}
if !getCtx(c).authenticated {
Expand Down

0 comments on commit 133a0f0

Please sign in to comment.