diff --git a/src/alice/alice.cpp b/src/alice/alice.cpp index caae94e977..1f31d8408b 100644 --- a/src/alice/alice.cpp +++ b/src/alice/alice.cpp @@ -103,7 +103,10 @@ THREAD_ENTRY_DECLARE ALICE_main(THREAD_ENTRY_PARAM arg) } catch (const Firebird::Exception& e) { - e.stuff_exception(uSvc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FB_FAILURE; } @@ -590,8 +593,9 @@ int alice(Firebird::UtilSvc* uSvc) #endif if ((exit_code != FINI_OK) && uSvc->isService()) - { - memcpy(uSvc->getStatus(), tdgbl->status, sizeof (ISC_STATUS_ARRAY)); + { + uSvc->initStatus(); + uSvc->setServiceStatus(tdgbl->status); } return exit_code; diff --git a/src/burp/burp.cpp b/src/burp/burp.cpp index 8eacb180b4..74ec6f65a3 100644 --- a/src/burp/burp.cpp +++ b/src/burp/burp.cpp @@ -135,7 +135,10 @@ THREAD_ENTRY_DECLARE BURP_main(THREAD_ENTRY_PARAM arg) } catch (const Firebird::Exception& e) { - e.stuff_exception(uSvc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FB_FAILURE; } @@ -1151,8 +1154,9 @@ int gbak(Firebird::UtilSvc* uSvc) #endif if ((exit_code != FINI_OK) && uSvc->isService()) - { - memcpy(uSvc->getStatus(), tdgbl->status, sizeof (ISC_STATUS_ARRAY)); + { + uSvc->initStatus(); + uSvc->setServiceStatus(tdgbl->status); } return exit_code; diff --git a/src/common/UtilSvc.cpp b/src/common/UtilSvc.cpp index 841e451fda..83caef954c 100644 --- a/src/common/UtilSvc.cpp +++ b/src/common/UtilSvc.cpp @@ -110,9 +110,10 @@ public: virtual void putBytes(const UCHAR*, size_t) { } virtual void setServiceStatus(const ISC_STATUS*) { } virtual void setServiceStatus(const USHORT, const USHORT, const MsgFormat::SafeArg&) { } - virtual ISC_STATUS* getStatus() { return 0; } + virtual const ISC_STATUS* getStatus() { return 0; } virtual void getAddressPath(ClumpletWriter&) { } virtual bool finished() { return m_finished; }; + virtual void initStatus() { } private: bool m_finished; diff --git a/src/common/UtilSvc.h b/src/common/UtilSvc.h index 5e4a1c4962..c710336c1a 100644 --- a/src/common/UtilSvc.h +++ b/src/common/UtilSvc.h @@ -64,7 +64,8 @@ public: virtual void setServiceStatus(const ISC_STATUS*) = 0; virtual void setServiceStatus(const USHORT, const USHORT, const MsgFormat::SafeArg&) = 0; virtual void hidePasswd(ArgvType&, int) = 0; - virtual ISC_STATUS* getStatus() = 0; + virtual const ISC_STATUS* getStatus() = 0; + virtual void initStatus() = 0; virtual void checkService() = 0; virtual void getAddressPath(Firebird::ClumpletWriter& dpb) = 0; virtual bool finished() = 0; diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 43d4469380..27ffd3ac27 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -3174,7 +3174,7 @@ ISC_STATUS GDS_SERVICE_QUERY(ISC_STATUS* user_status, { memcpy(user_status, service->getStatus(), sizeof(ISC_STATUS) * len); // Empty out the service status vector - memset(service->getStatus(), 0, sizeof(ISC_STATUS_ARRAY)); + service->initStatus(); return user_status[1]; } } diff --git a/src/jrd/svc.cpp b/src/jrd/svc.cpp index 1ca690b1dc..ea1d0ed311 100644 --- a/src/jrd/svc.cpp +++ b/src/jrd/svc.cpp @@ -605,11 +605,16 @@ void Service::hidePasswd(ArgvType&, int) // no action } -ISC_STATUS* Service::getStatus() +const ISC_STATUS* Service::getStatus() { return svc_status; } +void Service::initStatus() +{ + fb_utils::init_status(svc_status); +} + void Service::checkService() { // no action @@ -2213,7 +2218,7 @@ void Service::readFbLog() } catch (const Firebird::Exception& e) { - e.stuff_exception(getStatus()); + e.stuff_exception(svc_status); } if (file) diff --git a/src/jrd/svc.h b/src/jrd/svc.h index 4d7e465810..bdd1328846 100644 --- a/src/jrd/svc.h +++ b/src/jrd/svc.h @@ -118,7 +118,9 @@ public: // utilities interface with service // no-op for services virtual void hidePasswd(ArgvType&, int); // return service status - virtual ISC_STATUS* getStatus(); + virtual const ISC_STATUS* getStatus(); + // reset service status + virtual void initStatus(); // no-op for services virtual void checkService(); // add address path (taken from spb) to dpb if present diff --git a/src/jrd/trace/TraceService.cpp b/src/jrd/trace/TraceService.cpp index 65e0db3012..7fa397e242 100644 --- a/src/jrd/trace/TraceService.cpp +++ b/src/jrd/trace/TraceService.cpp @@ -342,7 +342,10 @@ THREAD_ENTRY_DECLARE TRACE_main(THREAD_ENTRY_PARAM arg) } catch (const Exception& e) { - e.stuff_exception(svc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + svc->initStatus(); + svc->setServiceStatus(status); exit_code = FB_FAILURE; } diff --git a/src/utilities/gsec/gsec.cpp b/src/utilities/gsec/gsec.cpp index 2a9ee10fa7..f47b3fb077 100644 --- a/src/utilities/gsec/gsec.cpp +++ b/src/utilities/gsec/gsec.cpp @@ -100,7 +100,10 @@ THREAD_ENTRY_DECLARE GSEC_main(THREAD_ENTRY_PARAM arg) } catch (const Firebird::Exception& e) { - e.stuff_exception(uSvc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FB_FAILURE; } @@ -381,11 +384,8 @@ int gsec(Firebird::UtilSvc* uSvc) tdsec->tsec_throw = false; GSEC_print_status(status); - if (uSvc->getStatus()) - { - fb_utils::init_status(uSvc->getStatus()); - uSvc->setServiceStatus(status); - } + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FINI_ERROR; } diff --git a/src/utilities/gstat/dba.epp b/src/utilities/gstat/dba.epp index 64480f2720..f281bf9a78 100644 --- a/src/utilities/gstat/dba.epp +++ b/src/utilities/gstat/dba.epp @@ -267,7 +267,10 @@ THREAD_ENTRY_DECLARE main_gstat(THREAD_ENTRY_PARAM arg) } catch (const Firebird::Exception& e) { - e.stuff_exception(uSvc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FB_FAILURE; } @@ -921,8 +924,9 @@ int gstat(Firebird::UtilSvc* uSvc) } if ((exit_code != FINI_OK) && uSvc->isService()) - { - memcpy(uSvc->getStatus(), tddba->dba_status, sizeof (ISC_STATUS_ARRAY)); + { + uSvc->initStatus(); + uSvc->setServiceStatus(tddba->dba_status); } return exit_code; diff --git a/src/utilities/nbackup.cpp b/src/utilities/nbackup.cpp index a1f6ed6280..fb247f0a5b 100644 --- a/src/utilities/nbackup.cpp +++ b/src/utilities/nbackup.cpp @@ -1186,7 +1186,10 @@ THREAD_ENTRY_DECLARE NBACKUP_main(THREAD_ENTRY_PARAM arg) } catch (const Exception& e) { - e.stuff_exception(uSvc->getStatus()); + ISC_STATUS_ARRAY status; + e.stuff_exception(status); + uSvc->initStatus(); + uSvc->setServiceStatus(status); exit_code = FB_FAILURE; }