Skip to content

Commit 76eccad

Browse files
NoremosAlexPeshkoff
authored andcommitted
Make sure only one error will be sent to not-started Service
1 parent 2f5aea9 commit 76eccad

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/jrd/svc.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void Service::putBytes(const UCHAR* bytes, FB_SIZE_T len)
516516

517517
void Service::setServiceStatus(const ISC_STATUS* status_vector)
518518
{
519-
if (checkForShutdown())
519+
if (checkForShutdown() || checkForFailedStart())
520520
{
521521
return;
522522
}
@@ -529,7 +529,7 @@ void Service::setServiceStatus(const ISC_STATUS* status_vector)
529529
void Service::setServiceStatus(const USHORT facility, const USHORT errcode,
530530
const MsgFormat::SafeArg& args)
531531
{
532-
if (checkForShutdown())
532+
if (checkForShutdown() || checkForFailedStart())
533533
{
534534
return;
535535
}
@@ -974,6 +974,22 @@ bool Service::checkForShutdown()
974974
}
975975

976976

977+
bool Service::checkForFailedStart()
978+
{
979+
if ((svc_flags & SVC_evnt_fired) == 0)
980+
{
981+
// Service has not been started but we have got an error
982+
svc_flags |= SVC_failed_start;
983+
}
984+
else if ((svc_flags & SVC_failed_start) != 0)
985+
{
986+
// Service has started with an error but we are trying to write one more error
987+
return true;
988+
}
989+
990+
return false;
991+
}
992+
977993
void Service::cancel(thread_db* /*tdbb*/)
978994
{
979995
svc_shutdown_request = true;

src/jrd/svc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const int SVC_finished = 0x10;
9999
//const int SVC_thd_running = 0x20;
100100
const int SVC_evnt_fired = 0x40;
101101
const int SVC_cmd_line = 0x80;
102+
const int SVC_failed_start = 0x100;
102103

103104
// forward decl.
104105
class thread_db;
@@ -245,6 +246,8 @@ class Service : public Firebird::UtilSvc, public TypedHandle<type_svc>
245246
void finish(USHORT flag);
246247
// Throws shutdown exception if global flag is set for it
247248
bool checkForShutdown();
249+
// Check for the existence of errors in the service that has not started
250+
bool checkForFailedStart();
248251
// Transfer data from svc_stdout into buffer
249252
void get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, USHORT* return_length);
250253
// Sends stdin for a service

0 commit comments

Comments
 (0)