windows-misc-cleanup-20061007

reformat some code; make sure that pointers are copied while
mutexes are held; ...
This commit is contained in:
Jeffrey Altman 2006-10-07 23:32:27 +00:00
parent feb5f27c75
commit b400763506
4 changed files with 38 additions and 12 deletions

View File

@ -360,7 +360,7 @@ afsd_ServiceControlHandlerEx(
{
afsi_log("SERVICE_CONTROL_CUSTOM_DUMP");
GenerateMiniDump(NULL);
dwRet = NO_ERROR;
dwRet = NO_ERROR;
}
break;
} /* end switch(ctrlCode) */
@ -1069,10 +1069,13 @@ afsd_Main(DWORD argc, LPTSTR *argv)
#endif
#ifdef _DEBUG
afsd_DbgBreakAllocInit();
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF /*| _CRTDBG_CHECK_ALWAYS_DF*/ |
_CRTDBG_CHECK_CRT_DF /* | _CRTDBG_DELAY_FREE_MEM_DF */ );
#endif
afsd_SetUnhandledExceptionFilter();
osi_InitPanic(afsd_notifier);
osi_InitTraceOption();

View File

@ -201,7 +201,7 @@ cm_dnlcLookup (cm_scache_t *adp, cm_lookupSearch_t* sp)
ts = 0;
tnc_begin = cm_data.nameHash[skey];
for ( tvc = (cm_scache_t *) 0, tnc = tnc_begin, safety=0;
for ( tvc = (cm_scache_t *) NULL, tnc = tnc_begin, safety=0;
tnc; tnc = tnc->next, safety++ )
{
if (tnc->dirp == adp)

View File

@ -5615,9 +5615,9 @@ long smb_CloseFID(smb_vc_t *vcp, smb_fid_t *fidp, cm_user_t *userp,
afs_uint32 dosTime) {
long code = 0;
cm_req_t req;
cm_scache_t *dscp = fidp->NTopen_dscp;
char *pathp = fidp->NTopen_pathp;
cm_scache_t * scp = fidp->scp;
cm_scache_t *dscp = NULL;
char *pathp = NULL;
cm_scache_t * scp = NULL;
int deleted = 0;
int nullcreator = 0;
@ -5649,6 +5649,20 @@ long smb_CloseFID(smb_vc_t *vcp, smb_fid_t *fidp, cm_user_t *userp,
lock_ReleaseWrite(&smb_rctLock);
lock_ObtainMutex(&fidp->mx);
if (fidp->NTopen_dscp) {
dscp = fidp->NTopen_dscp;
cm_HoldSCache(dscp);
}
if (fidp->NTopen_pathp) {
pathp = strdup(fidp->NTopen_pathp);
}
if (fidp->scp) {
scp = fidp->scp;
cm_HoldSCache(scp);
}
/* Don't jump the gun on an async raw write */
while (fidp->raw_writers) {
lock_ReleaseMutex(&fidp->mx);
@ -5744,16 +5758,25 @@ long smb_CloseFID(smb_vc_t *vcp, smb_fid_t *fidp, cm_user_t *userp,
}
if (fidp->flags & SMB_FID_NTOPEN) {
cm_ReleaseSCache(fidp->NTopen_dscp);
fidp->NTopen_dscp = NULL;
free(fidp->NTopen_pathp);
fidp->NTopen_pathp = NULL;
fidp->flags &= ~SMB_FID_NTOPEN;
} else {
osi_assert(fidp->NTopen_dscp == NULL);
osi_assert(fidp->NTopen_pathp == NULL);
}
if (fidp->NTopen_wholepathp) {
free(fidp->NTopen_wholepathp);
fidp->NTopen_wholepathp = NULL;
free(fidp->NTopen_wholepathp);
fidp->NTopen_wholepathp = NULL;
}
if (fidp->scp) {
cm_ReleaseSCache(fidp->scp);
fidp->scp = NULL;
}
fidp->scp = NULL;
lock_ReleaseMutex(&fidp->mx);
if (dscp)

View File

@ -6593,10 +6593,10 @@ long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
/* save parent dir and pathname for delete or change notification */
if (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE)) {
osi_Log2(afsd_logp,"smb_ReceiveNTCreateX fidp 0x%p dscp 0x%p", fidp, dscp);
fidp->flags |= SMB_FID_NTOPEN;
fidp->NTopen_dscp = dscp;
osi_Log2(afsd_logp,"smb_ReceiveNTCreateX fidp 0x%p dscp 0x%p", fidp, dscp);
cm_HoldSCache(dscp);
dscp = NULL;
fidp->NTopen_pathp = strdup(lastNamep);
}
fidp->NTopen_wholepathp = realPathp;
@ -7214,7 +7214,7 @@ long smb_ReceiveNTTranCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *out
fidp->flags |= SMB_FID_NTOPEN;
fidp->NTopen_dscp = dscp;
osi_Log2(afsd_logp,"smb_ReceiveNTTranCreate fidp 0x%p dscp 0x%p", fidp, dscp);
cm_HoldSCache(dscp);
dscp = NULL;
fidp->NTopen_pathp = strdup(lastNamep);
}
fidp->NTopen_wholepathp = realPathp;