#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
-#if defined(AFS_SUN56_ENV)
+#if defined(AFS_SUN5_ENV)
#include <inet/led.h>
#include <inet/common.h>
-#if defined(AFS_SUN58_ENV)
#include <netinet/ip6.h>
-#endif
#include <inet/ip.h>
#endif
#ifndef AFS_PAG_MANAGER
/* Forward declarations */
void afs_ResetAccessCache(afs_int32 uid, int alock);
-
-/*
- * Called with afs_xuser, afs_xserver and afs_xconn locks held, to delete
- * appropriate conn structures for au
- */
-static void
-RemoveUserConns(struct unixuser *au)
-{
- int i;
- struct server *ts;
- struct srvAddr *sa;
- struct afs_conn *tc, **lc;
-
- AFS_STATCNT(RemoveUserConns);
- for (i = 0; i < NSERVERS; i++) {
- for (ts = afs_servers[i]; ts; ts = ts->next) {
- for (sa = ts->addr; sa; sa = sa->next_sa) {
- lc = &sa->conns;
- for (tc = *lc; tc; lc = &tc->next, tc = *lc) {
- if (tc->user == au && tc->refCount == 0) {
- *lc = tc->next;
- AFS_GUNLOCK();
- rx_DestroyConnection(tc->id);
- AFS_GLOCK();
- afs_osi_Free(tc, sizeof(struct afs_conn));
- break; /* at most one instance per server */
- } /*Found unreferenced connection for user */
- } /*For each connection on the server */
- }
- } /*For each server on chain */
- } /*For each chain */
-
-} /*RemoveUserConns */
#endif /* !AFS_PAG_MANAGER */
delFlag = 0; /* should we delete this dude? */
/* Don't garbage collect users in use now (refCount) */
if (tu->refCount == 0) {
- if (tu->states & UHasTokens) {
+ if (tu->tokens) {
/* Need to walk the token stack, and dispose of
* all expired tokens */
afs_DiscardExpiredTokens(&tu->tokens, now);
if (delFlag) {
*lu = tu->next;
#ifndef AFS_PAG_MANAGER
- RemoveUserConns(tu);
+ afs_ReleaseConnsUser(tu);
#endif
afs_FreeTokens(&tu->tokens);
* If tokens are still good and user has Kerberos tickets,
* check expiration
*/
- if (!(tu->states & UTokensBad) && tu->vid != UNDEFVID) {
+ if ((tu->states & UHasTokens) && !(tu->states & UTokensBad)) {
if (!afs_HasUsableTokens(tu->tokens, now)) {
/*
* This token has expired, warn users and reset access
* cache.
*/
-#ifdef notdef
- /* I really hate this message - MLK */
- afs_warn
- ("afs: Tokens for user of AFS id %d for cell %s expired now\n",
- tu->vid, afs_GetCell(tu->cell)->cellName);
-#endif
tu->states |= (UTokensBad | UNeedsReset);
}
}
}
ReleaseReadLock(&afs_xuser);
ReleaseReadLock(&afs_xvcache);
-
} /*afs_CheckTokenCache */
void
afs_ResetUserConns(struct unixuser *auser)
{
- int i;
+ int i, j;
struct srvAddr *sa;
- struct afs_conn *tc;
+ struct sa_conn_vector *tcv;
AFS_STATCNT(afs_ResetUserConns);
ObtainReadLock(&afs_xsrvAddr);
for (i = 0; i < NSERVERS; i++) {
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
- for (tc = sa->conns; tc; tc = tc->next) {
- if (tc->user == auser) {
- tc->forceConnectFS = 1;
+ for (tcv = sa->conns; tcv; tcv = tcv->next) {
+ if (tcv->user == auser) {
+ for(j = 0; j < CVEC_LEN; ++j) {
+ (tcv->cvec[j]).forceConnectFS = 1;
+ }
}
}
}
if (tu->uid == auid && ((tu->cell == acell) || (acell == -1))) {
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
+ afs_LockUser(tu, locktype, 365);
return tu;
}
}
* We've found a previously-uncounted PAG. If it's been deleted
* but just not garbage-collected yet, we step over it.
*/
- if (currPAGP->vid == UNDEFVID)
+ if (!(currPAGP->states & UHasTokens))
continue;
/*
/* Here we setup the real cell for the client */
tu->cell = acell;
tu->refCount++;
- ReleaseWriteLock(&afs_xuser);
- return tu;
+ goto done;
} else if (tu->cell == acell || acell == -1) {
tu->refCount++;
- ReleaseWriteLock(&afs_xuser);
- return tu;
+ goto done;
}
}
}
- tu = (struct unixuser *)afs_osi_Alloc(sizeof(struct unixuser));
+ tu = afs_osi_Alloc(sizeof(struct unixuser));
+ osi_Assert(tu != NULL);
#ifndef AFS_NOSTATS
afs_stats_cmfullperf.authent.PAGCreations++;
#endif /* AFS_NOSTATS */
memset(tu, 0, sizeof(struct unixuser));
+ AFS_RWLOCK_INIT(&tu->lock, "unixuser lock");
tu->next = afs_users[i];
afs_users[i] = tu;
if (RmtUser) {
}
tu->uid = auid;
tu->cell = acell;
- tu->vid = UNDEFVID;
+ tu->viceId = UNDEFVID;
tu->refCount = 1;
tu->tokenTime = osi_Time();
+
+ done:
ReleaseWriteLock(&afs_xuser);
+ afs_LockUser(tu, locktype, 364);
return tu;
} /*afs_GetUser */
+void
+afs_LockUser(struct unixuser *au, afs_int32 locktype,
+ unsigned int src_indicator)
+{
+ switch (locktype) {
+ case READ_LOCK:
+ ObtainReadLock(&au->lock);
+ break;
+ case WRITE_LOCK:
+ ObtainWriteLock(&au->lock, src_indicator);
+ break;
+ case SHARED_LOCK:
+ ObtainSharedLock(&au->lock, src_indicator);
+ break;
+ default:
+ /* noop */
+ break;
+ }
+}
void
afs_PutUser(struct unixuser *au, afs_int32 locktype)
{
AFS_STATCNT(afs_PutUser);
+
+ switch (locktype) {
+ case READ_LOCK:
+ ReleaseReadLock(&au->lock);
+ break;
+ case WRITE_LOCK:
+ ReleaseWriteLock(&au->lock);
+ break;
+ case SHARED_LOCK:
+ ReleaseSharedLock(&au->lock);
+ break;
+ default:
+ /* noop */
+ break;
+ }
+
--au->refCount;
} /*afs_PutUser */