Skip to content

Commit 84b9598

Browse files
Noremosdyemanov
authored andcommitted
Make sure only one error will be sent to not-started Service
1 parent 43ec310 commit 84b9598

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
}
@@ -964,6 +964,22 @@ bool Service::checkForShutdown()
964964
}
965965

966966

967+
bool Service::checkForFailedStart()
968+
{
969+
if ((svc_flags & SVC_evnt_fired) == 0)
970+
{
971+
// Service has not been started but we have got an error
972+
svc_flags |= SVC_failed_start;
973+
}
974+
else if ((svc_flags & SVC_failed_start) != 0)
975+
{
976+
// Service has started with an error but we are trying to write one more error
977+
return true;
978+
}
979+
980+
return false;
981+
}
982+
967983
void Service::cancel(thread_db* /*tdbb*/)
968984
{
969985
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;
@@ -244,6 +245,8 @@ class Service : public Firebird::UtilSvc, public TypedHandle<type_svc>
244245
void finish(USHORT flag);
245246
// Throws shutdown exception if global flag is set for it
246247
bool checkForShutdown();
248+
// Check for the existence of errors in the service that has not started
249+
bool checkForFailedStart();
247250
// Transfer data from svc_stdout into buffer
248251
void get(UCHAR* buffer, USHORT length, USHORT flags, USHORT timeout, USHORT* return_length);
249252
// Sends stdin for a service

0 commit comments

Comments
 (0)