mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 14:03:07 +01:00
Backport faster lookup in the security classes.
This commit is contained in:
parent
ec5979c2fa
commit
501dadee9d
@ -109,6 +109,10 @@ public:
|
||||
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
|
||||
{ }
|
||||
|
||||
explicit BePlusTree(Allocator& _pool)
|
||||
: pool(&_pool), level(0), root(NULL), defaultAccessor(this)
|
||||
{ }
|
||||
|
||||
BePlusTree(Allocator *_pool, const BePlusTree& from)
|
||||
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
|
||||
{
|
||||
|
@ -7201,16 +7201,10 @@ static void purge_attachment(thread_db* tdbb,
|
||||
while ( (request = attachment->att_requests) ) {
|
||||
CMP_release(tdbb, request);
|
||||
}
|
||||
|
||||
SecurityClass* sec_class;
|
||||
while ( (sec_class = attachment->att_security_classes) ) {
|
||||
SCL_release(sec_class);
|
||||
}
|
||||
|
||||
UserId* user = attachment->att_user;
|
||||
if (user) {
|
||||
delete user;
|
||||
}
|
||||
|
||||
SCL_release_all(attachment->att_security_classes);
|
||||
|
||||
delete attachment->att_user;
|
||||
|
||||
delete attachment;
|
||||
}
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "../jrd/RandomGenerator.h"
|
||||
#include "../jrd/os/guid.h"
|
||||
#include "../jrd/sbm.h"
|
||||
#include "../jrd/scl.h"
|
||||
|
||||
#ifdef DEV_BUILD
|
||||
#define DEBUG if (debug) DBG_supervisor(debug);
|
||||
@ -542,7 +543,7 @@ public:
|
||||
SLONG att_lock_owner_handle; // Handle for the lock manager
|
||||
SLONG att_event_session; // Event session id, if any
|
||||
SecurityClass* att_security_class; // security class for database
|
||||
SecurityClass* att_security_classes; // security classes
|
||||
SecurityClassList* att_security_classes; // security classes
|
||||
vcl* att_counts[DBB_max_count];
|
||||
RuntimeStatistics att_stats;
|
||||
ULONG att_flags; // Flags describing the state of the attachment
|
||||
|
@ -460,26 +460,23 @@ SecurityClass* SCL_get_class(const TEXT* par_string)
|
||||
|
||||
// Look for the class already known
|
||||
|
||||
SecurityClass* s_class;
|
||||
for (s_class = attachment->att_security_classes;
|
||||
s_class;
|
||||
s_class = s_class->scl_next)
|
||||
{
|
||||
if (!strcmp(string.c_str(), s_class->scl_name)) {
|
||||
return s_class;
|
||||
}
|
||||
}
|
||||
SecurityClassList* list = attachment->att_security_classes;
|
||||
if (list && list->locate(string))
|
||||
return list->current();
|
||||
|
||||
// Class isn't known. So make up a new security class block.
|
||||
|
||||
s_class = FB_NEW_RPT(*dbb->dbb_permanent, string.length()) SecurityClass();
|
||||
strcpy(s_class->scl_name, string.c_str());
|
||||
MemoryPool& pool = *dbb->dbb_permanent;
|
||||
SecurityClass* const s_class = FB_NEW(pool) SecurityClass(pool, string);
|
||||
s_class->scl_flags = compute_access(tdbb, s_class, NULL, NULL, NULL);
|
||||
|
||||
if (s_class->scl_flags & SCL_exists)
|
||||
{
|
||||
s_class->scl_next = attachment->att_security_classes;
|
||||
attachment->att_security_classes = s_class;
|
||||
if (!list) {
|
||||
attachment->att_security_classes = list = FB_NEW(pool) SecurityClassList(pool);
|
||||
}
|
||||
|
||||
list->add(s_class);
|
||||
return s_class;
|
||||
}
|
||||
|
||||
@ -760,38 +757,41 @@ SecurityClass* SCL_recompute_class(thread_db* tdbb, const TEXT* string)
|
||||
|
||||
// Class no long exists - get rid of it!
|
||||
|
||||
SCL_release(s_class);
|
||||
SecurityClassList* list = tdbb->getAttachment()->att_security_classes;
|
||||
if (list && list->locate(string))
|
||||
{
|
||||
list->fastRemove();
|
||||
delete s_class;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void SCL_release(SecurityClass* s_class)
|
||||
void SCL_release_all(SecurityClassList*& list)
|
||||
{
|
||||
/**************************************
|
||||
*
|
||||
* S C L _ r e l e a s e
|
||||
* S C L _ r e l e a s e _ a l l
|
||||
*
|
||||
**************************************
|
||||
*
|
||||
* Functional description
|
||||
* Release an unneeded and unloved security class.
|
||||
* Release all security classes.
|
||||
*
|
||||
**************************************/
|
||||
thread_db* tdbb = JRD_get_thread_data();
|
||||
Attachment* attachment = tdbb->getAttachment();
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
for (SecurityClass** next = &attachment->att_security_classes; *next;
|
||||
next = &(*next)->scl_next)
|
||||
if (list->getFirst())
|
||||
{
|
||||
if (*next == s_class)
|
||||
{
|
||||
*next = s_class->scl_next;
|
||||
break;
|
||||
}
|
||||
do {
|
||||
delete list->current();
|
||||
} while (list->getNext());
|
||||
}
|
||||
|
||||
delete s_class;
|
||||
delete list;
|
||||
list = NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -963,7 +963,7 @@ static SecurityClass::flags_t compute_access(thread_db* tdbb,
|
||||
jrd_req* request = CMP_find_request(tdbb, irq_l_security, IRQ_REQUESTS);
|
||||
|
||||
FOR(REQUEST_HANDLE request) X IN RDB$SECURITY_CLASSES
|
||||
WITH X.RDB$SECURITY_CLASS EQ s_class->scl_name
|
||||
WITH X.RDB$SECURITY_CLASS EQ s_class->scl_name.c_str()
|
||||
|
||||
if (!REQUEST(irq_l_security))
|
||||
REQUEST(irq_l_security) = request;
|
||||
|
@ -30,15 +30,31 @@ const size_t ACL_BLOB_BUFFER_SIZE = MAX_USHORT; /* used to read/write acl blob *
|
||||
|
||||
/* Security class definition */
|
||||
|
||||
class SecurityClass : public pool_alloc_rpt<SCHAR, type_scl>
|
||||
class SecurityClass
|
||||
{
|
||||
public:
|
||||
typedef USHORT flags_t;
|
||||
SecurityClass* scl_next; /* Next security class in system */
|
||||
flags_t scl_flags; /* Access permissions */
|
||||
TEXT scl_name[2];
|
||||
public:
|
||||
typedef USHORT flags_t;
|
||||
|
||||
flags_t scl_flags; // Access permissions
|
||||
const Firebird::MetaName scl_name;
|
||||
|
||||
explicit SecurityClass(MemoryPool& pool, const Firebird::MetaName& name)
|
||||
: scl_flags(0), scl_name(pool, name)
|
||||
{}
|
||||
|
||||
static const Firebird::MetaName& generate(const void*, const SecurityClass* item)
|
||||
{
|
||||
return item->scl_name;
|
||||
}
|
||||
};
|
||||
|
||||
typedef Firebird::BePlusTree<
|
||||
SecurityClass*,
|
||||
Firebird::MetaName,
|
||||
Firebird::MemoryPool,
|
||||
SecurityClass
|
||||
> SecurityClassList;
|
||||
|
||||
const SecurityClass::flags_t SCL_read = 1; /* Read access */
|
||||
const SecurityClass::flags_t SCL_write = 2; /* Write access */
|
||||
const SecurityClass::flags_t SCL_delete = 4; /* Delete access */
|
||||
|
@ -43,7 +43,7 @@ Jrd::SecurityClass* SCL_get_class(const TEXT*);
|
||||
Jrd::SecurityClass::flags_t SCL_get_mask(const TEXT*, const TEXT*);
|
||||
void SCL_init(bool, const Jrd::UserId& tempId, Jrd::thread_db*);
|
||||
Jrd::SecurityClass* SCL_recompute_class(Jrd::thread_db*, const TEXT*);
|
||||
void SCL_release(Jrd::SecurityClass*);
|
||||
void SCL_release_all(Jrd::SecurityClassList*&);
|
||||
|
||||
namespace Jrd {
|
||||
typedef Firebird::Array<UCHAR> Acl;
|
||||
|
Loading…
Reference in New Issue
Block a user