@@ -98,10 +98,8 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
98
98
{
99
99
using Result = Checkable::ProcessingResult;
100
100
101
- {
102
- ObjectLock olock (this );
103
- m_CheckRunning = false ;
104
- }
101
+ ObjectLock olock (this );
102
+ m_CheckRunning = false ;
105
103
106
104
if (!cr)
107
105
return Result::NoCheckResult;
@@ -158,8 +156,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
158
156
// This will be used to determine whether the on reachability changed event should be triggered.
159
157
bool affectsPreviousStateChildren (reachable && AffectsChildren ());
160
158
161
- ObjectLock olock (this );
162
-
163
159
CheckResult::Ptr old_cr = GetLastCheckResult ();
164
160
ServiceState old_state = GetStateRaw ();
165
161
StateType old_stateType = GetStateType ();
@@ -322,8 +318,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
322
318
if (is_volatile && IsStateOK (old_state) && IsStateOK (new_state))
323
319
send_notification = false ; /* Don't send notifications for volatile OK -> OK changes. */
324
320
325
- olock.Unlock ();
326
-
327
321
if (remove_acknowledgement_comments)
328
322
RemoveAckComments (String (), cr->GetExecutionEnd ());
329
323
@@ -339,25 +333,14 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
339
333
340
334
cr->SetVarsAfter (vars_after);
341
335
342
- olock.Lock ();
343
-
336
+ bool problem_change = false ;
344
337
if (service) {
345
338
SetLastCheckResult (cr);
346
339
} else {
347
340
bool wasProblem = GetProblem ();
348
-
349
341
SetLastCheckResult (cr);
350
-
351
- if (GetProblem () != wasProblem) {
352
- auto services = host->GetServices ();
353
- olock.Unlock ();
354
- for (auto & service : services) {
355
- Service::OnHostProblemChanged (service, cr, origin);
356
- }
357
- olock.Lock ();
358
- }
342
+ problem_change = GetProblem () != wasProblem;
359
343
}
360
-
361
344
bool was_flapping = IsFlapping ();
362
345
363
346
UpdateFlappingStatus (cr->GetState ());
@@ -388,8 +371,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
388
371
}
389
372
}
390
373
391
- olock.Unlock ();
392
-
393
374
#ifdef I2_DEBUG /* I2_DEBUG */
394
375
Log (LogDebug, " Checkable" )
395
376
<< " Flapping: Checkable " << GetName ()
@@ -400,36 +381,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
400
381
<< " % current: " << GetFlappingCurrent () << " %." ;
401
382
#endif /* I2_DEBUG */
402
383
403
- if (recovery) {
404
- for (auto & child : children) {
405
- if (child->GetProblem () && child->GetEnableActiveChecks ()) {
406
- auto nextCheck (now + Utility::Random () % 60 );
407
-
408
- ObjectLock oLock (child);
409
-
410
- if (nextCheck < child->GetNextCheck ()) {
411
- child->SetNextCheck (nextCheck);
412
- }
413
- }
414
- }
415
- }
416
-
417
- if (stateChange) {
418
- /* reschedule direct parents */
419
- for (const Checkable::Ptr& parent : GetParents ()) {
420
- if (parent.get () == this )
421
- continue ;
422
-
423
- if (!parent->GetEnableActiveChecks ())
424
- continue ;
425
-
426
- if (parent->GetNextCheck () >= now + parent->GetRetryInterval ()) {
427
- ObjectLock olock (parent);
428
- parent->SetNextCheck (now);
429
- }
430
- }
431
- }
432
-
433
384
OnNewCheckResult (this , cr, origin);
434
385
435
386
/* signal status updates to for example db_ido */
@@ -510,7 +461,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
510
461
* stash them into a notification types bitmask for maybe re-sending later.
511
462
*/
512
463
513
- ObjectLock olock (this );
514
464
int suppressed_types_before (GetSuppressedNotifications ());
515
465
int suppressed_types_after (suppressed_types_before | suppressed_types);
516
466
@@ -540,6 +490,44 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
540
490
if ((stateChange || hardChange) && !children.empty () && (affectsPreviousStateChildren || AffectsChildren ()))
541
491
OnReachabilityChanged (this , cr, children, origin);
542
492
493
+ olock->Unlock ();
494
+ if (!service && problem_change) {
495
+ auto services = host->GetServices ();
496
+ for (auto & service : services) {
497
+ Service::OnHostProblemChanged (service, cr, origin);
498
+ }
499
+ }
500
+
501
+ if (recovery) {
502
+ for (auto & child : children) {
503
+ if (child->GetProblem () && child->GetEnableActiveChecks ()) {
504
+ auto nextCheck (now + Utility::Random () % 60 );
505
+
506
+ ObjectLock oLock (child);
507
+
508
+ if (nextCheck < child->GetNextCheck ()) {
509
+ child->SetNextCheck (nextCheck);
510
+ }
511
+ }
512
+ }
513
+ }
514
+
515
+ if (stateChange) {
516
+ /* reschedule direct parents */
517
+ for (const Checkable::Ptr& parent : GetParents ()) {
518
+ if (parent.get () == this )
519
+ continue ;
520
+
521
+ if (!parent->GetEnableActiveChecks ())
522
+ continue ;
523
+
524
+ if (parent->GetNextCheck () >= now + parent->GetRetryInterval ()) {
525
+ ObjectLock olock (parent);
526
+ parent->SetNextCheck (now);
527
+ }
528
+ }
529
+ }
530
+
543
531
return Result::Ok;
544
532
}
545
533
0 commit comments