Skip to content

Commit

Permalink
server/run: Add note about why the run server is single threaded
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi4 committed Jun 13, 2024
1 parent d3fb37e commit e22fd3b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions server/run/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ func (c *client) SendShutdown() error {
return json.NewEncoder(conn).Encode(data)
}

// NOTE: If we don't wait for the response and if the server has go-routines for each connection, we might have race conditions.
// e.g: c.NextCommand() and c.CurrentState() might be called sequentially, but the server might schedule the go-routines such that c.CurrentState() completes before c.NextCommand()
// Then we might get the wrong state.
// To avoid this, for now, the server is single threaded.
func (c *client) NextCommand() error {
conn, err := net.Dial("unix", c.socketPath)
if err != nil {
Expand Down

0 comments on commit e22fd3b

Please sign in to comment.