From b4007635064f08d4d0f019acc9888f0d4005708c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 7 Oct 2006 23:32:27 +0000 Subject: [PATCH] windows-misc-cleanup-20061007 reformat some code; make sure that pointers are copied while mutexes are held; ... --- src/WINNT/afsd/afsd_service.c | 5 ++++- src/WINNT/afsd/cm_dnlc.c | 2 +- src/WINNT/afsd/smb.c | 37 ++++++++++++++++++++++++++++------- src/WINNT/afsd/smb3.c | 6 +++--- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/WINNT/afsd/afsd_service.c b/src/WINNT/afsd/afsd_service.c index 369e176bb0..7b444d919d 100644 --- a/src/WINNT/afsd/afsd_service.c +++ b/src/WINNT/afsd/afsd_service.c @@ -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(); diff --git a/src/WINNT/afsd/cm_dnlc.c b/src/WINNT/afsd/cm_dnlc.c index df60841844..c6a98d4f2a 100644 --- a/src/WINNT/afsd/cm_dnlc.c +++ b/src/WINNT/afsd/cm_dnlc.c @@ -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) diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index fbce160945..b0ec3982e5 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -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) diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 0433f76c1f..676748a164 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -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;