Skip to content

Commit

Permalink
linux race fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zwass committed Oct 10, 2017
1 parent ae75376 commit 5ee8ed9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion osquery/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ func launchOsqueryInstance(o *OsqueryInstance) (*OsqueryInstance, error) {
level.Error(o.logger).Log("err", errors.Wrap(runtimeError, "osquery runtime error"))
}

if needsRecovery {
o.instanceLock.Lock()
teardownStarted := o.teardownStarted()
o.instanceLock.Unlock()
if needsRecovery && !teardownStarted {
level.Info(o.logger).Log("msg", "recovering osquery instance")
if recoveryError := o.Recover(); recoveryError != nil {
// If we were not able to recover the osqueryd process for some reason,
Expand All @@ -503,6 +506,11 @@ func (o *OsqueryInstance) beginTeardown() bool {
return begun == 0
}

func (o *OsqueryInstance) teardownStarted() bool {
begun := atomic.LoadInt32(&o.instance.hasBegunTeardown)
return begun != 0
}

// Recover attempts to launch a new osquery instance if the running instance has
// failed for some reason. Note that this function does not call o.Kill() to
// release resources because Kill() expects the osquery instance to be healthy,
Expand Down

0 comments on commit 5ee8ed9

Please sign in to comment.