Skip to content

Commit

Permalink
Fix deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Apr 19, 2024
1 parent 1a6c8c1 commit 054695c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ func (c *Connection) send(rdb *DatagramBuilder) (int, error) {
}

// Receives an RCT response via the connection
func (c *Connection) Receive() (dg *Datagram, err error) {
func (c *Connection) Receive() (*Datagram, error) {
c.mu.Lock()
defer c.mu.Unlock()
return c.receive()
}

// Receives an RCT response via the connection
func (c *Connection) receive() (dg *Datagram, err error) {
// ensure active connection
if c.conn == nil {
if err := c.connect(); err != nil {
Expand Down Expand Up @@ -130,7 +134,7 @@ func (c *Connection) Query(id Identifier) (*Datagram, error) {
return nil, err
}

dg, err := c.Receive()
dg, err := c.receive()
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 054695c

Please sign in to comment.