Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu committed Sep 6, 2023
1 parent b5acc29 commit 2c7ed05
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions x/mongo/driver/topology/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,21 @@ type errorQueue struct {
mutex sync.Mutex
}

func (eq *errorQueue) head() (error, int) {
func (eq *errorQueue) head() (int, error) {
eq.mutex.Lock()
defer eq.mutex.Unlock()
if l := len(eq.errors); l > 0 {
return eq.errors[0], l
return l, eq.errors[0]
}
return nil, 0
return 0, nil
}

func (eq *errorQueue) dequeue() bool {
func (eq *errorQueue) dequeue() {
eq.mutex.Lock()
defer eq.mutex.Unlock()
if len(eq.errors) > 0 {
eq.errors = eq.errors[1:]
return true
}
return false
}

type timeoutConn struct {
Expand All @@ -83,7 +81,7 @@ type timeoutConn struct {

func (c *timeoutConn) Read(b []byte) (int, error) {
var n int
err, l := c.errors.head()
l, err := c.errors.head()
defer func(l int) {
c.ch <- l
}(l)
Expand All @@ -95,7 +93,7 @@ func (c *timeoutConn) Read(b []byte) (int, error) {

func (c *timeoutConn) Write(b []byte) (int, error) {
var n int
err, l := c.errors.head()
l, err := c.errors.head()
defer func(l int) {
c.ch <- l
}(l)
Expand Down

0 comments on commit 2c7ed05

Please sign in to comment.