mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 22:03:03 +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)
|
: 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)
|
BePlusTree(Allocator *_pool, const BePlusTree& from)
|
||||||
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
|
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
|
||||||
{
|
{
|
||||||
|
@ -7202,15 +7202,9 @@ static void purge_attachment(thread_db* tdbb,
|
|||||||
CMP_release(tdbb, request);
|
CMP_release(tdbb, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityClass* sec_class;
|
SCL_release_all(attachment->att_security_classes);
|
||||||
while ( (sec_class = attachment->att_security_classes) ) {
|
|
||||||
SCL_release(sec_class);
|
|
||||||
}
|
|
||||||
|
|
||||||
UserId* user = attachment->att_user;
|
delete attachment->att_user;
|
||||||
if (user) {
|
|
||||||
delete user;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete attachment;
|
delete attachment;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include "../jrd/RandomGenerator.h"
|
#include "../jrd/RandomGenerator.h"
|
||||||
#include "../jrd/os/guid.h"
|
#include "../jrd/os/guid.h"
|
||||||
#include "../jrd/sbm.h"
|
#include "../jrd/sbm.h"
|
||||||
|
#include "../jrd/scl.h"
|
||||||
|
|
||||||
#ifdef DEV_BUILD
|
#ifdef DEV_BUILD
|
||||||
#define DEBUG if (debug) DBG_supervisor(debug);
|
#define DEBUG if (debug) DBG_supervisor(debug);
|
||||||
@ -542,7 +543,7 @@ public:
|
|||||||
SLONG att_lock_owner_handle; // Handle for the lock manager
|
SLONG att_lock_owner_handle; // Handle for the lock manager
|
||||||
SLONG att_event_session; // Event session id, if any
|
SLONG att_event_session; // Event session id, if any
|
||||||
SecurityClass* att_security_class; // security class for database
|
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];
|
vcl* att_counts[DBB_max_count];
|
||||||
RuntimeStatistics att_stats;
|
RuntimeStatistics att_stats;
|
||||||
ULONG att_flags; // Flags describing the state of the attachment
|
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
|
// Look for the class already known
|
||||||
|
|
||||||
SecurityClass* s_class;
|
SecurityClassList* list = attachment->att_security_classes;
|
||||||
for (s_class = attachment->att_security_classes;
|
if (list && list->locate(string))
|
||||||
s_class;
|
return list->current();
|
||||||
s_class = s_class->scl_next)
|
|
||||||
{
|
|
||||||
if (!strcmp(string.c_str(), s_class->scl_name)) {
|
|
||||||
return s_class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Class isn't known. So make up a new security class block.
|
// Class isn't known. So make up a new security class block.
|
||||||
|
|
||||||
s_class = FB_NEW_RPT(*dbb->dbb_permanent, string.length()) SecurityClass();
|
MemoryPool& pool = *dbb->dbb_permanent;
|
||||||
strcpy(s_class->scl_name, string.c_str());
|
SecurityClass* const s_class = FB_NEW(pool) SecurityClass(pool, string);
|
||||||
s_class->scl_flags = compute_access(tdbb, s_class, NULL, NULL, NULL);
|
s_class->scl_flags = compute_access(tdbb, s_class, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (s_class->scl_flags & SCL_exists)
|
if (s_class->scl_flags & SCL_exists)
|
||||||
{
|
{
|
||||||
s_class->scl_next = attachment->att_security_classes;
|
if (!list) {
|
||||||
attachment->att_security_classes = s_class;
|
attachment->att_security_classes = list = FB_NEW(pool) SecurityClassList(pool);
|
||||||
|
}
|
||||||
|
|
||||||
|
list->add(s_class);
|
||||||
return 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!
|
// 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;
|
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
|
* Functional description
|
||||||
* Release an unneeded and unloved security class.
|
* Release all security classes.
|
||||||
*
|
*
|
||||||
**************************************/
|
**************************************/
|
||||||
thread_db* tdbb = JRD_get_thread_data();
|
if (!list)
|
||||||
Attachment* attachment = tdbb->getAttachment();
|
return;
|
||||||
|
|
||||||
for (SecurityClass** next = &attachment->att_security_classes; *next;
|
if (list->getFirst())
|
||||||
next = &(*next)->scl_next)
|
|
||||||
{
|
{
|
||||||
if (*next == s_class)
|
do {
|
||||||
{
|
delete list->current();
|
||||||
*next = s_class->scl_next;
|
} while (list->getNext());
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
jrd_req* request = CMP_find_request(tdbb, irq_l_security, IRQ_REQUESTS);
|
||||||
|
|
||||||
FOR(REQUEST_HANDLE request) X IN RDB$SECURITY_CLASSES
|
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))
|
if (!REQUEST(irq_l_security))
|
||||||
REQUEST(irq_l_security) = request;
|
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 */
|
/* Security class definition */
|
||||||
|
|
||||||
class SecurityClass : public pool_alloc_rpt<SCHAR, type_scl>
|
class SecurityClass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef USHORT flags_t;
|
typedef USHORT flags_t;
|
||||||
SecurityClass* scl_next; /* Next security class in system */
|
|
||||||
flags_t scl_flags; /* Access permissions */
|
flags_t scl_flags; // Access permissions
|
||||||
TEXT scl_name[2];
|
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_read = 1; /* Read access */
|
||||||
const SecurityClass::flags_t SCL_write = 2; /* Write access */
|
const SecurityClass::flags_t SCL_write = 2; /* Write access */
|
||||||
const SecurityClass::flags_t SCL_delete = 4; /* Delete 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*);
|
Jrd::SecurityClass::flags_t SCL_get_mask(const TEXT*, const TEXT*);
|
||||||
void SCL_init(bool, const Jrd::UserId& tempId, Jrd::thread_db*);
|
void SCL_init(bool, const Jrd::UserId& tempId, Jrd::thread_db*);
|
||||||
Jrd::SecurityClass* SCL_recompute_class(Jrd::thread_db*, const TEXT*);
|
Jrd::SecurityClass* SCL_recompute_class(Jrd::thread_db*, const TEXT*);
|
||||||
void SCL_release(Jrd::SecurityClass*);
|
void SCL_release_all(Jrd::SecurityClassList*&);
|
||||||
|
|
||||||
namespace Jrd {
|
namespace Jrd {
|
||||||
typedef Firebird::Array<UCHAR> Acl;
|
typedef Firebird::Array<UCHAR> Acl;
|
||||||
|
Loading…
Reference in New Issue
Block a user