Skip to content

Commit 1966b79

Browse files
authored
Merge pull request #389 from IbrahimAhmed8/fix_ffi_race
prevent data race in ReEnrollNode
2 parents 077a43e + 61f5cf3 commit 1966b79

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

mobile/sam-node-ffi/ffi/ffi.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ func saveRefreshSession(ctx context.Context, store *node.Store, controlPlaneURL,
545545
// at enrollment buys a JWT and the stored key keeps the PeerID. Fails when
546546
// no token was saved or it expired; the app then falls back to the browser.
547547
func ReEnrollNode(dataDir string, labels string) error {
548-
if activeNode != nil || unauthSrv != nil {
548+
mu.Lock()
549+
isRunning := activeNode != nil || unauthSrv != nil
550+
mu.Unlock()
551+
if isRunning {
549552
return errors.New("stop the node before re-enrolling")
550553
}
551554
parsedLabels, err := decodeLabels(labels)

0 commit comments

Comments
 (0)