Skip to content

Commit

Permalink
check isCPUProfiling later
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Vaillancourt <[email protected]>
  • Loading branch information
timvaillancourt committed Dec 24, 2023
1 parent 36ca797 commit f4f324c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 3 additions & 4 deletions go/logic/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ func NewServer(migrationContext *base.MigrationContext, hooksExecutor *HooksExec
}

func (this *Server) runCPUProfile(args string) (string, error) {
if atomic.LoadInt64(&this.isCPUProfiling) > 0 {
return "", ErrCPUProfilingInProgress
}

duration := defaultCPUProfileDuration

var err error
Expand All @@ -78,6 +74,9 @@ func (this *Server) runCPUProfile(args string) (string, error) {
}
}

if atomic.LoadInt64(&this.isCPUProfiling) > 0 {
return "", ErrCPUProfilingInProgress
}
atomic.StoreInt64(&this.isCPUProfiling, 1)
defer atomic.StoreInt64(&this.isCPUProfiling, 0)

Expand Down
3 changes: 0 additions & 3 deletions go/logic/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package logic

import (
"encoding/base64"
"fmt"
"testing"
"time"

Expand Down Expand Up @@ -44,8 +43,6 @@ func TestServerRunCPUProfile(t *testing.T) {
tests.S(t).ExpectNil(err)
tests.S(t).ExpectNotEquals(profile, "")

fmt.Println(profile)

data, err := base64.StdEncoding.DecodeString(profile)
tests.S(t).ExpectNil(err)
tests.S(t).ExpectEquals(len(data), 106)
Expand Down

0 comments on commit f4f324c

Please sign in to comment.