mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 14:30:06 +00:00
* nscd/connections.c (serv2db): Change type into structure which
also says whether this is a request for data. Renamed to servinfo. All users changed. (handle_request): Much simpler test whether we should search the cache.
This commit is contained in:
parent
49ee6d7965
commit
9691d83c53
@ -1,5 +1,10 @@
|
|||||||
2007-01-15 Ulrich Drepper <drepper@redhat.com>
|
2007-01-15 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
|
* nscd/connections.c (serv2db): Change type into structure which
|
||||||
|
also says whether this is a request for data. Renamed to
|
||||||
|
servinfo. All users changed.
|
||||||
|
(handle_request): Much simpler test whether we should search the cache.
|
||||||
|
|
||||||
* nscd/connections.c (handle_request): Fix thinko in selinux test
|
* nscd/connections.c (handle_request): Fix thinko in selinux test
|
||||||
invocation.
|
invocation.
|
||||||
|
|
||||||
|
@ -181,24 +181,31 @@ struct database_dyn dbs[lastdb] =
|
|||||||
|
|
||||||
|
|
||||||
/* Mapping of request type to database. */
|
/* Mapping of request type to database. */
|
||||||
static struct database_dyn *const serv2db[LASTREQ] =
|
static struct
|
||||||
{
|
{
|
||||||
[GETPWBYNAME] = &dbs[pwddb],
|
bool data_request;
|
||||||
[GETPWBYUID] = &dbs[pwddb],
|
struct database_dyn *db;
|
||||||
[GETGRBYNAME] = &dbs[grpdb],
|
} const servinfo[LASTREQ] =
|
||||||
[GETGRBYGID] = &dbs[grpdb],
|
{
|
||||||
[GETHOSTBYNAME] = &dbs[hstdb],
|
[GETPWBYNAME] = { true, &dbs[pwddb] },
|
||||||
[GETHOSTBYNAMEv6] = &dbs[hstdb],
|
[GETPWBYUID] = { true, &dbs[pwddb] },
|
||||||
[GETHOSTBYADDR] = &dbs[hstdb],
|
[GETGRBYNAME] = { true, &dbs[grpdb] },
|
||||||
[GETHOSTBYADDRv6] = &dbs[hstdb],
|
[GETGRBYGID] = { true, &dbs[grpdb] },
|
||||||
[GETFDPW] = &dbs[pwddb],
|
[GETHOSTBYNAME] = { true, &dbs[hstdb] },
|
||||||
[GETFDGR] = &dbs[grpdb],
|
[GETHOSTBYNAMEv6] = { true, &dbs[hstdb] },
|
||||||
[GETFDHST] = &dbs[hstdb],
|
[GETHOSTBYADDR] = { true, &dbs[hstdb] },
|
||||||
[GETAI] = &dbs[hstdb],
|
[GETHOSTBYADDRv6] = { true, &dbs[hstdb] },
|
||||||
[INITGROUPS] = &dbs[grpdb],
|
[SHUTDOWN] = { false, NULL },
|
||||||
[GETSERVBYNAME] = &dbs[servdb],
|
[GETSTAT] = { false, NULL },
|
||||||
[GETSERVBYPORT] = &dbs[servdb],
|
[SHUTDOWN] = { false, NULL },
|
||||||
[GETFDSERV] = &dbs[servdb]
|
[GETFDPW] = { false, &dbs[pwddb] },
|
||||||
|
[GETFDGR] = { false, &dbs[grpdb] },
|
||||||
|
[GETFDHST] = { false, &dbs[hstdb] },
|
||||||
|
[GETAI] = { true, &dbs[hstdb] },
|
||||||
|
[INITGROUPS] = { true, &dbs[grpdb] },
|
||||||
|
[GETSERVBYNAME] = { true, &dbs[servdb] },
|
||||||
|
[GETSERVBYPORT] = { true, &dbs[servdb] },
|
||||||
|
[GETFDSERV] = { false, &dbs[servdb] }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -385,7 +392,7 @@ verify_persistent_db (void *mem, struct database_pers_head *readhead, int dbnr)
|
|||||||
|
|
||||||
/* Make sure the record is for this type of service. */
|
/* Make sure the record is for this type of service. */
|
||||||
if (here->type >= LASTREQ
|
if (here->type >= LASTREQ
|
||||||
|| serv2db[here->type] != &dbs[dbnr])
|
|| servinfo[here->type].db != &dbs[dbnr])
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* Validate boolean field value. */
|
/* Validate boolean field value. */
|
||||||
@ -942,14 +949,10 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
&& nscd_request_avc_has_perm (fd, req->type) != 0)
|
&& nscd_request_avc_has_perm (fd, req->type) != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct database_dyn *db = serv2db[req->type];
|
struct database_dyn *db = servinfo[req->type].db;
|
||||||
|
|
||||||
// XXX Clean up so that each new command need not introduce a
|
/* See whether we can service the request from the cache. */
|
||||||
// XXX new conditional.
|
if (__builtin_expect (servinfo[req->type].data_request, true))
|
||||||
if ((__builtin_expect (req->type, GETPWBYNAME) >= GETPWBYNAME
|
|
||||||
&& __builtin_expect (req->type, GETHOSTBYADDRv6) <= GETHOSTBYADDRv6)
|
|
||||||
|| req->type == GETAI || req->type == INITGROUPS
|
|
||||||
|| req->type == GETSERVBYNAME || req->type == GETSERVBYPORT)
|
|
||||||
{
|
{
|
||||||
if (__builtin_expect (debug_level, 0) > 0)
|
if (__builtin_expect (debug_level, 0) > 0)
|
||||||
{
|
{
|
||||||
@ -1148,7 +1151,7 @@ cannot handle old request version %d; current version is %d"),
|
|||||||
case GETFDHST:
|
case GETFDHST:
|
||||||
case GETFDSERV:
|
case GETFDSERV:
|
||||||
#ifdef SCM_RIGHTS
|
#ifdef SCM_RIGHTS
|
||||||
send_ro_fd (serv2db[req->type], key, fd);
|
send_ro_fd (servinfo[req->type].db, key, fd);
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user