userp = malloc(sizeof(*userp));
memset(userp, 0, sizeof(*userp));
- userp->refCount = 1;
+ InterlockedIncrement( &userp->refCount);
lock_InitializeMutex(&userp->mx, "cm_user_t", LOCK_HIERARCHY_USER);
return userp;
}
void cm_HoldUser(cm_user_t *up)
{
+ long lcount;
+
lock_ObtainWrite(&cm_userLock);
- up->refCount++;
+ lcount = InterlockedIncrement( &up->refCount);
+ osi_assertx(lcount > 0, "user refcount error");
lock_ReleaseWrite(&cm_userLock);
}
{
cm_ucell_t *ucp;
cm_ucell_t *ncp;
+ long lcount;
if (userp == NULL)
return;
lock_ObtainWrite(&cm_userLock);
- osi_assertx(userp->refCount-- > 0, "cm_user_t refCount 0");
- if (userp->refCount == 0) {
+ lcount = InterlockedDecrement(&userp->refCount);
+ osi_assertx(lcount >= 0, "cm_user_t refCount < 0");
+ if (lcount == 0) {
lock_FinalizeMutex(&userp->mx);
for (ucp = userp->cellInfop; ucp; ucp = ncp) {
ncp = ucp->nextp;
void cm_HoldUserVCRef(cm_user_t *userp)
{
lock_ObtainMutex(&userp->mx);
- userp->vcRefs++;
+ InterlockedIncrement(&userp->vcRefs);
lock_ReleaseMutex(&userp->mx);
}
*/
void cm_ReleaseUserVCRef(cm_user_t *userp)
{
+ long lcount;
+
lock_ObtainMutex(&userp->mx);
- osi_assertx(userp->vcRefs-- > 0, "cm_user_t refCount 0");
+ lcount = InterlockedDecrement(&userp->vcRefs);
+ osi_assertx(lcount >= 0, "cm_user vcRefs refCount < 0");
lock_ReleaseMutex(&userp->mx);
}
#define CM_UCELLFLAG_ROOTUSER 0x10 /* cm_rootUser connection */
typedef struct cm_user {
- unsigned long refCount; /* ref count - cm_userLock */
+ long refCount; /* ref count - cm_userLock */
cm_ucell_t *cellInfop; /* list of cell info */
osi_mutex_t mx; /* mutex */
- int vcRefs; /* count of references from virtual circuits */
+ long vcRefs; /* count of references from virtual circuits */
long flags;
GUID authgroup; /* AFS redirector */
} cm_user_t;