Skip to content

Commit

Permalink
fix data race
Browse files Browse the repository at this point in the history
  • Loading branch information
sijms committed May 4, 2024
1 parent 032d50b commit f485f79
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions v2/db_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func GetDBVersion(session *network.Session) (*DBVersion, error) {
return nil, err
}
msg, err := session.GetByte()
if err != nil {
return nil, err
}
if msg != 8 {
return nil, errors.New(fmt.Sprintf("message code error: received code %d and expected code is 8", msg))
}
Expand Down
9 changes: 5 additions & 4 deletions v2/network/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func (session *Session) StartContext(ctx context.Context) {
go func(idone chan struct{}, mu *sync.Mutex) {
var err error
mu.Lock()
var tracer = session.tracer
mu.Unlock()
select {
case <-idone:
Expand All @@ -206,12 +207,12 @@ func (session *Session) StartContext(ctx context.Context) {
session.mu.Unlock()
if connected {
if err = session.BreakConnection(); err != nil {
session.tracer.Print("Connection Break Error: ", err)
tracer.Print("Connection Break Error: ", err)
}
} else {
err = session.WriteFinalPacket()
if err != nil {
session.tracer.Print("Write Final Packet With Error: ", err)
tracer.Print("Write Final Packet With Error: ", err)
}
session.Disconnect()
}
Expand Down Expand Up @@ -930,8 +931,8 @@ func (session *Session) GetError() *OracleError {
}

func (session *Session) readAll(size int) error {
session.mu.Lock()
defer session.mu.Unlock()
//session.mu.Lock()
//defer session.mu.Unlock()
index := 0
tempBuffer := make([]byte, size)
var err error
Expand Down

0 comments on commit f485f79

Please sign in to comment.