Skip to content

Commit

Permalink
Fix data race and execution ID comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Oct 29, 2024
1 parent d37a999 commit 130c984
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/server/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,12 @@ func (s *Server) addExecutions(c *gin.Context) {
}
}

s.appendToQueue(newElements)
addToQueue := func() {
mtx.Lock()
defer mtx.Unlock()
s.appendToQueue(newElements)
}
addToQueue()

c.JSON(http.StatusCreated, "")
}
Expand Down
13 changes: 13 additions & 0 deletions go/server/cron.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ var (
func (ei executionIdentifier) equalWithoutUUID(id executionIdentifier) bool {
ei.UUID = ""
id.UUID = ""

// If one has a profile and the other doesn't, it's not equal
if ei.Profile != nil && id.Profile == nil || ei.Profile == nil && id.Profile != nil {
return false
}
// If both have a profile, but they're different, it's not equal
if ei.Profile != nil && id.Profile != nil && *ei.Profile != *id.Profile {
return false
}
// Setting the profiles to nil so they don't mess up the equality comparison below
ei.Profile = nil
id.Profile = nil

return ei == id
}

Expand Down

0 comments on commit 130c984

Please sign in to comment.