From 421956750733fee9d215ca2e8306bbd263838211 Mon Sep 17 00:00:00 2001 From: Artyom Abakumov Date: Wed, 5 Feb 2025 20:10:58 +0300 Subject: [PATCH] Make sure only one error will be sent to not-started Service --- src/jrd/svc.cpp | 20 ++++++++++++++++++-- src/jrd/svc.h | 3 +++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/jrd/svc.cpp b/src/jrd/svc.cpp index 7d0dfdbeb30..ec719192757 100644 --- a/src/jrd/svc.cpp +++ b/src/jrd/svc.cpp @@ -516,7 +516,7 @@ void Service::putBytes(const UCHAR* bytes, FB_SIZE_T len) void Service::setServiceStatus(const ISC_STATUS* status_vector) { - if (checkForShutdown()) + if (checkForShutdown() || checkForFailedStart()) { return; } @@ -529,7 +529,7 @@ void Service::setServiceStatus(const ISC_STATUS* status_vector) void Service::setServiceStatus(const USHORT facility, const USHORT errcode, const MsgFormat::SafeArg& args) { - if (checkForShutdown()) + if (checkForShutdown() || checkForFailedStart()) { return; } @@ -974,6 +974,22 @@ bool Service::checkForShutdown() } +bool Service::checkForFailedStart() +{ + if ((svc_flags & SVC_evnt_fired) == 0) + { + // Service has not been started but we have got an error + svc_flags |= SVC_failed_start; + } + else if ((svc_flags & SVC_failed_start) != 0) + { + // Service has started with an error but we are trying to write one more error + return true; + } + + return false; +} + void Service::cancel(thread_db* /*tdbb*/) { svc_shutdown_request = true; diff --git a/src/jrd/svc.h b/src/jrd/svc.h index 66cf96790fd..7f5b3124ef1 100644 --- a/src/jrd/svc.h +++ b/src/jrd/svc.h @@ -99,6 +99,7 @@ const int SVC_finished = 0x10; //const int SVC_thd_running = 0x20; const int SVC_evnt_fired = 0x40; const int SVC_cmd_line = 0x80; +const int SVC_failed_start = 0x100; // forward decl. class thread_db; @@ -245,6 +246,8 @@ class Service : public Firebird::UtilSvc, public TypedHandle void finish(USHORT flag); // Throws shutdown exception if global flag is set for it bool checkForShutdown(); + // Check for the existence of errors in the service that has not started + bool checkForFailedStart(); // Transfer data from svc_stdout into buffer void get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, USHORT* return_length); // Sends stdin for a service