for-rodney-20040404

Formatting changes

Fix the problem with a corrupted cell table when using \\afs\cell-alias

Attempt to fix Rodney's DST problem.  Added a check for tm_isdst to the
computation of the local vs GMT differential.
This commit is contained in:
Jeffrey Altman 2004-04-05 03:16:11 +00:00 committed by Jeffrey Altman
parent 4ad381d895
commit 5a8e37d882
8 changed files with 136 additions and 125 deletions

View File

@ -104,10 +104,10 @@ static cm_aclent_t *GetFreeACLEnt(void)
aclp->backp = NULL;
}
/* release the old user */
if (aclp->userp) {
/* release the old user */
if (aclp->userp) {
cm_ReleaseUser(aclp->userp);
aclp->userp = NULL;
aclp->userp = NULL;
}
return aclp;
}
@ -144,8 +144,8 @@ long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights)
aclp->backp = scp;
aclp->nextp = scp->randomACLp;
scp->randomACLp = aclp;
cm_HoldUser(userp);
aclp->userp = userp;
cm_HoldUser(userp);
aclp->randomAccess = rights;
aclp->tgtLifetime = cm_TGTLifeTime(userp);
lock_ReleaseWrite(&cm_aclLock);
@ -228,8 +228,8 @@ void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp)
for (aclp = *laclpp; aclp; laclpp = &aclp->nextp, aclp = *laclpp) {
if (userp == aclp->userp) { /* One for a given user/scache */
*laclpp = aclp->nextp;
cm_ReleaseUser(aclp->userp);
aclp->userp = NULL;
cm_ReleaseUser(aclp->userp);
aclp->userp = NULL;
aclp->backp = (struct cm_scache *) 0;
break;
}

View File

@ -1371,44 +1371,45 @@ long buf_CleanVnode(struct cm_scache *scp, cm_user_t *userp, cm_req_t *reqp)
{
long code;
cm_buf_t *bp; /* buffer we're hacking on */
cm_buf_t *nbp; /* next one */
cm_buf_t *nbp; /* next one */
long i;
i = BUF_FILEHASH(&scp->fid);
code = 0;
lock_ObtainWrite(&buf_globalLock);
bp = buf_fileHashTablepp[i];
if (bp) bp->refCount++;
lock_ReleaseWrite(&buf_globalLock);
bp = buf_fileHashTablepp[i];
if (bp) bp->refCount++;
lock_ReleaseWrite(&buf_globalLock);
for(; bp; bp = nbp) {
/* clean buffer synchronously */
if (cm_FidCmp(&bp->fid, &scp->fid) == 0) {
if (userp) {
cm_HoldUser(userp);
lock_ObtainMutex(&bp->mx);
if (bp->userp) cm_ReleaseUser(bp->userp);
bp->userp = userp;
if (bp->userp)
cm_ReleaseUser(bp->userp);
bp->userp = userp;
lock_ReleaseMutex(&bp->mx);
cm_HoldUser(userp);
}
}
buf_CleanAsync(bp, reqp);
buf_CleanWait(bp);
lock_ObtainMutex(&bp->mx);
buf_CleanWait(bp);
lock_ObtainMutex(&bp->mx);
if (bp->flags & CM_BUF_ERROR) {
if (code == 0 || code == -1) code = bp->error;
if (code == 0) code = -1;
}
lock_ReleaseMutex(&bp->mx);
if (code == 0) code = -1;
}
lock_ReleaseMutex(&bp->mx);
}
lock_ObtainWrite(&buf_globalLock);
buf_LockedRelease(bp);
nbp = bp->fileHashp;
if (nbp) nbp->refCount++;
nbp = bp->fileHashp;
if (nbp) nbp->refCount++;
lock_ReleaseWrite(&buf_globalLock);
} /* for loop over a bunch of buffers */
/* done */
/* done */
return code;
}

View File

@ -68,7 +68,7 @@ void DebugEvent0_local(char *a)
DeregisterEventSource(h);
}
#define MAXBUF_ 131
#define MAXBUF_ 512
void DebugEvent_local(char *a,char *b,...)
{
@ -150,11 +150,11 @@ static long cm_ParsePair(char *lineBufferp, char *leftp, char *rightp)
long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
cm_configProc_t *procp, void *rockp)
{
char wdir[256];
char wdir[257];
int tlen;
FILE *tfilep, *bestp, *tempp;
char *tp;
char lineBuffer[256];
char lineBuffer[257];
struct hostent *thp;
char *valuep;
struct sockaddr_in vlSockAddr;
@ -165,7 +165,7 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
#if defined(DJGPP) || defined(AFS_WIN95_ENV)
long ip_addr;
int c1, c2, c3, c4;
char aname[256];
char aname[241];
char *afsconf_path;
#endif
@ -173,7 +173,7 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
#if !defined(DJGPP)
code = GetWindowsDirectory(wdir, sizeof(wdir));
if (code == 0 || code > sizeof(wdir))
if (code == 0 || code > sizeof(wdir))
return -1;
/* add trailing backslash, if required */

View File

@ -404,8 +404,8 @@ long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
void cm_GCConnections(cm_server_t *serverp)
{
cm_conn_t *tcp;
cm_conn_t **lcpp;
cm_user_t *userp;
cm_conn_t **lcpp;
cm_user_t *userp;
lock_ObtainWrite(&cm_connLock);
lcpp = &serverp->connsp;
@ -413,38 +413,38 @@ void cm_GCConnections(cm_server_t *serverp)
userp = tcp->userp;
if (userp && tcp->refCount == 0 && (userp->vcRefs == 0)) {
/* do the deletion of this guy */
cm_ReleaseUser(userp);
*lcpp = tcp->nextp;
cm_ReleaseUser(userp);
*lcpp = tcp->nextp;
rx_DestroyConnection(tcp->callp);
lock_FinalizeMutex(&tcp->mx);
free(tcp);
}
else {
/* just advance to the next */
lcpp = &tcp->nextp;
}
lock_FinalizeMutex(&tcp->mx);
free(tcp);
}
else {
/* just advance to the next */
lcpp = &tcp->nextp;
}
}
lock_ReleaseWrite(&cm_connLock);
}
static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
cm_server_t *serverp)
{
unsigned short port;
int serviceID;
int secIndex;
struct rx_securityClass *secObjp;
unsigned short port;
int serviceID;
int secIndex;
struct rx_securityClass *secObjp;
afs_int32 level;
if (serverp->type == CM_SERVER_VLDB) {
port = htons(7003);
serviceID = 52;
}
else {
serviceID = 52;
}
else {
osi_assert(serverp->type == CM_SERVER_FILE);
port = htons(7000);
serviceID = 1;
}
port = htons(7000);
serviceID = 1;
}
if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
secIndex = 2;
if (cryptall) {
@ -453,21 +453,21 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
} else {
level = rxkad_clear;
}
secObjp = rxkad_NewClientSecurityObject(level,
&ucellp->sessionKey, ucellp->kvno,
ucellp->ticketLen, ucellp->ticketp);
}
else {
/* normal auth */
secIndex = 0;
secObjp = rxnull_NewClientSecurityObject();
}
secObjp = rxkad_NewClientSecurityObject(level,
&ucellp->sessionKey, ucellp->kvno,
ucellp->ticketLen, ucellp->ticketp);
}
else {
/* normal auth */
secIndex = 0;
secObjp = rxnull_NewClientSecurityObject();
}
osi_assert(secObjp != NULL);
tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr,
port,
serviceID,
secObjp,
secIndex);
tcp->callp = rx_NewConnection(serverp->addr.sin_addr.s_addr,
port,
serviceID,
secObjp,
secIndex);
rx_SetConnDeadTime(tcp->callp, CM_CONN_CONNDEADTIME);
rx_SetConnHardDeadTime(tcp->callp, CM_CONN_HARDDEADTIME);
tcp->ucgen = ucellp->gen;
@ -478,44 +478,44 @@ static void cm_NewRXConnection(cm_conn_t *tcp, cm_ucell_t *ucellp,
long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
{
cm_conn_t *tcp;
cm_ucell_t *ucellp;
cm_ucell_t *ucellp;
lock_ObtainMutex(&userp->mx);
lock_ObtainWrite(&cm_connLock);
for(tcp = serverp->connsp; tcp; tcp=tcp->nextp) {
if (tcp->userp == userp) break;
}
}
/* find ucell structure */
ucellp = cm_GetUCell(userp, serverp->cellp);
ucellp = cm_GetUCell(userp, serverp->cellp);
if (!tcp) {
tcp = malloc(sizeof(*tcp));
memset(tcp, 0, sizeof(*tcp));
tcp->nextp = serverp->connsp;
serverp->connsp = tcp;
tcp->userp = userp;
cm_HoldUser(userp);
lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex");
tcp->serverp = serverp;
memset(tcp, 0, sizeof(*tcp));
tcp->nextp = serverp->connsp;
serverp->connsp = tcp;
cm_HoldUser(userp);
tcp->userp = userp;
lock_InitializeMutex(&tcp->mx, "cm_conn_t mutex");
tcp->serverp = serverp;
tcp->cryptlevel = rxkad_clear;
cm_NewRXConnection(tcp, ucellp, serverp);
tcp->refCount = 1;
}
}
else {
if ((tcp->ucgen < ucellp->gen) || (tcp->cryptlevel != cryptall))
{
rx_DestroyConnection(tcp->callp);
cm_NewRXConnection(tcp, ucellp, serverp);
}
tcp->refCount++;
tcp->refCount++;
}
lock_ReleaseWrite(&cm_connLock);
lock_ReleaseMutex(&userp->mx);
lock_ReleaseMutex(&userp->mx);
/* return this pointer to our caller */
osi_Log1(afsd_logp, "cm_ConnByServer returning conn 0x%x", (long) tcp);
osi_Log1(afsd_logp, "cm_ConnByServer returning conn 0x%x", (long) tcp);
*connpp = tcp;
return 0;
return 0;
}
long cm_Conn(struct cm_fid *fidp, struct cm_user *userp, cm_req_t *reqp,

View File

@ -70,35 +70,35 @@ void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, long p1, long p2,
{
cm_bkgRequest_t *rp;
rp = malloc(sizeof(*rp));
memset(rp, 0, sizeof(*rp));
rp = malloc(sizeof(*rp));
memset(rp, 0, sizeof(*rp));
rp->scp = scp;
cm_HoldSCache(scp);
rp->userp = userp;
cm_HoldUser(userp);
rp->procp = procp;
rp->p1 = p1;
rp->p2 = p2;
rp->p3 = p3;
rp->p4 = p4;
lock_ObtainWrite(&cm_daemonLock);
cm_HoldSCache(scp);
rp->scp = scp;
cm_HoldUser(userp);
rp->userp = userp;
rp->procp = procp;
rp->p1 = p1;
rp->p2 = p2;
rp->p3 = p3;
rp->p4 = p4;
lock_ObtainWrite(&cm_daemonLock);
cm_bkgQueueCount++;
osi_QAdd((osi_queue_t **) &cm_bkgListp, &rp->q);
if (!cm_bkgListEndp) cm_bkgListEndp = rp;
lock_ReleaseWrite(&cm_daemonLock);
osi_Wakeup((long) &cm_bkgListp);
osi_QAdd((osi_queue_t **) &cm_bkgListp, &rp->q);
if (!cm_bkgListEndp) cm_bkgListEndp = rp;
lock_ReleaseWrite(&cm_daemonLock);
osi_Wakeup((long) &cm_bkgListp);
}
/* periodic check daemon */
void cm_Daemon(long parm)
{
long now;
long now;
long lastLockCheck;
long lastVolCheck;
long lastCBExpirationCheck;
long lastVolCheck;
long lastCBExpirationCheck;
long lastDownServerCheck;
long lastUpServerCheck;
long lastTokenCacheCheck;

View File

@ -100,7 +100,7 @@ void cm_HoldUser(cm_user_t *up)
void cm_ReleaseUser(cm_user_t *up)
{
cm_ucell_t *ucp;
cm_ucell_t *ncp;
cm_ucell_t *ncp;
if (up == NULL) return;
@ -108,13 +108,13 @@ void cm_ReleaseUser(cm_user_t *up)
osi_assert(up->refCount-- > 0);
if (up->refCount == 0) {
lock_FinalizeMutex(&up->mx);
for(ucp = up->cellInfop; ucp; ucp = ncp) {
for(ucp = up->cellInfop; ucp; ucp = ncp) {
ncp = ucp->nextp;
if (ucp->ticketp) free(ucp->ticketp);
free(ucp);
}
free(up);
free(ucp);
}
free(up);
}
lock_ReleaseWrite(&cm_userLock);
}
@ -154,12 +154,12 @@ void cm_CheckTokenCache(long now)
*/
lock_ObtainWrite(&smb_rctLock);
for(vcp=smb_allVCsp; vcp; vcp=vcp->nextp) {
for(usersp=vcp->usersp; usersp; usersp=usersp->nextp) {
for(usersp=vcp->usersp; usersp; usersp=usersp->nextp) {
if (usersp->unp) {
if ((userp=usersp->unp->userp)==0)
continue;
} else
continue;
if ((userp=usersp->unp->userp)==0)
continue;
} else
continue;
lock_ObtainMutex(&userp->mx);
for(ucellp=userp->cellInfop; ucellp; ucellp=ucellp->nextp) {
if(ucellp->flags & CM_UCELLFLAG_RXKAD) {

View File

@ -2401,8 +2401,8 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
if (code == 0 || Timeout != 0) {
fileLock = malloc(sizeof(cm_file_lock_t));
fileLock->LockType = LockType;
fileLock->userp = userp;
cm_HoldUser(userp);
fileLock->userp = userp;
fileLock->fid = scp->fid;
fileLock->LOffset = LOffset;
fileLock->LLength = LLength;
@ -2440,7 +2440,7 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
q = scp->fileLocks;
while (q) {
fileLock = (cm_file_lock_t *)
((char *) q - offsetof(cm_file_lock_t, fileq));
((char *) q - offsetof(cm_file_lock_t, fileq));
if (!found
&& fileLock->userp == userp
&& LargeIntegerEqualTo(fileLock->LOffset, LOffset)
@ -2480,7 +2480,8 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
lock_ReleaseMutex(&scp->mx);
do {
code = cm_Conn(&scp->fid, userp, reqp, &connp);
if (code) break;
if (code)
break;
code = RXAFS_ReleaseLock(connp->callp, &tfid, &volSync);
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
NULL, code));
@ -2596,7 +2597,7 @@ long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
code = cm_MapRPCError(code, &req);
}
handleCode:
handleCode:
if (code != 0 && code != CM_ERROR_WOULDBLOCK) {
lock_ObtainMutex(&scp->mx);
osi_QRemove(&scp->fileLocks, &oldFileLock->fileq);
@ -2608,6 +2609,7 @@ handleCode:
else if (code != CM_ERROR_WOULDBLOCK) {
oldFileLock->flags |= CM_FILELOCK_FLAG_INVALID;
cm_ReleaseUser(oldFileLock->userp);
oldFileLock->userp = NULL;
}
lock_ReleaseWrite(&cm_scacheLock);

View File

@ -528,7 +528,7 @@ smb_CalculateNowTZ()
local_tm = *(localtime(&t));
days = local_tm.tm_yday - gmt_tm.tm_yday;
hours = 24 * days + local_tm.tm_hour - gmt_tm.tm_hour;
hours = 24 * days + local_tm.tm_hour - gmt_tm.tm_hour - (local_tm.tm_isdst ? 1 : 0);
minutes = 60 * hours + local_tm.tm_min - gmt_tm.tm_min;
seconds = 60 * minutes + local_tm.tm_sec - gmt_tm.tm_sec;
@ -894,8 +894,10 @@ void smb_ReleaseUID(smb_user_t *uidp)
osi_assert(up != NULL);
*lupp = up->nextp;
lock_FinalizeMutex(&uidp->mx);
if (uidp->unp)
if (uidp->unp) {
userp = uidp->unp->userp; /* remember to drop ref later */
uidp->unp->userp = NULL;
}
}
lock_ReleaseWrite(&smb_rctLock);
if (userp) {
@ -1267,15 +1269,20 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
}
else /* create \\<netbiosName>\<cellname> */
{
if (cm_GetCell_Gen(shareName, temp, CM_FLAG_CREATE))
{
int len = min(strlen(shareName), strlen(temp));
if (!_strnicmp(shareName, temp, len)) { /* partial matches allowed */
sprintf(pathName,"/%s/",temp);
*pathNamep = strdup(strlwr(pathName));
return 1;
}
}
/* Get the full name for this cell */
code = cm_SearchCellFile(shareName, temp, 0, 0);
#ifdef AFS_AFSDB_ENV
if (code && cm_dnsEnabled) {
int ttl;
code = cm_SearchCellByDNS(shareName, temp, &ttl, 0, 0);
}
#endif
/* construct the path */
if (code == 0) {
sprintf(pathName,"/%s/",temp);
*pathNamep = strdup(strlwr(pathName));
return 1;
}
}
/* failure */
*pathNamep = NULL;
@ -4753,9 +4760,10 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
/* and record the last writer */
if (bufferp->userp != userp) {
if (bufferp->userp) cm_ReleaseUser(bufferp->userp);
bufferp->userp = userp;
cm_HoldUser(userp);
if (bufferp->userp)
cm_ReleaseUser(bufferp->userp);
bufferp->userp = userp;
}
/* adjust counters, pointers, etc. */