@@ -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;
@@ -154,8 +152,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
154
152
bool reachable = IsReachable ();
155
153
bool notification_reachable = IsReachable (DependencyNotification);
156
154
157
- ObjectLock olock (this );
158
-
159
155
CheckResult::Ptr old_cr = GetLastCheckResult ();
160
156
ServiceState old_state = GetStateRaw ();
161
157
StateType old_stateType = GetStateType ();
@@ -318,8 +314,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
318
314
if (is_volatile && IsStateOK (old_state) && IsStateOK (new_state))
319
315
send_notification = false ; /* Don't send notifications for volatile OK -> OK changes. */
320
316
321
- olock.Unlock ();
322
-
323
317
if (remove_acknowledgement_comments)
324
318
RemoveAckComments (String (), cr->GetExecutionEnd ());
325
319
@@ -335,25 +329,14 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
335
329
336
330
cr->SetVarsAfter (vars_after);
337
331
338
- olock.Lock ();
339
-
332
+ bool problem_change = false ;
340
333
if (service) {
341
334
SetLastCheckResult (cr);
342
335
} else {
343
336
bool wasProblem = GetProblem ();
344
-
345
337
SetLastCheckResult (cr);
346
-
347
- if (GetProblem () != wasProblem) {
348
- auto services = host->GetServices ();
349
- olock.Unlock ();
350
- for (auto & service : services) {
351
- Service::OnHostProblemChanged (service, cr, origin);
352
- }
353
- olock.Lock ();
354
- }
338
+ problem_change = GetProblem () != wasProblem;
355
339
}
356
-
357
340
bool was_flapping = IsFlapping ();
358
341
359
342
UpdateFlappingStatus (cr->GetState ());
@@ -384,8 +367,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
384
367
}
385
368
}
386
369
387
- olock.Unlock ();
388
-
389
370
#ifdef I2_DEBUG /* I2_DEBUG */
390
371
Log (LogDebug, " Checkable" )
391
372
<< " Flapping: Checkable " << GetName ()
@@ -396,35 +377,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
396
377
<< " % current: " << GetFlappingCurrent () << " %." ;
397
378
#endif /* I2_DEBUG */
398
379
399
- if (recovery) {
400
- for (auto & child : children) {
401
- if (child->GetProblem () && child->GetEnableActiveChecks ()) {
402
- auto nextCheck (now + Utility::Random () % 60 );
403
-
404
- ObjectLock oLock (child);
405
-
406
- if (nextCheck < child->GetNextCheck ()) {
407
- child->SetNextCheck (nextCheck);
408
- }
409
- }
410
- }
411
- }
412
-
413
- if (stateChange) {
414
- /* reschedule direct parents */
415
- for (const Checkable::Ptr& parent : GetParents ()) {
416
- if (parent.get () == this )
417
- continue ;
418
-
419
- if (!parent->GetEnableActiveChecks ())
420
- continue ;
421
-
422
- if (parent->GetNextCheck () >= now + parent->GetRetryInterval ()) {
423
- ObjectLock olock (parent);
424
- parent->SetNextCheck (now);
425
- }
426
- }
427
- }
428
380
429
381
OnNewCheckResult (this , cr, origin);
430
382
@@ -506,7 +458,6 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
506
458
* stash them into a notification types bitmask for maybe re-sending later.
507
459
*/
508
460
509
- ObjectLock olock (this );
510
461
int suppressed_types_before (GetSuppressedNotifications ());
511
462
int suppressed_types_after (suppressed_types_before | suppressed_types);
512
463
@@ -536,6 +487,44 @@ Checkable::ProcessingResult Checkable::ProcessCheckResult(const CheckResult::Ptr
536
487
if ((stateChange || hardChange) && !children.empty ())
537
488
OnReachabilityChanged (this , cr, children, origin);
538
489
490
+ olock->Unlock ();
491
+ if (!service && problem_change) {
492
+ auto services = host->GetServices ();
493
+ for (auto & service : services) {
494
+ Service::OnHostProblemChanged (service, cr, origin);
495
+ }
496
+ }
497
+
498
+ if (recovery) {
499
+ for (auto & child : children) {
500
+ if (child->GetProblem () && child->GetEnableActiveChecks ()) {
501
+ auto nextCheck (now + Utility::Random () % 60 );
502
+
503
+ ObjectLock oLock (child);
504
+
505
+ if (nextCheck < child->GetNextCheck ()) {
506
+ child->SetNextCheck (nextCheck);
507
+ }
508
+ }
509
+ }
510
+ }
511
+
512
+ if (stateChange) {
513
+ /* reschedule direct parents */
514
+ for (const Checkable::Ptr& parent : GetParents ()) {
515
+ if (parent.get () == this )
516
+ continue ;
517
+
518
+ if (!parent->GetEnableActiveChecks ())
519
+ continue ;
520
+
521
+ if (parent->GetNextCheck () >= now + parent->GetRetryInterval ()) {
522
+ ObjectLock olock (parent);
523
+ parent->SetNextCheck (now);
524
+ }
525
+ }
526
+ }
527
+
539
528
return Result::Ok;
540
529
}
541
530
0 commit comments