Skip to content

Commit

Permalink
#1 panic in xmeye
Browse files Browse the repository at this point in the history
  • Loading branch information
kihamo committed Oct 16, 2019
1 parent 98e4d25 commit ca5f5db
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions providers/xmeye/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (

type connection struct {
protocol.Conn
sync.Mutex

_ [4]byte
sessionID uint32
sequenceNumber uint32

lock sync.Mutex
}

func (c *connection) SessionID() uint32 {
Expand All @@ -23,7 +23,7 @@ func (c *connection) SessionID() uint32 {
func (c *connection) SessionIDAsString() (id string) {
session := Uint32(c.SessionID())

if b, err := session.MarshalJSON(); err != nil {
if b, err := session.MarshalJSON(); err == nil {
id = string(b)
}

Expand All @@ -43,8 +43,8 @@ func (c *connection) InSequenceNumber() {
}

func (c *connection) send(packet *packet) error {
c.Lock()
defer c.Unlock()
c.lock.Lock()
defer c.lock.Unlock()

packet.SessionID = c.SessionID()
packet.SequenceNumber = c.SequenceNumber()
Expand All @@ -59,8 +59,8 @@ func (c *connection) send(packet *packet) error {
}

func (c *connection) receive() (*packet, error) {
c.Lock()
defer c.Unlock()
c.lock.Lock()
defer c.lock.Unlock()

head := make([]byte, 0x14) // read head
if _, err := c.Conn.Read(head); err != nil {
Expand Down

0 comments on commit ca5f5db

Please sign in to comment.