make crfree into a function rather than a macro to avoid bloat because of
the mutex aquire/release reorder struct ucred
This commit is contained in:
parent
6d984dfa6a
commit
5c3f70d7c0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=69401
@ -1137,6 +1137,20 @@ crget()
|
||||
return (cr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Claim another referernce to a ucred structure
|
||||
*/
|
||||
void
|
||||
crhold(cr)
|
||||
struct ucred *cr;
|
||||
{
|
||||
|
||||
mtx_enter(&cr->cr_mtx, MTX_DEF);
|
||||
cr->cr_ref++;
|
||||
mtx_exit(&(cr)->cr_mtx, MTX_DEF);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Free a cred structure.
|
||||
* Throws away space when ref count gets to 0.
|
||||
|
@ -46,24 +46,18 @@
|
||||
* Only the suser()/suser_xxx() function should be used for this.
|
||||
*/
|
||||
struct ucred {
|
||||
struct mtx cr_mtx; /* protect refcount */
|
||||
u_int cr_ref; /* reference count */
|
||||
uid_t cr_uid; /* effective user id */
|
||||
short cr_ngroups; /* number of groups */
|
||||
gid_t cr_groups[NGROUPS]; /* groups */
|
||||
struct uidinfo *cr_uidinfo; /* per uid resource consumption */
|
||||
struct mtx cr_mtx; /* protect refcount */
|
||||
};
|
||||
#define cr_gid cr_groups[0]
|
||||
#define NOCRED ((struct ucred *)0) /* no credential available */
|
||||
#define FSCRED ((struct ucred *)-1) /* filesystem credential */
|
||||
|
||||
#ifdef _KERNEL
|
||||
#define crhold(cr) \
|
||||
do { \
|
||||
mtx_enter(&(cr)->cr_mtx, MTX_DEF); \
|
||||
(cr)->cr_ref++; \
|
||||
mtx_exit(&(cr)->cr_mtx, MTX_DEF); \
|
||||
} while (0)
|
||||
|
||||
struct proc;
|
||||
|
||||
@ -73,6 +67,7 @@ struct ucred *crcopy __P((struct ucred *cr));
|
||||
struct ucred *crdup __P((struct ucred *cr));
|
||||
void crfree __P((struct ucred *cr));
|
||||
struct ucred *crget __P((void));
|
||||
void crhold __P((struct ucred *cr));
|
||||
int groupmember __P((gid_t gid, struct ucred *cred));
|
||||
#endif /* _KERNEL */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user