Skip to content

Commit 25ff2f7

Browse files
committed
WIP
1 parent cf85f59 commit 25ff2f7

File tree

14 files changed

+278
-212
lines changed

14 files changed

+278
-212
lines changed

src/include/fb_exception.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class LongJump : public Exception
7474
public:
7575
virtual void stuffByException(StaticStatusVector& status_vector) const throw();
7676
virtual const char* what() const throw();
77-
static void raise();
77+
static void raise [[noreturn]] ();
7878
LongJump() throw() : Exception() { }
7979
};
8080

@@ -85,7 +85,7 @@ class BadAlloc : public std::bad_alloc, public Exception
8585
BadAlloc() throw() : std::bad_alloc(), Exception() { }
8686
virtual void stuffByException(StaticStatusVector& status_vector) const throw();
8787
virtual const char* what() const throw();
88-
static void raise();
88+
static void raise [[noreturn]] ();
8989
};
9090

9191
// Main exception class in firebird
@@ -102,9 +102,9 @@ class status_exception : public Exception
102102

103103
const ISC_STATUS* value() const throw() { return m_status_vector; }
104104

105-
[[noreturn]] static void raise(const ISC_STATUS* status_vector);
106-
[[noreturn]] static void raise(const Arg::StatusVector& statusVector);
107-
[[noreturn]] static void raise(const IStatus* status);
105+
[[noreturn]] static void raise [[noreturn]] (const ISC_STATUS* status_vector);
106+
[[noreturn]] static void raise [[noreturn]] (const Arg::StatusVector& statusVector);
107+
[[noreturn]] static void raise [[noreturn]] (const IStatus* status);
108108

109109
protected:
110110
// Create exception with undefined status vector, this constructor allows
@@ -134,8 +134,8 @@ class system_error : public status_exception
134134
system_error(const char* syscall, const char* arg, int error_code);
135135

136136
public:
137-
static void raise(const char* syscall, int error_code);
138-
static void raise(const char* syscall);
137+
static void raise [[noreturn]] (const char* syscall, int error_code);
138+
static void raise [[noreturn]] (const char* syscall);
139139

140140
int getErrorCode() const
141141
{
@@ -153,19 +153,19 @@ class system_call_failed : public system_error
153153
system_call_failed(const char* syscall, const char* arg, int error_code);
154154

155155
public:
156-
static void raise(const char* syscall, int error_code);
157-
static void raise(const char* syscall);
158-
static void raise(const char* syscall, const char* arg, int error_code);
159-
static void raise(const char* syscall, const char* arg);
156+
static void raise [[noreturn]] (const char* syscall, int error_code);
157+
static void raise [[noreturn]] (const char* syscall);
158+
static void raise [[noreturn]] (const char* syscall, const char* arg, int error_code);
159+
static void raise [[noreturn]] (const char* syscall, const char* arg);
160160
};
161161

162162
class fatal_exception : public status_exception
163163
{
164164
public:
165165
explicit fatal_exception(const char* message);
166-
static void raiseFmt(const char* format, ...);
166+
static void raiseFmt [[noreturn]] (const char* format, ...);
167167
const char* what() const throw();
168-
static void raise(const char* message);
168+
static void raise [[noreturn]] (const char* message);
169169
};
170170

171171

src/jrd/Statement.cpp

Lines changed: 3 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Statement::Statement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb)
6666
requests(*p),
6767
externalList(*p),
6868
accessList(*p),
69-
resources(*p),
69+
resources(*p, false),
7070
triggerName(*p),
7171
triggerInvoker(NULL),
7272
parentStatement(NULL),
@@ -89,71 +89,15 @@ Statement::Statement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb)
8989
accessList = csb->csb_access;
9090
externalList = csb->csb_external;
9191
mapFieldInfo.takeOwnership(csb->csb_map_field_info);
92+
93+
// Take out existence locks on resources used in statement.
9294
resources.transferResources(tdbb, csb->csb_resources);
9395
impureSize = csb->csb_impure;
9496

9597
//if (csb->csb_g_flags & csb_blr_version4)
9698
// flags |= FLAG_VERSION4;
9799
blrVersion = csb->blrVersion;
98100

99-
// Take out existence locks on resources used in statement. This is
100-
// a little complicated since relation locks MUST be taken before
101-
// index locks.
102-
/* to be moved to transferResources()
103-
for (Resource* resource = resources.begin(); resource != resources.end(); ++resource)
104-
{
105-
switch (resource->rsc_type)
106-
{
107-
case Resource::rsc_relation:
108-
{
109-
jrd_rel* relation = resource->rsc_rel;
110-
MetadataCache::post_existence(tdbb, relation);
111-
break;
112-
}
113-
114-
case Resource::rsc_index:
115-
{
116-
jrd_rel* relation = resource->rsc_rel;
117-
IndexLock* index = CMP_get_index_lock(tdbb, relation, resource->rsc_id);
118-
if (index)
119-
{
120-
++index->idl_count;
121-
if (index->idl_count == 1) {
122-
LCK_lock(tdbb, index->idl_lock, LCK_SR, LCK_WAIT);
123-
}
124-
}
125-
break;
126-
}
127-
128-
case Resource::rsc_procedure:
129-
case Resource::rsc_function:
130-
{
131-
Routine* routine = resource->rsc_routine;
132-
routine->addRef();
133-
134-
#ifdef DEBUG_PROCS
135-
string buffer;
136-
buffer.printf(
137-
"Called from Statement::makeRequest:\n\t Incrementing use count of %s\n",
138-
routine->getName()->toString().c_str());
139-
JRD_print_procedure_info(tdbb, buffer.c_str());
140-
#endif
141-
142-
break;
143-
}
144-
145-
case Resource::rsc_collation:
146-
{
147-
Collation* coll = resource->rsc_coll;
148-
coll->incUseCount(tdbb);
149-
break;
150-
}
151-
152-
default:
153-
BUGCHECK(219); // msg 219 request of unknown resource
154-
}
155-
}
156-
*/
157101
// make a vector of all used RSEs
158102
fors = csb->csb_fors;
159103

@@ -610,50 +554,6 @@ void Statement::release(thread_db* tdbb)
610554

611555
resources.releaseResources(tdbb);
612556

613-
/* move to releaseResources()
614-
for (Resource* resource = resources.begin(); resource != resources.end(); ++resource)
615-
{
616-
switch (resource->rsc_type)
617-
{
618-
case Resource::rsc_relation:
619-
{
620-
jrd_rel* relation = resource->rsc_rel;
621-
MET_release_existence(tdbb, relation);
622-
break;
623-
}
624-
625-
case Resource::rsc_index:
626-
{
627-
jrd_rel* relation = resource->rsc_rel;
628-
IndexLock* index = CMP_get_index_lock(tdbb, relation, resource->rsc_id);
629-
if (index && index->idl_count)
630-
{
631-
--index->idl_count;
632-
if (!index->idl_count)
633-
LCK_release(tdbb, index->idl_lock);
634-
}
635-
break;
636-
}
637-
638-
case Resource::rsc_procedure:
639-
case Resource::rsc_function:
640-
resource->rsc_routine->release(tdbb);
641-
break;
642-
643-
case Resource::rsc_collation:
644-
{
645-
Collation* coll = resource->rsc_coll;
646-
coll->decUseCount(tdbb);
647-
break;
648-
}
649-
650-
default:
651-
BUGCHECK(220); // msg 220 release of unknown resource
652-
break;
653-
}
654-
}
655-
*/
656-
657557
for (Request** instance = requests.begin(); instance != requests.end(); ++instance)
658558
EXE_release(tdbb, *instance);
659559

src/jrd/Statement.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Statement : public pool_alloc<type_req>
8282
Firebird::Array<Request*> requests; // vector of requests
8383
ExternalAccessList externalList; // Access to procedures/triggers to be checked
8484
AccessItemList accessList; // Access items to be checked
85-
PermanentResourceList resources; // Resources (relations and indices)
85+
ResourceList resources; // Resources (relations and indices)
8686
const jrd_prc* procedure; // procedure, if any
8787
const Function* function; // function, if any
8888
MetaName triggerName; // name of request (trigger), if any

src/jrd/dfw.epp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,7 +4602,7 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
46024602

46034603
if (!isTempIndex)
46044604
{
4605-
if (!index->idl_lock.exLock(tdbb))
4605+
if (!index->idl_lock.exclLock(tdbb))
46064606
//!LCK_lock(tdbb, index->idl_lock, LCK_EX, transaction->getLockWait()))
46074607
{
46084608
raiseObjectInUseError("INDEX", arg->dfw_name);
@@ -4645,7 +4645,9 @@ static bool delete_index(thread_db* tdbb, SSHORT phase, DeferredWork* work, jrd_
46454645

46464646
if (index)
46474647
{
4648-
if (index->idl_lock.hasExLock(tdbb))
4648+
// if we are here that means we got exclLock() on step 3
4649+
fb_assert(index->idl_lock.hasExclLock(tdbb));
4650+
//if (index->idl_lock.hasExLock(tdbb))
46494651
{
46504652
// Release index existence lock and memory.
46514653
fb_assert(relation->rel_index_locks.load(tdbb, index->idl_id) == index);
@@ -4835,7 +4837,7 @@ static bool delete_relation(thread_db* tdbb, SSHORT phase, DeferredWork* work, j
48354837
if (relation->rel_existence_lock->getUseCount())
48364838
MetadataCache::clear_cache(tdbb);
48374839

4838-
if (relation->rel_existence_lock->exLock(tdbb))
4840+
if (!relation->rel_existence_lock->exclLock(tdbb))
48394841
/////// ??????? !LCK_convert(tdbb, relation->rel_existence_lock, LCK_EX, transaction->getLockWait())))
48404842
{
48414843
if (adjusted)

src/jrd/err.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbSta
303303
}
304304

305305

306-
void ERR_post(const Arg::StatusVector& v)
306+
void ERR_post [[noreturn]] (const Arg::StatusVector& v)
307307
/**************************************
308308
*
309309
* E R R _ p o s t
@@ -321,7 +321,7 @@ void ERR_post(const Arg::StatusVector& v)
321321
}
322322

323323

324-
void ERR_punt()
324+
void ERR_punt [[noreturn]] ()
325325
{
326326
/**************************************
327327
*

src/jrd/err_proto.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ void ERR_bugcheck_msg(const TEXT*);
5353
void ERR_soft_bugcheck(int, const TEXT*, int);
5454
void ERR_corrupt(int);
5555
void ERR_error(int);
56-
void ERR_post(const Firebird::Arg::StatusVector& v);
56+
void ERR_post [[noreturn]] (const Firebird::Arg::StatusVector& v);
5757
void ERR_post_nothrow(const Firebird::Arg::StatusVector& v, Jrd::FbStatusVector* statusVector = NULL);
5858
void ERR_post_nothrow(const Firebird::IStatus* v, Jrd::FbStatusVector* statusVector = NULL);
59-
void ERR_punt();
59+
void ERR_punt [[noreturn]] ();
6060
void ERR_warning(const Firebird::Arg::StatusVector& v);
6161
void ERR_log(int, int, const TEXT*);
6262
void ERR_append_status(Jrd::FbStatusVector*, const Firebird::Arg::StatusVector& v);

0 commit comments

Comments
 (0)